mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
notmuch.el: Fix notmuch-help to properly display prefixed bindings.
Previously, we would do only a single-level traverse of the keymap. That meant that for a keybinding such as "M-TAB" we would just see the prefix key ("ESC") and print that it was a keymap---never printing the TAB nor the documentation for the command it is bound to. Now, we do the full walk, constructing a proper description of the full keybdinding with prefix characters, (and converting "ESC" to "M-" for legibility).
This commit is contained in:
parent
335a8aec2b
commit
f5e125a9c0
1 changed files with 28 additions and 7 deletions
33
notmuch.el
33
notmuch.el
|
@ -787,17 +787,38 @@ which this thread was originally shown."
|
||||||
(buffer-substring beg (point))))
|
(buffer-substring beg (point))))
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
(defun notmuch-substitute-one-command-key (binding)
|
(defun notmuch-prefix-key-description (key)
|
||||||
"For a key binding, return a string showing a human-readable representation
|
"Given a prefix key code, return a human-readable string representation.
|
||||||
of the key as well as the first line of documentation from the bound function.
|
|
||||||
|
This is basically just `format-kbd-macro' but we also convert ESC to M-."
|
||||||
|
(let ((desc (format-kbd-macro (vector key))))
|
||||||
|
(if (string= desc "ESC")
|
||||||
|
"M-"
|
||||||
|
(concat desc " "))))
|
||||||
|
|
||||||
|
; I would think that emacs would have code handy for walking a keymap
|
||||||
|
; and generating strings for each key, and I would prefer to just call
|
||||||
|
; that. But I couldn't find any (could be all implemented in C I
|
||||||
|
; suppose), so I wrote my own here.
|
||||||
|
(defun notmuch-substitute-one-command-key-with-prefix (prefix binding)
|
||||||
|
"For a key binding, return a string showing a human-readable
|
||||||
|
representation of the prefixed key as well as the first line of
|
||||||
|
documentation from the bound function.
|
||||||
|
|
||||||
For a mouse binding, return nil."
|
For a mouse binding, return nil."
|
||||||
(let ((key (car binding)))
|
(let ((key (car binding))
|
||||||
|
(action (cdr binding)))
|
||||||
(if (mouse-event-p key)
|
(if (mouse-event-p key)
|
||||||
nil
|
nil
|
||||||
(concat (format-kbd-macro (vector key))
|
(if (keymapp action)
|
||||||
|
(let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key))))
|
||||||
|
(mapconcat substitute (cdr action) "\n"))
|
||||||
|
(concat prefix (format-kbd-macro (vector key))
|
||||||
"\t"
|
"\t"
|
||||||
(notmuch-documentation-first-line (cdr binding))))))
|
(notmuch-documentation-first-line action))))))
|
||||||
|
|
||||||
|
(defalias 'notmuch-substitute-one-command-key
|
||||||
|
(apply-partially 'notmuch-substitute-one-command-key-with-prefix nil))
|
||||||
|
|
||||||
(defun notmuch-substitute-command-keys (doc)
|
(defun notmuch-substitute-command-keys (doc)
|
||||||
"Like `substitute-command-keys' but with documentation, not function names."
|
"Like `substitute-command-keys' but with documentation, not function names."
|
||||||
|
|
Loading…
Reference in a new issue