branch: externals/marginalia commit f9ca52c4e5c2d2a0b1f175309102d68378464ed2 Author: Omar Antolín <omar.anto...@gmail.com> Commit: Omar Antolín <omar.anto...@gmail.com>
Fallback for when full candidate is requested outside of minibuffer If marginalia--full-candidate is called when the minibuffer is no longer active, return cand unchanged. I made this change to support Embark which can call annotators from Embark Occur buffers when the minibuffer is not longer active. --- marginalia.el | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/marginalia.el b/marginalia.el index 862867a..9081339 100644 --- a/marginalia.el +++ b/marginalia.el @@ -271,16 +271,20 @@ component of a full file path. This function returns what would be the minibuffer contents after using `minibuffer-force-complete' on the candidate CAND." - (let* ((contents (minibuffer-contents)) - (pt (- (point) (minibuffer-prompt-end))) - (bounds (completion-boundaries - (substring contents 0 pt) - minibuffer-completion-table - minibuffer-completion-predicate - (substring contents pt)))) - (concat (substring contents 0 (car bounds)) - cand - (substring contents (+ pt (cdr bounds)))))) + (if (minibufferp) + (let* ((contents (minibuffer-contents)) + (pt (- (point) (minibuffer-prompt-end))) + (bounds (completion-boundaries + (substring contents 0 pt) + minibuffer-completion-table + minibuffer-completion-predicate + (substring contents pt)))) + (concat (substring contents 0 (car bounds)) + cand + (substring contents (+ pt (cdr bounds))))) + ;; not in a minibuffer, trust that cand already conveys all + ;; necessary information (there's not much else we can do) + cand)) (defun marginalia-annotate-file (cand) "Annotate file CAND with its size and modification time."