emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f845f8a 1/2: Use minibuffer-default in completion-a


From: João Távora
Subject: [Emacs-diffs] master f845f8a 1/2: Use minibuffer-default in completion-all-sorted-completions (bug#34083)
Date: Fri, 25 Jan 2019 12:33:21 -0500 (EST)

branch: master
commit f845f8a279cfc2acd1051b4cd4924e2aede54017
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Use minibuffer-default in completion-all-sorted-completions (bug#34083)
    
    * lisp/minibuffer (completion-all-sorted-completions): Sort with the
    default on top.
---
 lisp/minibuffer.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c8b84b0..b757eb8 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1244,12 +1244,16 @@ scroll the window of possible completions."
           (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.
+          ;; 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 (lambda (c1 c2)
-                                    (> (length (member c1 hist))
-                                       (length (member c2 hist))))))))
+              (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))))))))))
           ;; Cache the result.  This is not just for speed, but also so that
           ;; repeated calls to minibuffer-force-complete can cycle through
           ;; all possibilities.



reply via email to

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