summaryrefslogtreecommitdiff
path: root/lisp/minibuffer.el
diff options
context:
space:
mode:
authorTassilo Horn <tsdh@gnu.org>2019-02-20 16:58:57 +0100
committerTassilo Horn <tsdh@gnu.org>2019-02-20 16:58:57 +0100
commite5c99a1757c281953257ac2548fb77702af75c86 (patch)
tree4820116244ad6650f53208bc792ca248ccc630fb /lisp/minibuffer.el
parentbfa10b704ebe71c91d5e5eb28e407a02d2d88863 (diff)
parentae77728d14e58054bdaee3c6965979947c778208 (diff)
downloademacs-scratch/replace-region-contents.tar.gz
Merge branch 'master' into scratch/replace-region-contentsscratch/replace-region-contents
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r--lisp/minibuffer.el22
1 files changed, 13 insertions, 9 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 7413be42ebd..cc87ffaced5 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -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.