[PATCH] emacs: add show view bindings to move to previous/next thread

Jani Nikula jani at nikula.org
Fri Mar 1 10:03:08 PST 2013


We have most of the plumbing in place, add the bindings M-n and M-p.
---
 emacs/notmuch-show.el |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index acaef8e..4f2e8e0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -40,6 +40,7 @@
 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
 (declare-function notmuch-fontify-headers "notmuch" nil)
 (declare-function notmuch-search-next-thread "notmuch" nil)
+(declare-function notmuch-search-previous-thread "notmuch" nil)
 (declare-function notmuch-search-show-thread "notmuch" nil)
 
 (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date")
@@ -1270,6 +1271,8 @@ reset based on the original query."
 	(define-key map "P" 'notmuch-show-previous-message)
 	(define-key map "n" 'notmuch-show-next-open-message)
 	(define-key map "p" 'notmuch-show-previous-open-message)
+	(define-key map (kbd "M-n") 'notmuch-show-next-thread-show)
+	(define-key map (kbd "M-p") 'notmuch-show-previous-thread-show)
 	(define-key map (kbd "DEL") 'notmuch-show-rewind)
 	(define-key map " " 'notmuch-show-advance-and-archive)
 	(define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
@@ -1842,6 +1845,27 @@ argument, hide all of the messages."
       (if show-next
 	  (notmuch-search-show-thread)))))
 
+(defun notmuch-show-previous-thread (&optional show-previous)
+  "Move to the next item in the search results, if any."
+  (interactive "P")
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (notmuch-kill-this-buffer)
+    (when (buffer-live-p parent-buffer)
+      (switch-to-buffer parent-buffer)
+      (notmuch-search-previous-thread)
+      (if show-previous
+	  (notmuch-search-show-thread)))))
+
+(defun notmuch-show-next-thread-show ()
+  "Show the next thread in the search results, if any."
+  (interactive)
+  (notmuch-show-next-thread t))
+
+(defun notmuch-show-previous-thread-show ()
+  "Show the previous thread in the search results, if any."
+  (interactive)
+  (notmuch-show-previous-thread t))
+
 (defun notmuch-show-archive-thread (&optional unarchive)
   "Archive each message in thread.
 
-- 
1.7.10.4



More information about the notmuch mailing list