[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia 33e86dc: Add highlighting to variable view a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/marginalia 33e86dc: Add highlighting to variable view and improve perf |
Date: |
Mon, 26 Jul 2021 03:57:14 -0400 (EDT) |
branch: externals/marginalia
commit 33e86dc5812e0313926af97b589ca3b464673a8b
Author: TEC <tec@tecosaur.com>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add highlighting to variable view and improve perf
Use type predicates to select an appropriate face for viewing values,
and use type information to also use quicker type-to-string conversion
when possible.
---
marginalia.el | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index 127590a..0963af9 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -490,16 +490,38 @@ keybinding since CAND includes it."
(marginalia--fields
((marginalia--symbol-class sym) :face 'marginalia-type)
((cond
- ((not (boundp sym)) "<unbound>")
- ((seq-find (lambda (r) (string-match-p r cand))
marginalia-censor-variables) "*****")
- (t (let ((val (symbol-value sym))
- (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))))
- :truncate (/ marginalia-truncate-width 2) :face 'marginalia-variable)
+ ((not (boundp sym))
+ (propertize "<unbound>" 'face 'marginalia-variable))
+ ((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)))))
+ :truncate (/ marginalia-truncate-width 2))
((documentation-property sym 'variable-documentation)
:truncate marginalia-truncate-width :face 'marginalia-documentation))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/marginalia 33e86dc: Add highlighting to variable view and improve perf,
ELPA Syncer <=