branch: externals/marginalia commit 7fe1a031735be6a4d6ed97601b857b29a7264c30 Author: Omar Antolín <omar.anto...@gmail.com> Commit: Omar Antolín <omar.anto...@gmail.com>
Fix retrieving full paths under Selectrum This fix uses Selectrum's selectrum--get-full function. Ideally we would not depend on this, but it seems tricky to do otherwise. Selectrum has its own `selectrum-read-file-name` and its own handling of partial-completion style paths (~/u/s/d/w => ~/usr/sahre/dict/words). I think we may not be able to find a definition of marginalia--full-candidate that works under both default completion and Selectrum, but would be very happy to be proven wrong about that. --- marginalia.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/marginalia.el b/marginalia.el index f4419a5..aac036c 100644 --- a/marginalia.el +++ b/marginalia.el @@ -638,20 +638,24 @@ The string is transformed according to `marginalia-bookmark-type-transformers'." :truncate (/ marginalia-truncate-width 2) :face 'marginalia-file-name)))) +(declare-function 'selectrum--get-full "ext:selectrum") + (defun marginalia--full-candidate (cand) "Return completion candidate CAND in full. For some completion tables, the completion candidates offered are meant to be only a part of the full minibuffer contents. For example, during file name completion the candidates are one path component of a full file path." - (if-let (win (active-minibuffer-window)) - (with-current-buffer (window-buffer win) - (concat (substring (minibuffer-contents-no-properties) - 0 marginalia--base-position) - cand)) - ;; no minibuffer is active, trust that cand already conveys all - ;; necessary information (there's not much else we can do) - cand)) + (if-let (win (active-minibuffer-window)) + (with-current-buffer (window-buffer win) + (if (bound-and-true-p selectrum-is-active) + (selectrum--get-full cand) + (concat (substring (minibuffer-contents-no-properties) + 0 marginalia--base-position) + cand))) + ;; no minibuffer is active, trust that cand already conveys all + ;; necessary information (there's not much else we can do) + cand)) (defun marginalia--remote-p (path) "Return t if PATH is a remote path."