[PATCH 3/4] emacs: help: remap support
Mark Walters
markwalters1009 at gmail.com
Sat Oct 26 14:04:38 PDT 2013
If a user or mode uses remap to rebind a keybinding then it appears in
the help as a line <remap><function> New function docstring. Special
case these remapping lines so that we print the actual binding.
---
emacs/notmuch.el | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index b9db9ba..c354b05 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -140,7 +140,7 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."
"M-"
(concat desc " "))))
-(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail)
+(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail remap)
"Return a list of cons cells, each describing one binding in KEYMAP.
Each cons cell consists of a string giving a human-readable
@@ -150,16 +150,23 @@ documentation is extracted.
UA-KEYS should be a key sequence bound to `universal-argument'.
It will be used to describe bindings of commands that support a
-prefix argument. PREFIX and TAIL are used internally."
+prefix argument. PREFIX, TAIL and REMAP are used internally."
(map-keymap
(lambda (key binding)
(cond ((mouse-event-p key) nil)
((keymapp binding)
- (setq tail
- (notmuch-describe-keymap
- binding ua-keys (notmuch-prefix-key-description key) tail)))
+ (if (equal key 'remap)
+ (setq tail
+ (notmuch-describe-keymap
+ binding ua-keys prefix tail t))
+ (setq tail
+ (notmuch-describe-keymap
+ binding ua-keys (notmuch-prefix-key-description key) tail))))
(t
- (let ((key-string (concat prefix (format-kbd-macro (vector key)))))
+ (let* ((actual-key (if remap
+ (where-is-internal key nil t)
+ (vector key)))
+ (key-string (concat prefix (format-kbd-macro actual-key))))
;; We don't include documentation if the key-binding is
;; over-ridden. Note, over-riding a binding
;; automatically hides the prefixed version too.
@@ -168,7 +175,7 @@ prefix argument. PREFIX and TAIL are used internally."
(get binding 'notmuch-prefix-doc))
;; Documentation for prefixed command
(let ((ua-desc (key-description ua-keys)))
- (push (cons (concat ua-desc " " prefix (format-kbd-macro (vector key)))
+ (push (cons (concat ua-desc " " prefix (format-kbd-macro actual-key))
(get binding 'notmuch-prefix-doc))
tail)))
;; Documentation for command
--
1.7.9.1
More information about the notmuch
mailing list