aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/minibuffer.el38
1 files changed, 27 insertions, 11 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5dc753ffd5c..96931162cc1 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3585,17 +3585,33 @@ that is non-nil."
3585 (cl-flet ((compose-flex-sort-fn 3585 (cl-flet ((compose-flex-sort-fn
3586 (existing-sort-fn) ; wish `cl-flet' had proper indentation... 3586 (existing-sort-fn) ; wish `cl-flet' had proper indentation...
3587 (lambda (completions) 3587 (lambda (completions)
3588 (let ((res 3588 (let* ((by-score
3589 (if existing-sort-fn 3589 (sort
3590 (funcall existing-sort-fn completions) 3590 (if existing-sort-fn
3591 completions))) 3591 (funcall existing-sort-fn completions)
3592 (sort 3592 completions)
3593 res 3593 (lambda (c1 c2)
3594 (lambda (c1 c2) 3594 (let ((s1 (get-text-property 0 'completion-score c1))
3595 (or (equal c1 minibuffer-default) 3595 (s2 (get-text-property 0 'completion-score c2)))
3596 (let ((s1 (get-text-property 0 'completion-score c1)) 3596 (> (or s1 0) (or s2 0))))))
3597 (s2 (get-text-property 0 'completion-score c2))) 3597 (promoted-default
3598 (> (or s1 0) (or s2 0)))))))))) 3598 (and minibuffer-default
3599 (and (window-minibuffer-p)
3600 (= (point-max)
3601 (minibuffer-prompt-end)))
3602 ;; If we have an empty pattern and a
3603 ;; non-nil default we probably want to
3604 ;; make sure that default is bubbled to
3605 ;; the top even if it doesn't match the
3606 ;; completion perfectly (like in M-x man
3607 ;; case)
3608 (cl-loop
3609 for l on by-score
3610 for comp = (cadr l)
3611 when (string-prefix-p minibuffer-default comp)
3612 do (setf (cdr l) (cddr l))
3613 and return (cons comp by-score)))))
3614 (or promoted-default by-score)))))
3599 `(metadata 3615 `(metadata
3600 (display-sort-function 3616 (display-sort-function
3601 . ,(compose-flex-sort-fn 3617 . ,(compose-flex-sort-fn