Function: consult--with-async-f
consult--with-async-f is a byte-compiled function defined in
consult.el.
Signature
(consult--with-async-f ASYNC BODY)
Documentation
See consult--with-async for documentation.
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
(defun consult--with-async-f (async body)
"See `consult--with-async' for documentation."
(let (new-chunk orig-chunk)
(minibuffer-with-setup-hook
;; Append such that we overwrite the completion style setting of
;; `fido-mode'. See `consult--async-split' and `consult--split-setup'.
(:append
(lambda ()
(when (consult--async-p async)
(setq new-chunk (max read-process-output-max consult--process-chunk)
orig-chunk read-process-output-max
read-process-output-max new-chunk)
(funcall async 'setup)
(let* ((mb (current-buffer))
(fun (lambda ()
(when-let* ((win (active-minibuffer-window)))
(when (eq (window-buffer win) mb)
(with-current-buffer mb
(let ((inhibit-modification-hooks t))
;; Push input string to request refresh.
(funcall async (minibuffer-contents-no-properties))))))))
;; We use a symbol in order to avoid adding lambdas to
;; the hook variable. Symbol indirection because of
;; bug#46407.
(hook (make-symbol "consult--async-after-change"))
(timer (timer-create)))
(timer-set-function timer fun)
;; Delay modification hook to ensure that minibuffer is still
;; alive after the change, such that we don't restart a new
;; asynchronous search right before exiting the minibuffer.
(fset hook (lambda (&rest _)
(unless (memq timer timer-list)
(timer-set-time timer (current-time))
(timer-activate timer))))
(add-hook 'after-change-functions hook nil 'local)
;; Immediately start asynchronous computation. This may lead
;; to problems unnecessary work if content is inserted shortly
;; afterwards.
(funcall fun)))))
(let ((async (if (consult--async-p async) async (lambda (_) async))))
(unwind-protect
(funcall body async)
(funcall async 'destroy)
(when (and orig-chunk (eq read-process-output-max new-chunk))
(setq read-process-output-max orig-chunk)))))))