unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Make notmuch-hello a mode.
@ 2010-05-03  9:45 Sebastian Spaeth
  2010-05-03 10:29 ` [PATCHv2 1/2] " Sebastian Spaeth
  2010-05-03 10:29 ` [PATCHv2 2/2] add missing docstring for functions Sebastian Spaeth
  0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Spaeth @ 2010-05-03  9:45 UTC (permalink / raw)
  To: Notmuch developer list

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@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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-06-04  0:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-03  9:45 [PATCH] Make notmuch-hello a mode Sebastian Spaeth
2010-05-03 10:29 ` [PATCHv2 1/2] " Sebastian Spaeth
2010-05-14 17:15   ` [PATCH] emacs: notmuch-hello: Make widget-keymap a parent of notmuch-hello-keymap Nelson Elhage
2010-06-04  0:32     ` Carl Worth
2010-06-04  0:36       ` Nelson Elhage
2010-05-03 10:29 ` [PATCHv2 2/2] add missing docstring for functions Sebastian Spaeth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).