Function: consult--async-highlight

consult--async-highlight is a natively 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 /nix/store/6higv2v1wk916v4ynnybyrdkfy2gq44d-emacs-packages-deps/share/emacs/site-lisp/elpa/consult-20261004.957/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))))))))