[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia 659a550 081/241: show annotations even if no
From: |
Stefan Monnier |
Subject: |
[elpa] externals/marginalia 659a550 081/241: show annotations even if no documentation is present |
Date: |
Fri, 28 May 2021 20:49:01 -0400 (EDT) |
branch: externals/marginalia
commit 659a550e1cad23bfc01a0025af8a39ac57a419e2
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
show annotations even if no documentation is present
---
marginalia.el | 66 +++++++++++++++++++++++++++++++----------------------------
1 file changed, 35 insertions(+), 31 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index 73687cf..5e75b8d 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -258,7 +258,9 @@ FACE is the name of the face, with which the field should
be propertized.
WIDTH is the format width. This can be specified as alternative to FORMAT."
(cl-assert (not (and width format)))
(when width (setq format (format "%%%ds" (- width))))
- (when format (setq field `(format ,format ,field)))
+ (if format
+ (setq field `(format ,format ,field))
+ (setq field `(or ,field "")))
(when truncate (setq field `(marginalia--truncate ,field ,truncate)))
(when face (setq field `(propertize ,field 'face ,face)))
field)
@@ -291,7 +293,8 @@ This hash table is needed to speed up
`marginalia-annotate-command-binding'.")
(cl-do-all-symbols (sym)
(when-let (key (and (commandp sym) (where-is-internal sym nil t)))
(puthash sym key marginalia-annotate-command-binding--hash))))
- (when-let (binding (gethash (intern cand)
marginalia-annotate-command-binding--hash))
+ (when-let* ((sym (intern-soft cand))
+ (binding (gethash sym
marginalia-annotate-command-binding--hash)))
(propertize (format " (%s)" (key-description binding)) 'face
'marginalia-key))))
(defun marginalia-annotate-command-full (cand)
@@ -332,19 +335,20 @@ This hash table is needed to speed up
`marginalia-annotate-command-binding'.")
(defun marginalia-annotate-symbol (cand)
"Annotate symbol CAND with its documentation string."
- (when-let* ((sym (intern-soft cand))
- (doc (cond
+ (when-let (sym (intern-soft cand))
+ (let ((doc (or (cond
((fboundp sym) (ignore-errors (documentation sym)))
((facep sym) (documentation-property sym
'face-documentation))
- (t (documentation-property sym 'variable-documentation)))))
- (marginalia--fields
- ((if (and (fboundp sym) (string-match-p marginalia--advice-regexp doc))
- "*" " ")
- :face 'marginalia-modified)
- ((if (fboundp sym)
- (replace-regexp-in-string marginalia--advice-regexp "" doc)
- doc)
- :truncate marginalia-truncate-width :face 'marginalia-documentation))))
+ (t (documentation-property sym 'variable-documentation)))
+ "")))
+ (marginalia--fields
+ ((if (and (fboundp sym) (string-match-p marginalia--advice-regexp doc))
+ "*" " ")
+ :face 'marginalia-modified)
+ ((if (fboundp sym)
+ (replace-regexp-in-string marginalia--advice-regexp "" doc)
+ doc)
+ :truncate marginalia-truncate-width :face
'marginalia-documentation)))))
(defun marginalia-annotate-imenu (cand)
"Annotate imenu CAND with its documentation string."
@@ -355,23 +359,23 @@ This hash table is needed to speed up
`marginalia-annotate-command-binding'.")
(defun marginalia-annotate-variable (cand)
"Annotate variable CAND with its documentation string."
- (let ((sym (intern cand)))
- (when-let (doc (documentation-property sym 'variable-documentation))
- (marginalia--fields
- ((if (and (boundp sym) (not (equal (symbol-value sym) (default-value
sym))))
- "*" " ")
- :face 'marginalia-modified)
- ((if (boundp sym) (symbol-value sym) 'unbound)
- :truncate (/ marginalia-truncate-width 3) :format "%S" :face
'marginalia-variable)
- (doc :truncate marginalia-truncate-width :face
'marginalia-documentation)))))
+ (when-let (sym (intern-soft cand))
+ (marginalia--fields
+ ((if (and (boundp sym) (not (equal (symbol-value sym) (default-value
sym))))
+ "*" " ")
+ :face 'marginalia-modified)
+ ((if (boundp sym) (symbol-value sym) 'unbound)
+ :truncate (/ marginalia-truncate-width 3) :format "%S" :face
'marginalia-variable)
+ ((documentation-property sym 'variable-documentation)
+ :truncate marginalia-truncate-width :face 'marginalia-documentation))))
(defun marginalia-annotate-face (cand)
"Annotate face CAND with documentation string and face example."
- (let ((sym (intern cand)))
- (when-let (doc (documentation-property sym 'face-documentation))
- (marginalia--fields
- ("abcdefghijklmNOPQRSTUVWXYZ" :face sym)
- (doc :truncate marginalia-truncate-width :face
'marginalia-documentation)))))
+ (when-let (sym (intern-soft cand))
+ (marginalia--fields
+ ("abcdefghijklmNOPQRSTUVWXYZ" :face sym)
+ ((documentation-property sym 'face-documentation)
+ :truncate marginalia-truncate-width :face 'marginalia-documentation))))
(defun marginalia-annotate-minor-mode (cand)
"Annotate minor-mode CAND with status and documentation string."
@@ -388,8 +392,8 @@ This hash table is needed to speed up
`marginalia-annotate-command-binding'.")
((if (and (boundp mode) (symbol-value mode))
(propertize "On" 'face 'marginalia-on)
(propertize "Off" 'face 'marginalia-off)) :width 3)
- ((or lighter-str "") :width 14 :face 'marginalia-lighter)
- ((or (ignore-errors (documentation mode)) "")
+ (lighter-str :width 14 :face 'marginalia-lighter)
+ ((ignore-errors (documentation mode))
:truncate marginalia-truncate-width
:face 'marginalia-documentation)))))
@@ -434,8 +438,8 @@ This hash table is needed to speed up
`marginalia-annotate-command-binding'.")
(if (buffer-local-value 'buffer-read-only buffer) "%" " "))
:face 'marginalia-modified)
((buffer-local-value 'major-mode buffer) :width 30 :face 'marginalia-mode)
- ((if-let (file (buffer-file-name buffer))
- (abbreviate-file-name file) "")
+ ((when-let (file (buffer-file-name buffer))
+ (abbreviate-file-name file))
:truncate (/ marginalia-truncate-width 2)
:face 'marginalia-file-name))))
- [elpa] externals/marginalia 445d283 234/241: README: Update helper commands (Use remq instead of delq), (continued)
- [elpa] externals/marginalia 445d283 234/241: README: Update helper commands (Use remq instead of delq), Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia a0e9903 237/241: Remove marginalia--annotate-binding-hash (See #16), Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia bc8e5f2 178/241: customize group: more restrictive prompt classifier, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 6caf9f0 202/241: Add link to readme (Fix #66), Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 5ce5a0e 200/241: marginalia-annotate-color: Add component letters, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 668265a 211/241: Simplify setup, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 9ca180b 026/241: richer formatting of file and buffer annotations, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2805127 058/241: introduce a small dsl marginalia--fields which helps with formatting, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 31ba78b 072/241: add marginalia-annotate-coding-system, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 783cb49 067/241: improve marginalia-minor-mode, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 659a550 081/241: show annotations even if no documentation is present,
Stefan Monnier <=
- [elpa] externals/marginalia 56ad689 094/241: modify marginalia-annotate-imenu regexp such that it works with consult narrowing, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia ac53a00 097/241: optimize marginalia--truncate, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 7743fd7 109/241: add marginalia-annotate-char, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 78f676e 122/241: marginalia-annotate-package: use package-desc-status, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 0c5521a 126/241: fix window context for Embark Occur, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia b75f43e 128/241: fix #34, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia e132638 134/241: marginalia-annotate-buffer: show remote indicator, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 4d4f639 140/241: fix project file/buffer annotations for consult-buffer, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 5a644d8 143/241: abbreviate list-buffers-directory, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2a9df61 145/241: readme fixes, Stefan Monnier, 2021/05/28