Function: consult--async-sink
consult--async-sink is a byte-compiled function defined in consult.el.
Signature
(consult--async-sink)
Documentation
Asynchronous sink function.
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
(defun consult--async-sink ()
"Asynchronous sink function."
(let (candidates last buffer)
(lambda (action)
(pcase-exhaustive action
('setup
(setq buffer (current-buffer))
nil)
((or (pred stringp) 'destroy 'cancel) nil)
('flush (setq candidates nil last nil))
('refresh
;; Refresh the UI when the current minibuffer window belongs
;; to the current asynchronous completion session.
(when-let* ((win (active-minibuffer-window)))
(when (eq (window-buffer win) buffer)
(with-selected-window win
(run-hooks 'consult--completion-refresh-hook)
;; Interaction between asynchronous completion functions and
;; preview: We have to trigger preview immediately when
;; candidates arrive (gh:minad/consult#436).
(when (and consult--preview-function candidates)
(funcall consult--preview-function)))))
nil)
('nil candidates)
((pred consp)
;; Lazily initialize last link, such that it is only initialized when
;; appending, and not for one-shot async functions like
;; `consult--async-static'.
(if (not candidates)
(setq candidates action)
(setq last (last (setcdr (or last (last candidates)) action)))
candidates))))))