unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last.
@ 2011-12-27 10:50 David Edmondson
  2011-12-27 11:02 ` David Edmondson
                   ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: David Edmondson @ 2011-12-27 10:50 UTC (permalink / raw)
  To: notmuch

As suggested by j4ni in #notmuch, rename
`notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
have it behave accordingly.
---
 emacs/notmuch.el |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c678c93..4844385 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1056,20 +1056,35 @@ current search results AND that are tagged with the given tag."
   (notmuch-hello))
 
 ;;;###autoload
-(defun notmuch-jump-to-recent-buffer ()
-  "Jump to the most recent notmuch buffer (search, show or hello).
+(defun notmuch-cycle-notmuch-buffers ()
+  "Cycle through any existing notmuch buffers (search, show or hello).
 
-If no recent buffer is found, run `notmuch'."
+If the current buffer is the only notmuch buffer, bury it. If no
+notmuch buffers exist, 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)
+
+  (let (start first)
+    ;; If the current buffer is a notmuch buffer, remember it and then
+    ;; bury it.
+    (when (memq major-mode '(notmuch-show-mode
+			     notmuch-search-mode
+			     notmuch-hello-mode))
+      (setq start (current-buffer))
+      (bury-buffer))
+
+    ;; Find the first notmuch buffer.
+    (setq first (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 first
+	;; If the first one we found is any other than the starting
+	;; buffer, switch to it.
+	(unless (eq first start)
+	  (switch-to-buffer first))
       (notmuch))))
 
 (setq mail-user-agent 'notmuch-user-agent)
-- 
1.7.7.3

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

end of thread, other threads:[~2012-01-19 19:15 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-27 10:50 [PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last David Edmondson
2011-12-27 11:02 ` David Edmondson
2011-12-27 19:23 ` Jani Nikula
2011-12-28  8:20   ` David Edmondson
2011-12-28  8:29 ` [PATCH v2] " David Edmondson
2012-01-10 16:55   ` David Edmondson
2012-01-10 20:15     ` Jani Nikula
2012-01-14  9:32       ` Pieter Praet
2012-01-14  9:29   ` Pieter Praet
2012-01-15 11:55     ` David Edmondson
2012-01-16  3:01       ` Austin Clements
2012-01-16  8:43         ` David Edmondson
2012-01-16 10:42           ` [PATCH] [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch' Pieter Praet
2012-01-16 11:06             ` David Edmondson
2012-01-16 11:28               ` Pieter Praet
2012-01-16 11:32                 ` Pieter Praet
2012-01-16 11:47                 ` David Edmondson
2012-01-16 16:45                   ` Pieter Praet
2012-01-16 16:46                     ` [PATCH] v2 " Pieter Praet
2012-01-16 17:03                       ` David Edmondson
2012-01-18 10:03                         ` Pieter Praet
2012-01-18 10:04                           ` [RFC] [PATCH v3] emacs: rewrite `notmuch-cycle-notmuch-buffers' Pieter Praet
2012-01-18 10:13                           ` [PATCH] v2 [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch' David Edmondson
2012-01-18 12:15                             ` Pieter Praet
2012-01-18 12:57                               ` David Edmondson
     [not found]                                 ` <cunboq1mad1.fsf@hotblack-desiato.hh.sledj.net>
2012-01-18 13:48                                   ` Pieter Praet
2012-01-18 22:18                                     ` Aaron Ecay
2012-01-19  0:48                                       ` Austin Clements
2012-01-19  8:19                                       ` David Edmondson
2012-01-19 19:13                                       ` Pieter Praet
2012-01-16 21:10                       ` Jani Nikula
2012-01-18 10:07                         ` Pieter Praet
2012-01-16  2:45   ` [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last David Bremner

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