Function: consult--async-merge-sink
consult--async-merge-sink is a byte-compiled function defined in
consult.el.
Signature
(consult--async-merge-sink SINK INDICATOR TAIL IDX)
Documentation
Create sink for the async sub-functions which merges the sub-lists.
SINK is the joined sink. INDICATOR is a vector of indicator symbols. TAIL is a vector of list tail links for each sub-list. IDX is the index of the corresponding link in TAIL.
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
(defun consult--async-merge-sink (sink indicator tail idx)
"Create sink for the async sub-functions which merges the sub-lists.
SINK is the joined sink.
INDICATOR is a vector of indicator symbols.
TAIL is a vector of list tail links for each sub-list.
IDX is the index of the corresponding link in TAIL."
(lambda (action)
(pcase action
(`[indicator ,state]
(aset indicator (1- idx) state)
(let* ((severity [nil finished running killed failed])
(state (aref severity (cl-loop for i across indicator maximize
(or (seq-position severity i) 0)))))
(funcall sink `[indicator ,state])))
('flush
;; Flush items if sub-list exists.
(when-let* ((tl (aref tail idx)) (pre t))
(let ((i idx)) (while (not (setq pre (aref tail (decf i))))))
(setcdr pre (cdr tl))
(aset tail idx nil)
(funcall sink 'flush)
(funcall sink (cdr (aref tail 0)))))
((pred consp)
(let ((tl (aref tail idx))
(last (last action))
pre)
(aset tail idx last)
(if tl ;; Append items if sub-list exists.
(progn
(setcdr last (cdr tl))
(setcdr tl action))
;; Otherwise insert new sub-list.
(let ((i idx)) (while (not (setq pre (aref tail (decf i))))))
(setcdr last (cdr pre))
(setcdr pre action))
(funcall sink 'flush)
(funcall sink (cdr (aref tail 0))))))))