branch: externals/vertico commit 5ed4530dd354df0f46709fa66e2e117cceb56933 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
More robust deferred highlighting for orderless --- vertico.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vertico.el b/vertico.el index fca08e8..83e3e48 100644 --- a/vertico.el +++ b/vertico.el @@ -238,9 +238,6 @@ ;; bug#47711: Deferred highlighting for `completion-all-completions' ;; XXX There is one complication: `completion--twq-all' already adds `completions-common-part'. ;; See below `vertico--candidate'. -(declare-function orderless-highlight-matches "ext:orderless") -(declare-function orderless-pattern-compiler "ext:orderless") -(require 'orderless nil 'noerror) (defun vertico--all-completions (&rest args) "Compute all completions for ARGS with deferred highlighting." (cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality)) @@ -265,13 +262,16 @@ (condition-case nil (completion-pcm--hilit-commonality pattern x) (t x)))) - cands)) - ((symbol-function #'orderless-highlight-matches) - (lambda (pattern cands) - (let ((regexps (orderless-pattern-compiler pattern))) - (setq hl (lambda (x) (orderless-highlight-matches regexps x)))) cands))) - (cons (apply #'completion-all-completions args) hl))) + ;; Only advise orderless after it has been loaded to avoid load order issues + (if (and (fboundp 'orderless-highlight-matches) (fboundp 'orderless-pattern-compiler)) + (cl-letf (((symbol-function 'orderless-highlight-matches) + (lambda (pattern cands) + (let ((regexps (orderless-pattern-compiler pattern))) + (setq hl (lambda (x) (orderless-highlight-matches regexps x)))) + cands))) + (cons (apply #'completion-all-completions args) hl)) + (cons (apply #'completion-all-completions args) hl)))) (defun vertico--recompute-candidates (pt content bounds metadata) "Recompute candidates given PT, CONTENT, BOUNDS and METADATA."