branch: externals/marginalia
commit dca1cb5d413ed7bd4ac058d38e64fd193fa7c827
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
marginalia--base-position: Minor changes
- Use defvar-local+setq instead of defvar+setq-local. This leads to better
code
being generated. I also consider it better style since it is guaranteed
that
the variable access is always local.
- Set base position to 0 by default
- Only acquire the base position for files for now
---
marginalia.el | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index f4419a5..56cd04a 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -272,10 +272,10 @@ determine it."
(defvar marginalia--margin nil
"Right margin.")
-(defvar marginalia--this-command nil
+(defvar-local marginalia--this-command nil
"Last command symbol saved in order to allow annotations.")
-(defvar marginalia--base-position nil
+(defvar-local marginalia--base-position 0
"Last completion base position saved to get full file paths.")
(defvar marginalia--metadata nil
@@ -768,11 +768,14 @@ PROP is the property which is looked up."
(defun marginalia--minibuffer-setup ()
"Setup minibuffer for `marginalia-mode'.
Remember `this-command' for `marginalia-classify-by-command-name'."
- (setq-local marginalia--this-command this-command))
+ (setq marginalia--this-command this-command))
(defun marginalia--base-position (completions)
- "Record the completion base position."
- (setq-local marginalia--base-position (cdr (last completions)))
+ "Record the base position of COMPLETIONS."
+ ;; NOTE: As a small optimization track the base position only for file
completions,
+ ;; since `marginalia--full-candidate' is only used for files as of now.
+ (when minibuffer-completing-file-name
+ (setq marginalia--base-position (cdr (last completions))))
completions)
;;;###autoload