Patchworkβ [1/2] notmuch.el: convert sparse keymap to a list in notmuch-substitute-one-command-key-with-prefix

login
register
about
Submitter David Bremner
Date 2010-02-12 03:01:07
Message ID <1265943668-31531-2-git-send-email-david@tethera.net>
Download mbox | patch
Permalink /patch/360/
State New
Headers show

Comments

David Bremner - 2010-02-12 03:01:07
From: David Bremner <bremner@unb.ca>

The previous version would crash when a key was bound to a sparse
keymap, since apparently these are not straightforward lists.  The
usage of map-keymap is a bit obscure: it only has side-effects, no
return value.
---
 notmuch.el |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/notmuch.el b/notmuch.el
index d2a3b1b..60ef592 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -984,8 +984,12 @@  For a mouse binding, return nil."
     (if (mouse-event-p key)
 	nil
       (if (keymapp action)
-	  (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key))))
-	    (mapconcat substitute (cdr action) "\n"))
+	  (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key)))
+		(as-list))
+	    (map-keymap (lambda (a b)
+			  (push (cons a b) as-list))
+			action)
+	    (mapconcat substitute as-list "\n"))
 	(concat prefix (format-kbd-macro (vector key))
 		"\t"
 		(notmuch-documentation-first-line action))))))