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 27C60429E4D for ; Sat, 14 Jan 2012 01:31:21 -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 fIJ0od3aIsoi for ; Sat, 14 Jan 2012 01:31:20 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 5AA93429E4A for ; Sat, 14 Jan 2012 01:31:20 -0800 (PST) Received: by werh12 with SMTP id h12so21762wer.26 for ; Sat, 14 Jan 2012 01:31:19 -0800 (PST) Received: by 10.216.136.23 with SMTP id v23mr520747wei.48.1326533479053; Sat, 14 Jan 2012 01:31:19 -0800 (PST) Received: from localhost ([109.131.75.86]) by mx.google.com with ESMTPS id ga4sm14231108wbb.4.2012.01.14.01.31.18 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 14 Jan 2012 01:31:18 -0800 (PST) From: Pieter Praet To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last. In-Reply-To: <1325060998-25567-1-git-send-email-dme@dme.org> References: <1324983044-29249-1-git-send-email-dme@dme.org> <1325060998-25567-1-git-send-email-dme@dme.org> User-Agent: Notmuch/0.10.2+115~gadd29f6 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Sat, 14 Jan 2012 10:29:31 +0100 Message-ID: <87boq6pr7o.fsf@praet.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: Sat, 14 Jan 2012 09:31:21 -0000 On Wed, 28 Dec 2011 08:29:58 +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. > > Consider `message-mode' buffers to be of interest. > --- > emacs/notmuch.el | 42 ++++++++++++++++++++++++++++++------------ > 1 files changed, 30 insertions(+), 12 deletions(-) > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index c678c93..6a44d49 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -1055,21 +1055,39 @@ current search results AND that are tagged with the given tag." > (interactive) > (notmuch-hello)) > > +(defun notmuch-interesting-buffer (b) > + "Is the current buffer of interest to a notmuch user?" > + (with-current-buffer b > + (memq major-mode '(notmuch-show-mode > + notmuch-search-mode > + notmuch-hello-mode > + message-mode)))) > + > ;;;###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 (notmuch-interesting-buffer (current-buffer)) > + (setq start (current-buffer)) > + (bury-buffer)) > + > + ;; Find the first notmuch buffer. > + (setq first (loop for buffer in (buffer-list) > + if (notmuch-interesting-buffer buffer) > + 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 Signed-off-by: Pieter Praet ! Might I ask, to what key(chord) have you bound this ? Due to its usefulness, I'm inclined to bind it to [SPC], but on second though, that might be a bit on the intense side... Peace -- Pieter