[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [elpa] externals/vertico a962a8b 2/3: Implement deferred highlightin
From: |
Stefan Monnier |
Subject: |
Re: [elpa] externals/vertico a962a8b 2/3: Implement deferred highlighting for all completion styles |
Date: |
Sun, 11 Apr 2021 12:37:34 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> +(declare-function orderless-highlight-matches "ext:orderless")
> +(defun vertico--all-completions (&rest args)
> + "Compute all completions for ARGS with deferred highlighting."
> + (cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality))
> + (orig-flex (symbol-function #'completion-flex-all-completions))
> + ((symbol-function #'completion-flex-all-completions)
> + (lambda (&rest args)
> + ;; Unfortunately for flex we have to undo the deferred
> highlighting, since flex uses
> + ;; the completion-score for sorting, which is applied during
> highlighting.
> + (cl-letf (((symbol-function
> #'completion-pcm--hilit-commonality) orig-pcm))
> + (apply orig-flex args))))
> + ;; Defer the following highlighting functions
> + (hl #'identity)
> + ((symbol-function #'completion-hilit-commonality)
> + (lambda (cands prefix &optional base)
> + (setq hl (lambda (x) (nconc (completion-hilit-commonality x
> prefix base) nil)))
> + (and cands (nconc cands base))))
> + ((symbol-function #'completion-pcm--hilit-commonality)
> + (lambda (pattern cands)
> + (setq hl (lambda (x) (completion-pcm--hilit-commonality
> pattern x)))
> + cands))
> + ((symbol-function #'orderless-highlight-matches)
> + (lambda (pattern cands)
> + (setq hl (lambda (x) (orderless-highlight-matches pattern
> x)))
> + cands)))
> + (cons (apply #'completion-all-completions args) hl)))
Yuck!
I think this should have a bug#NNN attached to make sure it's only used
on a temporary basis (i.e. until Emacs's minibuffer.el provides the
corresponding functionality).
Stefan
- Re: [elpa] externals/vertico a962a8b 2/3: Implement deferred highlighting for all completion styles,
Stefan Monnier <=