emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 90aaf8b 307/348: ivy.el (ivy-completing-read): Set :caller


From: Oleh Krehel
Subject: [elpa] master 90aaf8b 307/348: ivy.el (ivy-completing-read): Set :caller to this-command
Date: Sat, 8 Apr 2017 11:04:20 -0400 (EDT)

branch: master
commit 90aaf8bfa1d02e647548076b693d99beb21ffd94
Author: Torsten Marek <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-completing-read): Set :caller to this-command
    
    Fix a bug with custom sorting functions when ivy-read is called from
    ivy-completing-read.
    
    When calling ivy-read from ivy-completing-read, always pass in :sort t
    and :caller this-command. In ivy--reset-state, look up the sorting
    function using caller.
    
    Fixes #899
---
 ivy.el | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/ivy.el b/ivy.el
index 1e2f83d..92699f0 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1283,8 +1283,7 @@ See also `ivy-sort-max-size'."
 
 (defun ivy--sort-function (collection)
   "Retrieve sort function from `ivy-sort-functions-alist'"
-  (let ((res (cdr (assoc collection ivy-sort-functions-alist))))
-    (or (car-safe res) res)))
+  (cdr (assoc collection ivy-sort-functions-alist)))
 
 (defun ivy-rotate-sort ()
   "Rotate through sorting functions available for current collection.
@@ -1666,10 +1665,10 @@ This is useful for recursive `ivy-read'."
                  (setq sort-fn (ivy--sort-function collection)))
             (when (not (eq collection 'read-file-name-internal))
               (setq coll (cl-sort coll sort-fn)))
-          (unless (eq history 'org-refile-history)
-            (if (and (setq sort-fn (ivy--sort-function t))
-                     (<= (length coll) ivy-sort-max-size))
-                (setq coll (cl-sort (copy-sequence coll) sort-fn))))))
+          (when (and (not (eq history 'org-refile-history))
+                     (<= (length coll) ivy-sort-max-size)
+                     (setq sort-fn (ivy--sort-function caller)))
+            (setq coll (cl-sort (copy-sequence coll) sort-fn)))))
       (setq coll (ivy--set-candidates coll))
       (when preselect
         (unless (or (not (stringp preselect))
@@ -1779,11 +1778,8 @@ INHERIT-INPUT-METHOD is currently ignored."
                 :preselect (if (listp def) (car def) def)
                 :history history
                 :keymap nil
-                :sort
-                (let ((sort (assoc this-command ivy-sort-functions-alist)))
-                  (if sort
-                      (ivy--sort-function (car sort))
-                    (or (ivy--sort-function t) t)))))))
+                :sort t
+                :caller this-command))))
 
 (defvar ivy-completion-beg nil
   "Completion bounds start.")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]