diff options
| author | João Távora | 2019-02-18 20:41:09 +0000 |
|---|---|---|
| committer | João Távora | 2019-02-19 09:11:28 +0000 |
| commit | e8b6cc9a99374b135a3a71dabefcdf98fe2bc6e6 (patch) | |
| tree | e89a4070a9a1349b0173ddbb46648d4bdfe5044c | |
| parent | 55478e4ad724fcc1194c9556b7699e6144e64971 (diff) | |
| download | emacs-e8b6cc9a99374b135a3a71dabefcdf98fe2bc6e6.tar.gz emacs-e8b6cc9a99374b135a3a71dabefcdf98fe2bc6e6.zip | |
cycle-sort-function prevails in completion-all-sorted-completions
* lisp/minibuffer.el (completion-all-sorted-completions): If
completion table has cycle-sort-function, that prevails over other
sorting strategies.
| -rw-r--r-- | lisp/minibuffer.el | 22 |
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. |