branch: externals/marginalia
commit 531fb6e9a5070b9a94f80f19f7b0329c8b243d47
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
fix #27
---
marginalia.el | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index 552c5c5..c0fa896 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -39,13 +39,20 @@
:group 'convenience
:prefix "marginalia-")
-
(defcustom marginalia-truncate-width 80
"Maximum truncation width of annotation fields.
This value is adjusted in the `minibuffer-setup-hook' depending on the
`window-width'."
:type 'integer)
+(defcustom marginalia-separator-threshold 120
+ "Use wider separator for window widths larger than this value."
+ :type 'integer)
+
+(defcustom marginalia-margin-threshold 160
+ "Use whitespace margin for window widths larger than this value."
+ :type 'integer)
+
(defcustom marginalia-annotators
'(marginalia-annotators-light marginalia-annotators-heavy)
"Choose an annotator association list for minibuffer completion.
@@ -219,6 +226,9 @@ determine it."
(defvar marginalia--separator " "
"Field separator.")
+(defvar marginalia--margin nil
+ "Right margin.")
+
(defvar marginalia--this-command nil
"Last command symbol saved in order to allow annotations.")
@@ -236,6 +246,8 @@ determine it."
(defsubst marginalia--align (str)
"Align STR at the right margin."
(unless (string-blank-p str)
+ (when marginalia--margin
+ (setq str (concat str marginalia--margin)))
(concat " "
(propertize
" "
@@ -606,7 +618,9 @@ PROP is the property which is looked up."
Remember `this-command' for annotation."
(let ((w (window-width)))
(setq-local marginalia-truncate-width (min (/ w 2)
marginalia-truncate-width))
- (setq-local marginalia--separator (if (> w 100) " " " "))
+ (setq-local marginalia--separator (if (> w marginalia-separator-threshold)
" " " "))
+ (setq-local marginalia--margin (when (> w marginalia-margin-threshold)
+ (make-string (- w
marginalia-margin-threshold) 32)))
(setq-local marginalia--this-command this-command)))
;;;###autoload