+(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).