]> git.eshelyaron.com Git - emacs.git/commitdiff
cycle-sort-function prevails in completion-all-sorted-completions
authorJoão Távora <joaotavora@gmail.com>
Mon, 18 Feb 2019 20:41:09 +0000 (20:41 +0000)
committerJoão Távora <joaotavora@gmail.com>
Tue, 19 Feb 2019 09:11:28 +0000 (09:11 +0000)
* lisp/minibuffer.el (completion-all-sorted-completions): If
completion table has cycle-sort-function, that prevails over other
sorting strategies.

lisp/minibuffer.el

index 7413be42ebdd8902eea673a5896130ee80cb0175..cc87ffaced58f9b66d29347755b3c22f346a3fe0 100644 (file)
@@ -1246,19 +1246,23 @@ scroll the window of possible completions."
           (setq all (delete-dups all))
           (setq last (last all))
 
-          (setq all (if sort-fun (funcall sort-fun all)
-                      ;; Prefer shorter completions, by default.
-                      (sort all (lambda (c1 c2) (< (length c1) (length c2))))))
-          ;; Prefer recently used completions and put the default, if
-          ;; it exists, on top.
-          (when (minibufferp)
-            (let ((hist (symbol-value minibuffer-history-variable)))
-              (setq all (sort all
+          (cond
+           (sort-fun
+            (setq all (funcall sort-fun all)))
+           (t
+            ;; Prefer shorter completions, by default.
+            (setq all (sort all (lambda (c1 c2) (< (length c1) (length c2)))))
+            (if (minibufferp)
+                ;; Prefer recently used completions and put the default, if
+                ;; it exists, on top.
+                (let ((hist (symbol-value minibuffer-history-variable)))
+                  (setq all
+                        (sort all
                               (lambda (c1 c2)
                                 (cond ((equal c1 minibuffer-default) t)
                                       ((equal c2 minibuffer-default) nil)
                                       (t (> (length (member c1 hist))
-                                            (length (member c2 hist))))))))))
+                                            (length (member c2 hist))))))))))))
           ;; Cache the result.  This is not just for speed, but also so that
           ;; repeated calls to minibuffer-force-complete can cycle through
           ;; all possibilities.