Function: marginalia--affixate

marginalia--affixate is a byte-compiled function defined in marginalia.el.

Signature

(marginalia--affixate METADATA ANNOTATOR CANDS)

Documentation

Affixate CANDS given METADATA and Marginalia ANNOTATOR.

Source Code

;; Defined in ~/.emacs.d/elpa/marginalia-20260724.810/marginalia.el
(defun marginalia--affixate (metadata annotator cands)
  "Affixate CANDS given METADATA and Marginalia ANNOTATOR."
  ;; Compute minimum width of windows, which display the minibuffer, including
  ;; the miniwindow.  In general the computed width corresponds to the full
  ;; frame width, since the miniwindow spans the full frame.  For example
  ;; `vertico-buffer' displays the minibuffer in a separate window.  Similarly,
  ;; we could detect other types of completion buffers, e.g., Embark Collect or
  ;; the default completion buffer, and compute smaller widths.
  (let* ((width (cl-loop for win in (get-buffer-window-list) minimize (window-width win)))
         (marginalia-field-width (min (/ width 2) marginalia-field-width))
         (marginalia--metadata metadata)
         (cache marginalia--cache)
         (orig-buf minibuffer--original-buffer))
    (marginalia--align
     ;; Run the annotators in the original window. `with-selected-window'
     ;; is necessary because of `lookup-minor-mode-from-indicator'.
     ;; Otherwise it would suffice to only change the current buffer. We
     ;; need the `selected-window' fallback for Embark Occur.
     (with-selected-window (or (minibuffer-selected-window) (selected-window))
       (with-current-buffer (if (buffer-live-p orig-buf) orig-buf (current-buffer))
         (cl-loop for cand in cands collect
                  (let ((ann (or (marginalia--cached cache annotator cand) "")))
                    (cons cand (if (string-blank-p ann) "" ann)))))))))