[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 39dfc80 05/54: Fix :dynamic-collection not being sorted
From: |
Oleh Krehel |
Subject: |
[elpa] master 39dfc80 05/54: Fix :dynamic-collection not being sorted |
Date: |
Tue, 29 Sep 2015 14:09:47 +0000 |
branch: master
commit 39dfc80a51a2f809f16338c568960de693f69ec9
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Fix :dynamic-collection not being sorted
* ivy.el (ivy--sort-maybe): New defun. If the current completion has
sorting enabled, try to find the sorting function either in :sort or
`ivy-sort-functions-alist'.
(ivy--exhibit): Use `ivy--sort-maybe'.
* counsel.el (counsel--async-sentinel): Use `ivy--sort-maybe'.
---
counsel.el | 4 +++-
ivy.el | 20 +++++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/counsel.el b/counsel.el
index 2d41766..f667916 100644
--- a/counsel.el
+++ b/counsel.el
@@ -430,7 +430,9 @@ Skip some dotfiles unless `ivy-text' requires them."
(if (string= event "finished\n")
(progn
(with-current-buffer (process-buffer process)
- (setq ivy--all-candidates (split-string (buffer-string) "\n" t))
+ (setq ivy--all-candidates
+ (ivy--sort-maybe
+ (split-string (buffer-string) "\n" t)))
(setq ivy--old-cands ivy--all-candidates))
(ivy--exhibit))
(if (string= event "exited abnormally with code 1\n")
diff --git a/ivy.el b/ivy.el
index 6aa06a7..b6b5d00 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1289,6 +1289,23 @@ Insert .* between each char."
(defvar inhibit-message)
+(defun ivy--sort-maybe (collection)
+ "Sort COLLECTION if needed."
+ (let ((sort (ivy-state-sort ivy-last))
+ entry)
+ (if (null sort)
+ collection
+ (let ((sort-fn (cond ((functionp sort)
+ sort)
+ ((setq entry (assoc (ivy-state-collection ivy-last)
+ ivy-sort-functions-alist))
+ (cdr entry))
+ (t
+ (cdr (assoc t ivy-sort-functions-alist))))))
+ (if (functionp sort-fn)
+ (cl-sort (copy-sequence collection) sort-fn)
+ collection)))))
+
(defun ivy--exhibit ()
"Insert Ivy completions display.
Should be run via minibuffer `post-command-hook'."
@@ -1301,7 +1318,8 @@ Should be run via minibuffer `post-command-hook'."
(unless (equal ivy--old-text ivy-text)
(while-no-input
(setq ivy--all-candidates
- (funcall (ivy-state-collection ivy-last) ivy-text))
+ (ivy--sort-maybe
+ (funcall (ivy-state-collection ivy-last) ivy-text)))
(setq ivy--old-text ivy-text)))
(when ivy--all-candidates
(ivy--insert-minibuffer
- [elpa] master updated (af81566 -> 8b73497), Oleh Krehel, 2015/10/07
- [elpa] master c9235c8 04/54: counsel-locate should use '' for the regex, Oleh Krehel, 2015/10/07
- [elpa] master 432bc7e 10/54: Set line-spacing to 0 in the minibuffer, Oleh Krehel, 2015/10/07
- [elpa] master 39dfc80 05/54: Fix :dynamic-collection not being sorted,
Oleh Krehel <=
- [elpa] master 970b984 01/54: Fix up ivy-recentf and ivy-switch-buffer window-wise, Oleh Krehel, 2015/10/07
- [elpa] master b844b69 19/54: ivy.el (ivy--format-minibuffer-line): Use add-face-text-property, Oleh Krehel, 2015/10/07
- [elpa] master c78a306 09/54: ivy.el (ivy-kill-ring-save): Add and bind to "M-w", Oleh Krehel, 2015/10/07
- [elpa] master 6bf2913 25/54: Declare some SLIME functions, Oleh Krehel, 2015/10/07
- [elpa] master 5db65db 34/54: swiper.el (swiper--ivy): Fix compiler warning, Oleh Krehel, 2015/10/07
- [elpa] master 05d5e63 02/54: (counsel-locate): Allow customizing locate options, Oleh Krehel, 2015/10/07
- [elpa] master 33fa81e 14/54: counsel.el (counsel-jedi): New command, Oleh Krehel, 2015/10/07
- [elpa] master 435f2b6 38/54: Add work-around for minibuffer not re-sizing for many frames, Oleh Krehel, 2015/10/07
- [elpa] master 438e51d 24/54: counsel.el (counsel-git-grep-function): Fix up, Oleh Krehel, 2015/10/07
- [elpa] master 478e4e4 32/54: Make line numbers in swiper into display properties, Oleh Krehel, 2015/10/07