aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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."
1246 (setq all (delete-dups all)) 1246 (setq all (delete-dups all))
1247 (setq last (last all)) 1247 (setq last (last all))
1248 1248
1249 (setq all (if sort-fun (funcall sort-fun all) 1249 (cond
1250 ;; Prefer shorter completions, by default. 1250 (sort-fun
1251 (sort all (lambda (c1 c2) (< (length c1) (length c2)))))) 1251 (setq all (funcall sort-fun all)))
1252 ;; Prefer recently used completions and put the default, if 1252 (t
1253 ;; it exists, on top. 1253 ;; Prefer shorter completions, by default.
1254 (when (minibufferp) 1254 (setq all (sort all (lambda (c1 c2) (< (length c1) (length c2)))))
1255 (let ((hist (symbol-value minibuffer-history-variable))) 1255 (if (minibufferp)
1256 (setq all (sort all 1256 ;; Prefer recently used completions and put the default, if
1257 ;; it exists, on top.
1258 (let ((hist (symbol-value minibuffer-history-variable)))
1259 (setq all
1260 (sort all
1257 (lambda (c1 c2) 1261 (lambda (c1 c2)
1258 (cond ((equal c1 minibuffer-default) t) 1262 (cond ((equal c1 minibuffer-default) t)
1259 ((equal c2 minibuffer-default) nil) 1263 ((equal c2 minibuffer-default) nil)
1260 (t (> (length (member c1 hist)) 1264 (t (> (length (member c1 hist))
1261 (length (member c2 hist)))))))))) 1265 (length (member c2 hist))))))))))))
1262 ;; Cache the result. This is not just for speed, but also so that 1266 ;; Cache the result. This is not just for speed, but also so that
1263 ;; repeated calls to minibuffer-force-complete can cycle through 1267 ;; repeated calls to minibuffer-force-complete can cycle through
1264 ;; all possibilities. 1268 ;; all possibilities.