aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs
diff options
context:
space:
mode:
authorGravatar Mark Walters <markwalters1009@gmail.com>2013-11-12 20:10:56 +0000
committerGravatar David Bremner <david@tethera.net>2013-11-13 21:46:32 -0400
commit141f3813d81bd1de9218007c77e0be1f75fcee27 (patch)
treef0124d7cce9e9c09685eea825e3920986aac024c /emacs
parent9d0174b11c11ca227b5666e4ce80229220b9f9e2 (diff)
emacs: help: split out notmuch-describe-key as a function
The actual documentation function notmuch-describe-keymap was getting rather complicated so split out the code for a single key into its own function notmuch-describe-key.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/notmuch-lib.el42
1 files changed, 25 insertions, 17 deletions
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0242edb7..065645c8 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -236,6 +236,30 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."
"M-"
(concat desc " "))))
+
+(defun notmuch-describe-key (actual-key binding prefix ua-keys tail)
+ "Prepend cons cells describing prefix-arg ACTUAL-KEY and ACTUAL-KEY to TAIL
+
+It does not prepend if ACTUAL-KEY is already listed in TAIL."
+ (let ((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.
+ (unless (assoc key-string tail)
+ (when (and ua-keys (symbolp binding)
+ (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 actual-key))
+ (get binding 'notmuch-prefix-doc))
+ tail)))
+ ;; Documentation for command
+ (push (cons key-string
+ (or (and (symbolp binding) (get binding 'notmuch-doc))
+ (notmuch-documentation-first-line binding)))
+ tail)))
+ tail)
+
(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail)
"Return a list of cons cells, each describing one binding in KEYMAP.
@@ -255,23 +279,7 @@ prefix argument. PREFIX and TAIL are used internally."
(notmuch-describe-keymap
binding ua-keys (notmuch-prefix-key-description key) tail)))
(binding
- (let ((key-string (concat prefix (format-kbd-macro (vector key)))))
- ;; We don't include documentation if the key-binding is
- ;; over-ridden. Note, over-riding a binding
- ;; automatically hides the prefixed version too.
- (unless (assoc key-string tail)
- (when (and ua-keys (symbolp binding)
- (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)))
- (get binding 'notmuch-prefix-doc))
- tail)))
- ;; Documentation for command
- (push (cons key-string
- (or (and (symbolp binding) (get binding 'notmuch-doc))
- (notmuch-documentation-first-line binding)))
- tail))))))
+ (setq tail (notmuch-describe-key (vector key) binding prefix ua-keys tail)))))
keymap)
tail)