diff options
| author | João Távora | 2019-12-25 17:54:00 +0000 |
|---|---|---|
| committer | João Távora | 2019-12-25 17:57:29 +0000 |
| commit | 83587bb68830bd91124f99ddf8590d1d5f63869f (patch) | |
| tree | 7c847caa2b78082e837d1dc53cb4196d38787f59 | |
| parent | c454fa7b48f04cdb357325137ee603e0659d9e36 (diff) | |
| download | emacs-83587bb68830bd91124f99ddf8590d1d5f63869f.tar.gz emacs-83587bb68830bd91124f99ddf8590d1d5f63869f.zip | |
Correctly cache sorted completions in icomplete--sorted-completions
* lisp/icomplete.el (icomplete--sorted-completions): Use
completion--cache-all-sorted-completions.
| -rw-r--r-- | lisp/icomplete.el | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index ec5591d806e..5126c035de1 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el | |||
| @@ -444,35 +444,36 @@ Usually run by inclusion in `minibuffer-setup-hook'." | |||
| 444 | (add-hook 'post-command-hook 'icomplete-post-command-hook nil t))) | 444 | (add-hook 'post-command-hook 'icomplete-post-command-hook nil t))) |
| 445 | 445 | ||
| 446 | (defun icomplete--sorted-completions () | 446 | (defun icomplete--sorted-completions () |
| 447 | (let ((all (completion-all-sorted-completions | 447 | (cl-loop |
| 448 | (icomplete--field-beg) (icomplete--field-end)))) | 448 | with beg = (icomplete--field-beg) |
| 449 | (cl-loop | 449 | with end = (icomplete--field-end) |
| 450 | for fn in (cond ((and minibuffer-default | 450 | with all = (completion-all-sorted-completions beg end) |
| 451 | (= (icomplete--field-end) (icomplete--field-beg))) | 451 | for fn in (cond ((and minibuffer-default |
| 452 | ;; When we have a non-nil default and no input | 452 | (= (icomplete--field-end) (icomplete--field-beg))) |
| 453 | ;; whatsoever: we want to make sure that default | 453 | ;; When we have a non-nil default and no input |
| 454 | ;; is bubbled to the top so that | 454 | ;; whatsoever: we want to make sure that default |
| 455 | ;; `icomplete-force-complete-and-exit' will | 455 | ;; is bubbled to the top so that |
| 456 | ;; select it (do that even if the match doesn't | 456 | ;; `icomplete-force-complete-and-exit' will |
| 457 | ;; match the completion perfectly. | 457 | ;; select it (do that even if the match doesn't |
| 458 | `(,(lambda (comp) | 458 | ;; match the completion perfectly. |
| 459 | (equal minibuffer-default comp)) | 459 | `(,(lambda (comp) |
| 460 | ,(lambda (comp) | 460 | (equal minibuffer-default comp)) |
| 461 | (string-prefix-p minibuffer-default comp)))) | 461 | ,(lambda (comp) |
| 462 | ((and fido-mode | 462 | (string-prefix-p minibuffer-default comp)))) |
| 463 | (not minibuffer-default) | 463 | ((and fido-mode |
| 464 | (eq (icomplete--category) 'file)) | 464 | (not minibuffer-default) |
| 465 | `(,(lambda (comp) | 465 | (eq (icomplete--category) 'file)) |
| 466 | (string= "./" comp))))) | 466 | `(,(lambda (comp) |
| 467 | thereis (cl-loop | 467 | (string= "./" comp))))) |
| 468 | for l on all | 468 | thereis (cl-loop |
| 469 | while (consp (cdr l)) | 469 | for l on all |
| 470 | for comp = (cadr l) | 470 | while (consp (cdr l)) |
| 471 | when (funcall fn comp) | 471 | for comp = (cadr l) |
| 472 | do (setf (cdr l) (cddr l)) | 472 | when (funcall fn comp) |
| 473 | and return | 473 | do (setf (cdr l) (cddr l)) |
| 474 | (setq completion-all-sorted-completions (cons comp all))) | 474 | and return |
| 475 | finally return all))) | 475 | (completion--cache-all-sorted-completions beg end (cons comp all))) |
| 476 | finally return all)) | ||
| 476 | 477 | ||
| 477 | 478 | ||
| 478 | 479 | ||