Function: consult--async-split

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

Signature

(consult--async-split &optional STYLE)

Documentation

Async function, which splits the input string.

STYLE is the splitting style and defaults to the splitting style configured by consult-async-split-style.

Source Code

;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
(defun consult--async-split (&optional style)
  "Async function, which splits the input string.
STYLE is the splitting style and defaults to the splitting style
configured by `consult-async-split-style'."
  (setq style (or style consult-async-split-style 'none)
        style (or (alist-get style consult-async-split-styles-alist)
                  (user-error "Splitting style `%s' not found" style)))
  (lambda (sink)
    (lambda (action)
      (pcase action
        ('setup
         (consult--split-setup (let ((fun (plist-get style :function)))
                                 (lambda (str) (funcall fun str style))))
         (when-let* ((initial (plist-get style :initial)))
           (save-excursion
             (goto-char (minibuffer-prompt-end))
             (unless (equal initial (char-after))
               (insert-before-markers initial))))
         (funcall sink 'setup))
        ((pred stringp)
         (pcase-let ((`(,input ,_ . ,highlights)
                      (funcall (plist-get style :function) action style))
                     (end (minibuffer-prompt-end)))
           ;; Highlight punctuation characters
           (pcase-dolist (`(,x . ,y) highlights)
             (add-text-properties (+ end x) (+ end y)
                                  '(face consult-async-split consult--split t rear-nonsticky t)))
           (funcall sink input)))
        (_ (funcall sink action))))))