>From a Carl Worth idea: Add `notmuch-jump-to-recent-buffer', which
will select the most recently used notmuch buffer (search, show or
hello). If no recent buffer is found, run `notmuch'.

It is expected that the user will global bind this command to a key
sequence.
---
 emacs/notmuch.el |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e8d4d98..67271d1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -962,6 +962,24 @@ current search results AND that are tagged with the given 
tag."
   (interactive)
   (notmuch-hello))

+;;;###autoload
+(defun notmuch-jump-to-recent-buffer ()
+  "Jump to the most recent notmuch buffer (search, show or hello).
+
+If no recent buffer is found, run `notmuch'."
+  (interactive)
+  (let ((last
+        (loop for buffer in (buffer-list)
+              if (progn
+                   (set-buffer buffer)
+                   (or (eq major-mode 'notmuch-show-mode)
+                       (eq major-mode 'notmuch-search-mode)
+                       (eq major-mode 'notmuch-hello-mode)))
+              return buffer)))
+    (if last
+       (switch-to-buffer last)
+      (notmuch))))
+
 (setq mail-user-agent 'notmuch-user-agent)

 (provide 'notmuch)
-- 
1.7.2.3

Reply via email to