unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: add some convenience functions to show mode
@ 2010-11-14 22:09 Jameson Rollins
  2010-11-16 19:35 ` Carl Worth
  0 siblings, 1 reply; 4+ messages in thread
From: Jameson Rollins @ 2010-11-14 22:09 UTC (permalink / raw)
  To: Notmuch Mail

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

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

end of thread, other threads:[~2010-12-07 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-14 22:09 [PATCH] emacs: add some convenience functions to show mode Jameson Rollins
2010-11-16 19:35 ` Carl Worth
2010-11-16 20:41   ` Jameson Rollins
2010-12-07 22:10     ` Carl Worth

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).