[PATCH v2 8/9] emacs: Define a common shared keymap for all of notmuch

Austin Clements amdragon at MIT.EDU
Tue Sep 3 14:45:24 PDT 2013


This defines a single, currently empty keymap that all other notmuch
mode maps inherit from.
---
 emacs/notmuch-hello.el |   10 ++++++++--
 emacs/notmuch-lib.el   |    5 +++++
 emacs/notmuch-show.el  |    1 +
 emacs/notmuch.el       |    1 +
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6a7b884..46baf55 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -515,8 +515,14 @@ Such a list can be computed with `notmuch-hello-query-counts'."
 
 
 (defvar notmuch-hello-mode-map
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map widget-keymap)
+  (let ((map (if (fboundp 'make-composed-keymap)
+		 ;; Inherit both widget-keymap and notmuch-common-keymap
+		 (make-composed-keymap widget-keymap)
+	       ;; Before Emacs 24, keymaps didn't support multiple
+	       ;; inheritance,, so just copy the widget keymap since
+	       ;; it's unlikely to change.
+	       (copy-keymap widget-keymap))))
+    (set-keymap-parent map notmuch-common-keymap)
     (define-key map "v" (lambda () "Display the notmuch version" (interactive)
 			  (message "notmuch version %s" (notmuch-version))))
     (define-key map "?" 'notmuch-help)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 782badb..2bf1d2f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -128,6 +128,11 @@ For example, if you wanted to remove an \"inbox\" tag and add an
   :group 'notmuch-search
   :group 'notmuch-show)
 
+(defvar notmuch-common-keymap
+  (let ((map (make-sparse-keymap)))
+    map)
+  "Keymap shared by all notmuch modes.")
+
 ;; By default clicking on a button does not select the window
 ;; containing the button (as opposed to clicking on a widget which
 ;; does). This means that the button action is then executed in the
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 380df66..9f67340 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1264,6 +1264,7 @@ reset based on the original query."
 
 (defvar notmuch-show-mode-map
       (let ((map (make-sparse-keymap)))
+	(set-keymap-parent map notmuch-common-keymap)
 	(define-key map "?" 'notmuch-help)
 	(define-key map "q" 'notmuch-kill-this-buffer)
 	(define-key map (kbd "<C-tab>") 'widget-backward)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0304096..e098bd7 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -198,6 +198,7 @@ first line of documentation for the bound function."
 
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map notmuch-common-keymap)
     (define-key map "?" 'notmuch-help)
     (define-key map "q" 'notmuch-kill-this-buffer)
     (define-key map "x" 'notmuch-kill-this-buffer)
-- 
1.7.10.4



More information about the notmuch mailing list