[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia f16d26a 082/241: marginalia-annotate-symbol:
From: |
Stefan Monnier |
Subject: |
[elpa] externals/marginalia f16d26a 082/241: marginalia-annotate-symbol: add keybindings to commands |
Date: |
Fri, 28 May 2021 20:49:01 -0400 (EDT) |
branch: externals/marginalia
commit f16d26a17bb93684dd0f099db6dc0400a743dcc3
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
marginalia-annotate-symbol: add keybindings to commands
---
marginalia.el | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index 5e75b8d..48c2a8c 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -143,7 +143,7 @@ only with the annotations that come with Emacs) without
disabling
:group 'marginalia)
(defcustom marginalia-annotators-light
- '((command . marginalia-annotate-command-binding)
+ '((command . marginalia-annotate-command)
(customize-group . marginalia-annotate-customize-group)
(variable . marginalia-annotate-variable)
(face . marginalia-annotate-face)
@@ -169,7 +169,7 @@ See also `marginalia-annotators-heavy'."
'((file . marginalia-annotate-file)
(buffer . marginalia-annotate-buffer)
(virtual-buffer . marginalia-annotate-virtual-buffer-full)
- (command . marginalia-annotate-command-full))
+ (command . marginalia-annotate-symbol))
marginalia-annotators-light)
"Heavy annotator functions.
@@ -277,32 +277,26 @@ WIDTH is the format width. This can be specified as
alternative to FORMAT."
(marginalia--fields
(str :truncate marginalia-truncate-width :face
'marginalia-documentation))))
-(defvar-local marginalia-annotate-command-binding--hash nil
+(defvar-local marginalia-annotate-command--hash nil
"Hash table storing the keybinding of every command.
-This hash table is needed to speed up `marginalia-annotate-command-binding'.")
+This hash table is needed to speed up `marginalia-annotate-command'.")
-(defun marginalia-annotate-command-binding (cand)
+(defun marginalia-annotate-command (cand)
"Annotate command CAND with keybinding."
(with-current-buffer (window-buffer (minibuffer-selected-window))
;; Precomputing the keybinding of every command is faster than looking it
up every time using
;; `where-is-internal'. `where-is-internal' generates a lot of garbage,
leading to garbage
;; collecting pauses when interacting with the minibuffer. See
;; https://github.com/minad/marginalia/issues/16.
- (unless marginalia-annotate-command-binding--hash
- (setq marginalia-annotate-command-binding--hash (make-hash-table))
+ (unless marginalia-annotate-command--hash
+ (setq marginalia-annotate-command--hash (make-hash-table))
(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))))
+ (puthash sym key marginalia-annotate-command--hash))))
(when-let* ((sym (intern-soft cand))
- (binding (gethash sym
marginalia-annotate-command-binding--hash)))
+ (binding (gethash sym marginalia-annotate-command--hash)))
(propertize (format " (%s)" (key-description binding)) 'face
'marginalia-key))))
-(defun marginalia-annotate-command-full (cand)
- "Annotate command CAND with the keybinding and its documentation string."
- (concat
- (marginalia-annotate-command-binding cand)
- (marginalia-annotate-symbol cand)))
-
;; This annotator is consult-specific, it will annotate the `consult-buffer'
command.
(defun marginalia-annotate-virtual-buffer-class (cand)
"Annotate virtual-buffer CAND with the buffer class."
@@ -341,14 +335,16 @@ This hash table is needed to speed up
`marginalia-annotate-command-binding'.")
((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)))))
+ (concat
+ (marginalia-annotate-command cand)
+ (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."
- [elpa] externals/marginalia 78023eb 038/241: update readme, (continued)
- [elpa] externals/marginalia 78023eb 038/241: update readme, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia b6d2e22 037/241: fix typo, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 472b47a 041/241: add comment to marginalia-toggle-annotators, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 85a2693 053/241: marginalia-annotate-package: show package archive, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia dfbaa7f 061/241: marginalia-annotate-package: show installed status instead of archive, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 17d539c 059/241: whitespace and comment adjustments, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 4a5ada6 063/241: smaller variable field, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2f1bb7c 064/241: do not overwrite the face weights as per recommendation by @purcell, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 785297d 075/241: Indicate advised functions with an asterisk, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 0bd8061 077/241: marginalia--fields: allow alignment to the right by using a negative width, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia f16d26a 082/241: marginalia-annotate-symbol: add keybindings to commands,
Stefan Monnier <=
- [elpa] externals/marginalia b0c24f7 088/241: introduce marginalia-annotate-command, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia bbde111 083/241: Annotate environment variables with their value, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 618fd9e 084/241: Improve formatting of environment variable annotation, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 3559cbb 095/241: update readme, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 27cd29d 101/241: add buffer size annotation, fix #29, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 3360875 113/241: Rename marginalia-cycle-annotators to marginalia-cycle, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 1fb2569 121/241: marginalia-annotate-minor-mode: fix support for consult, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 35cb523 127/241: add comment, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia d38a278 151/241: readme: do not export drawers, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 3febe72 155/241: fix #45, Stefan Monnier, 2021/05/28