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 66A49431FD0 for ; Tue, 27 Dec 2011 02:50:51 -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 U5Dcz52ETxBG for ; Tue, 27 Dec 2011 02:50:51 -0800 (PST) Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id CECFE431FB6 for ; Tue, 27 Dec 2011 02:50:50 -0800 (PST) Received: by wgbdt12 with SMTP id dt12so15459002wgb.2 for ; Tue, 27 Dec 2011 02:50:49 -0800 (PST) Received: by 10.216.139.94 with SMTP id b72mr15291838wej.38.1324983049606; Tue, 27 Dec 2011 02:50:49 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id fq7sm27588224wbb.1.2011.12.27.02.50.47 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Dec 2011 02:50:48 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 7DE93A04BC; Tue, 27 Dec 2011 10:50:46 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last. Date: Tue, 27 Dec 2011 10:50:44 +0000 Message-Id: <1324983044-29249-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.7.3 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 10:50:51 -0000 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