[PATCH] Make notmuch-hello a mode.

Sebastian Spaeth Sebastian at SSpaeth.de
Mon May 3 02:45:00 PDT 2010


This enables the nifty '?' key binding to work in notmuch-hello
(although for some strange reasons I don't see any descriptions for
specific key bindings yet. Not sure how that is supposed to work
though.
But this starts, runs and behaves identical to the existing code.

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
I am not sure this is ready to be commited as is. But it enables the 
'?' key binding and behaves as previously. Perhaps there can be made
some further tweaks as to where to set the buffer read-only now and stuff.

Is this something we could build on? I really enjoy my '?' keybinding.

 emacs/notmuch-hello.el |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6a1c56e..5746fd2 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -213,6 +213,31 @@ diagonal."
   (notmuch-poll)
   (notmuch-hello-update))
 
+
+(defvar notmuch-hello-mode-map
+  (let ((map (copy-keymap widget-keymap)))
+    (define-key map "?" 'notmuch-help)
+    (define-key map "=" 'notmuch-hello-update)
+    (define-key map "G" 'notmuch-hello-poll-and-update)
+    (define-key map "m" 'notmuch-mua-mail)
+    (define-key map "q" 'kill-this-buffer)
+    (define-key map "s" 'notmuch-hello-goto-search)
+    (define-key map "v" '(lambda () (interactive)
+                           (message "notmuch version %s" (notmuch-version))))
+    map)
+  "Keymap for \"notmuch hello\" buffers.")
+(fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
+
+(defun notmuch-hello-mode ()
+ "Major mode for conventient notmuch navigation"
+ (interactive)
+ (kill-all-local-variables)
+ (use-local-map notmuch-hello-mode-map)
+ (setq major-mode 'notmuch-hello-mode
+       mode-name "notmuch-hello")
+ ;;(setq buffer-read-only t)
+)
+
 (defun notmuch-hello (&optional no-display)
   (interactive)
 
@@ -237,6 +262,9 @@ diagonal."
     (let ((inhibit-read-only t))
       (erase-buffer))
 
+    (unless (eq major-mode 'notmuch-hello-mode)
+      (notmuch-hello-mode))
+
     (let ((all (overlay-lists)))
       ;; Delete all the overlays.
       (mapc 'delete-overlay (car all))
@@ -397,15 +425,6 @@ diagonal."
 	(let ((fill-column (- (window-width) notmuch-hello-indent)))
 	  (center-region start (point))))
 
-      (use-local-map widget-keymap)
-      (local-set-key "=" 'notmuch-hello-update)
-      (local-set-key "G" 'notmuch-hello-poll-and-update)
-      (local-set-key "m" 'notmuch-mua-mail)
-      (local-set-key "q" '(lambda () (interactive) (kill-buffer (current-buffer))))
-      (local-set-key "s" 'notmuch-hello-goto-search)
-      (local-set-key "v" '(lambda () (interactive)
-			    (message "notmuch version %s" (notmuch-version))))
-
       (widget-setup)
 
       (goto-char final-target-pos)
-- 
1.7.0.4



More information about the notmuch mailing list