[PATCH] emacs: add some convenience functions to show mode

Jameson Rollins jrollins at finestructure.net
Sun Nov 14 14:09:01 PST 2010


Adding three new conveneince functions:

notmuch-show-next-open-message-or-pop
notmuch-show-next-thread
notmuch-show-previous-thread

While these are not currently bound to any keys, I have found them to
be very useful for constructing custom key bindings outside of what
notmuch provides by default.  For example:

(define-key notmuch-show-mode-map "a"
  (lambda ()
    "archive current message and advance"
    (interactive)
    (notmuch-show-remove-tag "inbox")
    (notmuch-show-next-open-message-or-pop)))
(define-key notmuch-show-mode-map "N" 'notmuch-show-next-thread)
(define-key notmuch-show-mode-map "P" 'notmuch-show-previous-thread)
---
 emacs/notmuch-show.el |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index b89b685..820fd0e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -920,6 +920,45 @@ any effects from previous calls to
   (notmuch-show-mark-read)
   (notmuch-show-message-adjust))
 
+(defun notmuch-show-next-open-message-or-pop ()
+  "Show the next message or pop out if none remain."
+  (interactive)
+  (let (r)
+    (while (and (setq r (notmuch-show-goto-message-next))
+		(not (notmuch-show-message-visible-p))))
+    (if r
+	(progn
+	  (notmuch-show-mark-read)
+	  (notmuch-show-message-adjust))
+      (let ((parent-buffer notmuch-show-parent-buffer))
+	(if parent-buffer
+	    (progn
+	      (kill-this-buffer)
+	      (switch-to-buffer parent-buffer)
+	      (forward-line 1)))))))
+
+(defun notmuch-show-next-thread ()
+  "Move to the next thread from the last search."
+  (interactive)
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (if parent-buffer
+      (progn
+        (kill-this-buffer)
+        (switch-to-buffer parent-buffer)
+        (forward-line 1)
+        (notmuch-search-show-thread)))))
+
+(defun notmuch-show-previous-thread ()
+  "Move to the previous thread from the last search."
+  (interactive)
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (if parent-buffer
+      (progn
+        (kill-this-buffer)
+        (switch-to-buffer parent-buffer)
+        (forward-line -1)
+        (notmuch-search-show-thread)))))
+
 (defun notmuch-show-view-raw-message ()
   "View the file holding the current message."
   (interactive)
-- 
1.7.2.3



More information about the notmuch mailing list