[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f30801a2033: (completion-hilit-commonality): Support `completion-
From: |
Stefan Monnier |
Subject: |
master f30801a2033: (completion-hilit-commonality): Support `completion-lazy-hilit` |
Date: |
Mon, 8 Apr 2024 22:32:08 -0400 (EDT) |
branch: master
commit f30801a20338cdc7716c3eff1443f1be603aa94e
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
(completion-hilit-commonality): Support `completion-lazy-hilit`
* lisp/minibuffer.el (completion-hilit-commonality): Support lazy
completion candidate highlighting via `completion-lazy-hilit`.
---
lisp/minibuffer.el | 60 +++++++++++++++++++++++++++++-------------------------
1 file changed, 32 insertions(+), 28 deletions(-)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index b007320b110..41b20174be1 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2375,34 +2375,38 @@ This adds the face `completions-common-part' to the
first
It returns a list with font-lock properties applied to each element,
and with BASE-SIZE appended as the last element."
(when completions
- (let ((com-str-len (- prefix-len (or base-size 0))))
- (nconc
- (mapcar
- (lambda (elem)
- (let ((str
- ;; Don't modify the string itself, but a copy, since the
- ;; string may be read-only or used for other purposes.
- ;; Furthermore, since `completions' may come from
- ;; display-completion-list, `elem' may be a list.
- (if (consp elem)
- (car (setq elem (cons (copy-sequence (car elem))
- (cdr elem))))
- (setq elem (copy-sequence elem)))))
- (font-lock-prepend-text-property
- 0
- ;; If completion-boundaries returns incorrect
- ;; values, all-completions may return strings
- ;; that don't contain the prefix.
- (min com-str-len (length str))
- 'face 'completions-common-part str)
- (if (> (length str) com-str-len)
- (font-lock-prepend-text-property com-str-len (1+ com-str-len)
- 'face
- 'completions-first-difference
- str)))
- elem)
- completions)
- base-size))))
+ (let* ((com-str-len (- prefix-len (or base-size 0)))
+ (hilit-fn
+ (lambda (str)
+ (font-lock-prepend-text-property
+ 0
+ ;; If completion-boundaries returns incorrect values,
+ ;; all-completions may return strings that don't contain
+ ;; the prefix.
+ (min com-str-len (length str))
+ 'face 'completions-common-part str)
+ (when (> (length str) com-str-len)
+ (font-lock-prepend-text-property
+ com-str-len (1+ com-str-len)
+ 'face 'completions-first-difference str))
+ str)))
+ (if completion-lazy-hilit
+ (setq completion-lazy-hilit-fn hilit-fn)
+ (setq completions
+ (mapcar
+ (lambda (elem)
+ ;; Don't modify the string itself, but a copy, since
+ ;; the string may be read-only or used for other
+ ;; purposes. Furthermore, since `completions' may come
+ ;; from display-completion-list, `elem' may be a list.
+ (funcall hilit-fn
+ (if (consp elem)
+ (car (setq elem (cons (copy-sequence (car elem))
+ (cdr elem))))
+ (setq elem (copy-sequence elem))))
+ elem)
+ completions)))
+ (nconc completions base-size))))
(defun display-completion-list (completions &optional common-substring
group-fun)
"Display the list of completions, COMPLETIONS, using `standard-output'.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f30801a2033: (completion-hilit-commonality): Support `completion-lazy-hilit`,
Stefan Monnier <=