summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2019-12-23 23:11:59 +0000
committerJoão Távora <joaotavora@gmail.com>2019-12-31 13:31:45 +0000
commit5352947d0d40fbbdb2c22037d47f10e55c64c7d8 (patch)
tree259f3693a7fd5f5c312c6f6b37319d582ffed68f /lisp
parent9b6872b4e4fa782d9df313ab771c23ad1e7f8eff (diff)
downloademacs-5352947d0d40fbbdb2c22037d47f10e55c64c7d8.tar.gz
Another adjustment to flex completion style's sorting function
* lisp/minibuffer.el (completion--flex-adjust-metadata): Adjust case when minibuffer-default is non-nil. (cherry picked from commit 9c912049927cfb18b9c8b37039b38ddf51f2fe81)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/minibuffer.el23
1 files changed, 14 insertions, 9 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 0e9b1c199a3..f900557296e 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3608,16 +3608,21 @@ that is non-nil."
(> (or s1 0) (or s2 0))))))
(minibuffer-default
;; If we have an empty pattern and a non-nil default, we
- ;; probably want to make sure that default is bubbled to
- ;; the top so that a "force-completion" operation will
- ;; select it. We want that to happen even if it doesn't
- ;; match the completion perfectly.
+ ;; want to make sure that default is bubbled to the top
+ ;; so that a "force-completion" operation will select
+ ;; it. We want that to happen even if it doesn't match
+ ;; the completion perfectly.
(cl-loop
- for l on pre-sorted
- for comp = (cadr l)
- when (string-prefix-p minibuffer-default comp)
- do (setf (cdr l) (cddr l))
- and return (cons comp pre-sorted)
+ ;; JT@2019-12-23: FIXME: ideally, we want to use
+ ;; flex-matching itself on the default itself, not
+ ;; `equal' or `string-prefix-p'.
+ for fn in '(equal string-prefix-p)
+ thereis (cl-loop
+ for l on pre-sorted
+ for comp = (cadr l)
+ when (funcall fn minibuffer-default comp)
+ do (setf (cdr l) (cddr l))
+ and return (cons comp pre-sorted))
finally return pre-sorted))
(t
pre-sorted))))))