diff options
author | João Távora <joaotavora@gmail.com> | 2019-12-25 19:18:17 +0000 |
---|---|---|
committer | João Távora <joaotavora@gmail.com> | 2019-12-31 13:31:45 +0000 |
commit | 195bde9ea82e7bc62d7242bcf089ef3d181020f1 (patch) | |
tree | 25aa90458dfdcc44cb7a3960a0996b19bb19b51f /lisp/icomplete.el | |
parent | f2a349ba8d08ab5c3a491661acecd5600d9fb41b (diff) | |
download | emacs-195bde9ea82e7bc62d7242bcf089ef3d181020f1.tar.gz |
Don't always resort in recently introduced icomplete--sorted-completions
Doing so breaks icomplete-forward-completions and
icomplete-backward-completions.
* lisp/icomplete.el (icomplete--sorted-completions): Don't always
resort.
(cherry picked from commit 639fb50ed4c622f99dfbde32fbdbca42ce36d385)
Diffstat (limited to 'lisp/icomplete.el')
-rw-r--r-- | lisp/icomplete.el | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 3b3cabb890e..6bc75b39edb 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -442,36 +442,37 @@ Usually run by inclusion in `minibuffer-setup-hook'." (add-hook 'post-command-hook 'icomplete-post-command-hook nil t))) (defun icomplete--sorted-completions () - (cl-loop - with beg = (icomplete--field-beg) - with end = (icomplete--field-end) - with all = (completion-all-sorted-completions beg end) - for fn in (cond ((and minibuffer-default - (= (icomplete--field-end) (icomplete--field-beg))) - ;; When we have a non-nil default and no input - ;; whatsoever: we want to make sure that default - ;; is bubbled to the top so that - ;; `icomplete-force-complete-and-exit' will - ;; select it (do that even if the match doesn't - ;; match the completion perfectly. - `(,(lambda (comp) - (equal minibuffer-default comp)) - ,(lambda (comp) - (string-prefix-p minibuffer-default comp)))) - ((and fido-mode - (not minibuffer-default) - (eq (icomplete--category) 'file)) - `(,(lambda (comp) - (string= "./" comp))))) - thereis (cl-loop - for l on all - while (consp (cdr l)) - for comp = (cadr l) - when (funcall fn comp) - do (setf (cdr l) (cddr l)) - and return - (completion--cache-all-sorted-completions beg end (cons comp all))) - finally return all)) + (or completion-all-sorted-completions + (cl-loop + with beg = (icomplete--field-beg) + with end = (icomplete--field-end) + with all = (completion-all-sorted-completions beg end) + for fn in (cond ((and minibuffer-default + (= (icomplete--field-end) (icomplete--field-beg))) + ;; When we have a non-nil default and no input + ;; whatsoever: we want to make sure that default + ;; is bubbled to the top so that + ;; `icomplete-force-complete-and-exit' will + ;; select it (do that even if the match doesn't + ;; match the completion perfectly. + `(,(lambda (comp) + (equal minibuffer-default comp)) + ,(lambda (comp) + (string-prefix-p minibuffer-default comp)))) + ((and fido-mode + (not minibuffer-default) + (eq (icomplete--category) 'file)) + `(,(lambda (comp) + (string= "./" comp))))) + thereis (cl-loop + for l on all + while (consp (cdr l)) + for comp = (cadr l) + when (funcall fn comp) + do (setf (cdr l) (cddr l)) + and return + (completion--cache-all-sorted-completions beg end (cons comp all))) + finally return all))) |