[PATCH 1/1] emacs: don't show duplicate keys in help.

Mark Walters markwalters1009 at gmail.com
Fri Oct 11 06:39:54 PDT 2013


Previously notmuch-help would show two entries for keys in a parent
keymap that were over-ridden in the local keymap.  This keeps track of
which keys have been seen and thus avoids these spurious duplicate
entries.

---
 emacs/notmuch.el |   45 ++++++++++++++++++++++++---------------------
 1 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c47c6b5..4f4e2e7 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -150,27 +150,30 @@ for an overview of how this 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."
-  (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)))
-	   (t
-	    (when (and ua-keys (symbolp binding)
-		       (get binding 'notmuch-prefix-doc))
-	      ;; Documentation for prefixed command
-	      (let ((ua-desc (key-description ua-keys)))
-		(push (concat ua-desc " " prefix (format-kbd-macro (vector key))
-			      "\t" (get binding 'notmuch-prefix-doc))
-		      tail)))
-	    ;; Documentation for command
-	    (push (concat prefix (format-kbd-macro (vector key)) "\t"
-			  (or (and (symbolp binding) (get binding 'notmuch-doc))
-			      (notmuch-documentation-first-line binding)))
-		  tail))))
-   keymap)
+  (let (keys-seen)
+    (map-keymap
+     (lambda (key binding)
+       (unless (memq key keys-seen)
+	 (push key keys-seen)
+	 (cond ((mouse-event-p key) nil)
+	       ((keymapp binding)
+		(setq tail
+		      (notmuch-describe-keymap
+		       binding ua-keys (notmuch-prefix-key-description key) tail)))
+	       (t
+		(when (and ua-keys (symbolp binding)
+			   (get binding 'notmuch-prefix-doc))
+		  ;; Documentation for prefixed command
+		  (let ((ua-desc (key-description ua-keys)))
+		    (push (concat ua-desc " " prefix (format-kbd-macro (vector key))
+				  "\t" (get binding 'notmuch-prefix-doc))
+			  tail)))
+		;; Documentation for command
+		(push (concat prefix (format-kbd-macro (vector key)) "\t"
+			      (or (and (symbolp binding) (get binding 'notmuch-doc))
+				  (notmuch-documentation-first-line binding)))
+		      tail)))))
+     keymap))
   tail)
 
 (defun notmuch-substitute-command-keys (doc)
-- 
1.7.9.1



More information about the notmuch mailing list