Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0AEEC431FD0 for ; Tue, 27 Dec 2011 11:23:37 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uzsMNUlQCmvo for ; Tue, 27 Dec 2011 11:23:32 -0800 (PST) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 73ACD431FB6 for ; Tue, 27 Dec 2011 11:23:32 -0800 (PST) Received: by eekd41 with SMTP id d41so14376926eek.26 for ; Tue, 27 Dec 2011 11:23:29 -0800 (PST) Received: by 10.213.32.71 with SMTP id b7mr445864ebd.59.1325013809474; Tue, 27 Dec 2011 11:23:29 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi. [80.220.92.23]) by mx.google.com with ESMTPS id a60sm110385910eeb.4.2011.12.27.11.23.26 (version=SSLv3 cipher=OTHER); Tue, 27 Dec 2011 11:23:27 -0800 (PST) From: Jani Nikula To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last. In-Reply-To: <1324983044-29249-1-git-send-email-dme@dme.org> References: <1324983044-29249-1-git-send-email-dme@dme.org> User-Agent: Notmuch/0.10.2+142~g597904a (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Tue, 27 Dec 2011 21:23:25 +0200 Message-ID: <87vcp1es42.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 19:23:37 -0000 On Tue, 27 Dec 2011 10:50:44 +0000, David Edmondson 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@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch