[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia 444c5d1 1/2: marginalia-annotate-variable: M
From: |
ELPA Syncer |
Subject: |
[elpa] externals/marginalia 444c5d1 1/2: marginalia-annotate-variable: Minor stylistic changes, pcase |
Date: |
Mon, 26 Jul 2021 04:57:14 -0400 (EDT) |
branch: externals/marginalia
commit 444c5d10b24a06bba048fc49c9709270edcd38df
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
marginalia-annotate-variable: Minor stylistic changes, pcase
---
marginalia.el | 55 +++++++++++++++++++++++++++++--------------------------
1 file changed, 29 insertions(+), 26 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index 0963af9..f9524aa 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -495,32 +495,35 @@ keybinding since CAND includes it."
((and marginalia-censor-variables
(seq-find (lambda (r) (string-match-p r cand))
marginalia-censor-variables))
"*****")
- (t (let* ((val (symbol-value sym))
- (type-repr
- (cond
- ((null val) '(font-lock-comment-face . "nil"))
- ((eq t val) '(font-lock-builtin-face . "t"))
- ((numberp val)
- (cons 'font-lock-variable-name-face (number-to-string
val)))
- ((stringp val)
- (cons 'font-lock-string-face
- (concat "\"" (replace-regexp-in-string "\n" "\\\\n"
val) "\"")))
- ((functionp val)
- (cons 'font-lock-function-name-face (symbol-name sym)))
- ((symbolp val)
- (cons 'font-lock-type-face (symbol-name sym)))
- ((keymapp val)
- '(marginalia-variable . "<keymap>"))
- (t (cons (if (listp val)
- 'font-lock-constant-face
- 'marginalia-variable)
- (let ((print-escape-newlines t)
- (print-escape-control-characters t)
- (print-escape-multibyte t)
- (print-level 10)
- (print-length marginalia-truncate-width))
- (prin1-to-string val)))))))
- (propertize (cdr type-repr) 'face (car type-repr)))))
+ (t (pcase (symbol-value sym)
+ ('nil (propertize "nil" 'face 'font-lock-comment-face))
+ ('t (propertize "t" 'face 'font-lock-builtin-face))
+ ((and (pred numberp) val)
+ (propertize (number-to-string val) 'face
'font-lock-variable-name-face))
+ ((pred functionp)
+ (propertize (symbol-name sym) 'face
'font-lock-function-name-face))
+ ((pred symbolp)
+ (propertize (symbol-name sym) 'face 'font-lock-type-face))
+ ((pred keymapp)
+ (propertize "<keymap>" 'face 'marginalia-variable))
+ (val (let ((print-escape-newlines t)
+ (print-escape-control-characters t)
+ (print-escape-multibyte t)
+ (print-level 10)
+ (print-length marginalia-truncate-width))
+ (propertize
+ (prin1-to-string
+ (if (stringp val)
+ ;; Get rid of string properties to save some of the
precious space
+ (substring-no-properties
+ val 0
+ (min (length val) marginalia-truncate-width))
+ val))
+ 'face
+ (cond
+ ((listp val) 'font-lock-constant-face)
+ ((stringp val) 'font-lock-string-face)
+ (t 'marginalia-variable))))))))
:truncate (/ marginalia-truncate-width 2))
((documentation-property sym 'variable-documentation)
:truncate marginalia-truncate-width :face 'marginalia-documentation))))