[PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last.

Jani Nikula jani at nikula.org
Tue Dec 27 11:23:25 PST 2011


On Tue, 27 Dec 2011 10:50:44 +0000, David Edmondson <dme at dme.org> wrote:
> As suggested by j4ni in #notmuch, rename
> `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
> have it behave accordingly.

Hi David, thanks for submitting this. It works nicely, and IMHO it's
*much* more useful than notmuch-jump-to-recent-buffer.

I'm wondering whether message-mode should be included. I tried it, and
it's useful in my interrupted-more-often-than-I'd-like-to workflow...

BR,
Jani.



> ---
>  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
> 
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list