summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2024-04-09 06:38:25 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2024-04-09 06:38:25 +0200
commite7429b93bc61a9b76efdc2590d08af221b102f4c (patch)
tree251f9eec4059b71d158f89f55e02c4b604190e03
parent114285b6b0a1f6f15c3203ad8a71e0fb9c74de96 (diff)
completion-hilit-commonality supports completion-lazy-hilit
-rw-r--r--corfu.el17
1 files changed, 7 insertions, 10 deletions
diff --git a/corfu.el b/corfu.el
index 52dcaf2..bf51818 100644
--- a/corfu.el
+++ b/corfu.el
@@ -534,15 +534,7 @@ FRAME is the existing frame."
(defun corfu--filter-completions (&rest args)
"Compute all completions for ARGS with lazy highlighting."
- (defvar completion-lazy-hilit)
- (defvar completion-lazy-hilit-fn)
- (cl-letf* ((completion-lazy-hilit t)
- (completion-lazy-hilit-fn nil)
- ((symbol-function #'completion-hilit-commonality)
- (lambda (cands prefix &optional base)
- (setq completion-lazy-hilit-fn
- (lambda (x) (car (completion-hilit-commonality (list x) prefix base))))
- (and cands (nconc cands base)))))
+ (dlet ((completion-lazy-hilit t) (completion-lazy-hilit-fn nil))
(if (eval-when-compile (>= emacs-major-version 30))
(cons (apply #'completion-all-completions args) completion-lazy-hilit-fn)
(cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality))
@@ -562,7 +554,12 @@ FRAME is the existing frame."
(condition-case nil
(car (completion-pcm--hilit-commonality pattern (list x)))
(t x))))
- cands)))
+ cands))
+ ((symbol-function #'completion-hilit-commonality)
+ (lambda (cands prefix &optional base)
+ (setq completion-lazy-hilit-fn
+ (lambda (x) (car (completion-hilit-commonality (list x) prefix base))))
+ (and cands (nconc cands base)))))
(cons (apply #'completion-all-completions args) completion-lazy-hilit-fn)))))
(defsubst corfu--length-string< (x y)