]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Add `notmuch-jump-to-recent-buffer'.
authorDavid Edmondson <dme@dme.org>
Tue, 20 Dec 2011 08:01:46 +0000 (08:01 +0000)
committerDavid Bremner <bremner@debian.org>
Tue, 20 Dec 2011 12:10:36 +0000 (08:10 -0400)
From a Carl Worth idea: add a function 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

index 675a1105dc3b109ce0d1cb1dc8f199a6d3bf7dad..982b7d3ff7a2f713eec3f99e02860d5f9b0a741b 100644 (file)
@@ -1055,6 +1055,23 @@ 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 (with-current-buffer buffer
+                   (memq major-mode '(notmuch-show-mode
+                                      notmuch-search-mode
+                                      notmuch-hello-mode)))
+              return buffer)))
+    (if last
+       (switch-to-buffer last)
+      (notmuch))))
+
 (setq mail-user-agent 'notmuch-user-agent)
 
 (provide 'notmuch)