Function: consult--async-highlight

consult--async-highlight is a byte-compiled function defined in consult.el.

Signature

(consult--async-highlight &optional HIGHLIGHT)

Documentation

Async function with candidate highlighting.

HIGHLIGHT is a function called with the input string. It should return a function which mutably adds highlighting to a candidate string. HIGHLIGHT can also return a pair where the second element is the actual highlight function. If not given, HIGHLIGHT defaults to a function which highlights words.

Source Code

;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
(defun consult--async-highlight (&optional highlight)
  "Async function with candidate highlighting.
HIGHLIGHT is a function called with the input string.  It should return
a function which mutably adds highlighting to a candidate string.
HIGHLIGHT can also return a pair where the second element is the actual
highlight function.  If not given, HIGHLIGHT defaults to a function
which highlights words."
  (unless (functionp highlight)
    (setq highlight
          (lambda (input)
            (consult--compile-regexp input 'emacs completion-ignore-case))))
  (consult--async-transform-by-input
   (lambda (input)
     (when-let* ((hl (funcall highlight input))
                 (hl (if (functionp hl) hl (cdr hl))))
       (lambda (cands)
         (dolist (x cands cands)
           (funcall hl (if (consp x) (car x) x))))))))