[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia 6057427 164/241: autocompute marginalia-alig
From: |
Stefan Monnier |
Subject: |
[elpa] externals/marginalia 6057427 164/241: autocompute marginalia-align-offset if it is not overwritten |
Date: |
Fri, 28 May 2021 20:49:19 -0400 (EDT) |
branch: externals/marginalia
commit 6057427bb59d9ffa7ce38433b91186bf57eb83f0
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
autocompute marginalia-align-offset if it is not overwritten
cc @terlar
---
marginalia.el | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index a2635ac..d99a4ef 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -51,12 +51,12 @@ This value is adjusted in the `minibuffer-setup-hook'
depending on the `window-w
;; See https://github.com/minad/marginalia/issues/42 for the discussion
;; regarding the alignment.
-(defcustom marginalia-align-offset 0
+(defcustom marginalia-align-offset nil
"Additional offset at the right margin used by `marginalia--align'.
-This value should be set to 1 or a larger value if the annotations
-wrap at the right margin."
- :type 'integer)
+This value should be set to nil to enable auto-configuration.
+It can also be set to an integer value of 1 or larger to force an offset."
+ :type '(choice (const nil) integer))
(defcustom marginalia-margin-min 8
"Minimum whitespace margin at the right side."
@@ -650,15 +650,22 @@ looking for a regexp that matches the prompt."
(defmacro marginalia--context (&rest body)
"Setup annotator context around BODY."
- (let ((w (make-symbol "w")))
+ (let ((w (make-symbol "w"))
+ (o (make-symbol "o")))
;; Take the window width of the current window (minibuffer window!)
- `(let ((,w (window-width)))
+ `(let ((,w (window-width))
+ ;; Compute marginalia-align-offset. If the right-fringe-width is
+ ;; zero, use an additional offset of 1 by default! See
+ ;; https://github.com/minad/marginalia/issues/42 for the discussion
+ ;; regarding the alignment.
+ (,o (if (eq 0 (nth 1 (window-fringes))) 1 0)))
;; We generally run the annotators in the original window.
;; `with-selected-window' is necessary because of
`lookup-minor-mode-from-indicator'.
;; Otherwise it would probably 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))
(let ((marginalia-truncate-width (min (/ ,w 2)
marginalia-truncate-width))
+ (marginalia-align-offset (or marginalia-align-offset ,o))
(marginalia--separator (if (>= ,w
marginalia-separator-threshold) " " " "))
(marginalia--margin (when (>= ,w (+ marginalia-margin-min
marginalia-margin-threshold))
(make-string (- ,w
marginalia-margin-threshold) 32))))
- [elpa] externals/marginalia fe5d5db 047/241: add faces: marginalia-file-modes, marginalia-file-owner, (continued)
- [elpa] externals/marginalia fe5d5db 047/241: add faces: marginalia-file-modes, marginalia-file-owner, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2eec2dc 060/241: fix warnings, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia d0afe4a 068/241: add melpa badge, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 7394690 078/241: add marginalia-annotate-virtual-buffer for consult-buffer, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 091895b 092/241: fix #23, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 331b24a 093/241: check default-boundp too, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2864c8e 105/241: fix #31, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 5052240 114/241: annotate-buffer: use mode-name instead of major-mode, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia c1296db 108/241: introduce marginalia-margin-min, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia db18b0e 152/241: Add support for hidden consult buffers, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 6057427 164/241: autocompute marginalia-align-offset if it is not overwritten,
Stefan Monnier <=
- [elpa] externals/marginalia 206518b 163/241: add marginalia-align-offset, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia a5ce6aa 207/241: Work around `completion-boundaries' bug in Emacs 27.1, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia e41d939 206/241: Revert "Go back and use full minibuffer-contents for marginalia--full-file", Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 95c0bb3 205/241: Go back and use full minibuffer-contents for marginalia--full-file, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 0c2735e 214/241: Selectrum advice is unnecessary - post-command-hook performs the update, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 1a100ba 216/241: Add mail address to header, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 470e278 231/241: Restore obsolete variables, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia b6ca937 115/241: shorter mode name, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia cca8f9c 116/241: readme typo, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia d37e9a5 129/241: fix #33, Stefan Monnier, 2021/05/28