Function: embark--with-completion-list-buffer

embark--with-completion-list-buffer is a byte-compiled function defined in embark.el.

Signature

(embark--with-completion-list-buffer FUN)

Documentation

Run function FUN in currently active *Completions* buffer.

Source Code

;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(defun embark--with-completion-list-buffer (fun)
  "Run function FUN in currently active *Completions* buffer."
  (if (derived-mode-p #'completion-list-mode)
      ;; Proceed if we're already inside the *Completions* buffer.
      (funcall fun)
    ;; Switch to the *Completions* buffer if the buffer is connected to the
    ;; current minibuffer and if the *Completions* buffer can be navigated from
    ;; the minibuffer (see `minibuffer-visible-completions').
    (when-let* ((_ (bound-and-true-p minibuffer-visible-completions))
                (_ (minibufferp))
                (window (get-buffer-window "*Completions*"))
                (buffer (window-buffer window))
                (_ (eq (current-buffer)
                       (buffer-local-value 'completion-reference-buffer buffer))))
      (with-current-buffer buffer (funcall fun)))))