[PATCH] emacs: hello: fix accidental modification of widget-keymap

Mark Walters markwalters1009 at gmail.com
Thu Nov 12 03:02:19 PST 2015


In emacs24 we use make-composed-keymap. It seems that if only a single
map is specified then emacs just resuses it rather than creating a
copy of it. Thus use make-sparse-keymap to force a copy.
---

pseudomyne and the diredful author thamer found that we modify
widget-keymap in notmuch. We clearly don't want to, and I think we
tried not to, but emacs was being clever and reused the old keymap
rather than creating a new one.

Anyway the following patch seems to work, and if the user modifies
widget-keymap deliberately then it does get inherited by notmuch-hello
(which was the point of make-composed-keymap rather than just
copy-keymap in the first place).

The bug only occurs in emacs24. I essentially only use emacs23 so it
has not been tested much.

Best wishes

Mark




 emacs/notmuch-hello.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 8bde808..b42e0f2 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -652,8 +652,12 @@ with `notmuch-hello-query-counts'."
 
 (defvar notmuch-hello-mode-map
   (let ((map (if (fboundp 'make-composed-keymap)
-		 ;; Inherit both widget-keymap and notmuch-common-keymap
-		 (make-composed-keymap widget-keymap)
+		 ;; Inherit both widget-keymap and
+		 ;; notmuch-common-keymap. We have to use
+		 ;; make-sparse-keymap to force this to be a new
+		 ;; keymap (so that when we modify map it does not
+		 ;; modify widget-keymap).
+		 (make-composed-keymap (list (make-sparse-keymap) widget-keymap))
 	       ;; Before Emacs 24, keymaps didn't support multiple
 	       ;; inheritance,, so just copy the widget keymap since
 	       ;; it's unlikely to change.
-- 
2.1.4



More information about the notmuch mailing list