aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2019-12-25 19:18:17 +0000
committerJoão Távora2019-12-25 19:18:17 +0000
commit639fb50ed4c622f99dfbde32fbdbca42ce36d385 (patch)
tree910b05e8ac062e18388e85ca4464bcdd2b8502ed
parent13778aa5be7bf028893672d84c2a291f491d8216 (diff)
downloademacs-639fb50ed4c622f99dfbde32fbdbca42ce36d385.tar.gz
emacs-639fb50ed4c622f99dfbde32fbdbca42ce36d385.zip
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.
-rw-r--r--lisp/icomplete.el61
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'."
442 (add-hook 'post-command-hook 'icomplete-post-command-hook nil t))) 442 (add-hook 'post-command-hook 'icomplete-post-command-hook nil t)))
443 443
444(defun icomplete--sorted-completions () 444(defun icomplete--sorted-completions ()
445 (cl-loop 445 (or completion-all-sorted-completions
446 with beg = (icomplete--field-beg) 446 (cl-loop
447 with end = (icomplete--field-end) 447 with beg = (icomplete--field-beg)
448 with all = (completion-all-sorted-completions beg end) 448 with end = (icomplete--field-end)
449 for fn in (cond ((and minibuffer-default 449 with all = (completion-all-sorted-completions beg end)
450 (= (icomplete--field-end) (icomplete--field-beg))) 450 for fn in (cond ((and minibuffer-default
451 ;; When we have a non-nil default and no input 451 (= (icomplete--field-end) (icomplete--field-beg)))
452 ;; whatsoever: we want to make sure that default 452 ;; When we have a non-nil default and no input
453 ;; is bubbled to the top so that 453 ;; whatsoever: we want to make sure that default
454 ;; `icomplete-force-complete-and-exit' will 454 ;; is bubbled to the top so that
455 ;; select it (do that even if the match doesn't 455 ;; `icomplete-force-complete-and-exit' will
456 ;; match the completion perfectly. 456 ;; select it (do that even if the match doesn't
457 `(,(lambda (comp) 457 ;; match the completion perfectly.
458 (equal minibuffer-default comp)) 458 `(,(lambda (comp)
459 ,(lambda (comp) 459 (equal minibuffer-default comp))
460 (string-prefix-p minibuffer-default comp)))) 460 ,(lambda (comp)
461 ((and fido-mode 461 (string-prefix-p minibuffer-default comp))))
462 (not minibuffer-default) 462 ((and fido-mode
463 (eq (icomplete--category) 'file)) 463 (not minibuffer-default)
464 `(,(lambda (comp) 464 (eq (icomplete--category) 'file))
465 (string= "./" comp))))) 465 `(,(lambda (comp)
466 thereis (cl-loop 466 (string= "./" comp)))))
467 for l on all 467 thereis (cl-loop
468 while (consp (cdr l)) 468 for l on all
469 for comp = (cadr l) 469 while (consp (cdr l))
470 when (funcall fn comp) 470 for comp = (cadr l)
471 do (setf (cdr l) (cddr l)) 471 when (funcall fn comp)
472 and return 472 do (setf (cdr l) (cddr l))
473 (completion--cache-all-sorted-completions beg end (cons comp all))) 473 and return
474 finally return all)) 474 (completion--cache-all-sorted-completions beg end (cons comp all)))
475 finally return all)))
475 476
476 477
477 478