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 75BE6431E64 for ; Mon, 16 Jan 2012 02:44:26 -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 kktGsQ8Rm3Io for ; Mon, 16 Jan 2012 02:44:26 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D43B2431FC0 for ; Mon, 16 Jan 2012 02:44:25 -0800 (PST) Received: by wibhr12 with SMTP id hr12so2269757wib.26 for ; Mon, 16 Jan 2012 02:44:24 -0800 (PST) Received: by 10.180.85.4 with SMTP id d4mr18522588wiz.0.1326710664720; Mon, 16 Jan 2012 02:44:24 -0800 (PST) Received: from localhost ([109.131.75.86]) by mx.google.com with ESMTPS id fv6sm33219738wib.8.2012.01.16.02.44.24 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 02:44:24 -0800 (PST) From: Pieter Praet To: David Edmondson , Austin Clements Subject: [PATCH] [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch' Date: Mon, 16 Jan 2012 11:42:31 +0100 Message-Id: <1326710551-23122-1-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: References: Cc: Notmuch Mail 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: Mon, 16 Jan 2012 10:44:26 -0000 CLisp'ier version of `notmuch-cycle-notmuch-buffers', merged into `notmuch', eliminating the need to hog yet another keybind. FYI: causes 2 compile warnings due to requiring the cl package at runtime. --- emacs/notmuch.el | 34 ++++++++-------------------------- 1 files changed, 8 insertions(+), 26 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index ef4dcc7..60ab0b2 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -1067,7 +1067,14 @@ current search results AND that are tagged with the given tag." (defun notmuch () "Run notmuch and display saved searches, known tags, etc." (interactive) - (notmuch-hello)) + (let* ((old-buffer (current-buffer)) + (interesting-buffers (remove-if-not #'notmuch-interesting-buffer (buffer-list))) + (next-buffer (first (member-if-not #'(lambda (b) (eq old-buffer b)) interesting-buffers)))) + (if next-buffer + (progn + (switch-to-buffer next-buffer) + (bury-buffer old-buffer)) + (notmuch-hello)))) (defun notmuch-interesting-buffer (b) "Is the current buffer of interest to a notmuch user?" @@ -1078,31 +1085,6 @@ current search results AND that are tagged with the given tag." message-mode)))) ;;;###autoload -(defun notmuch-cycle-notmuch-buffers () - "Cycle through any existing notmuch buffers (search, show or hello). - -If the current buffer is the only notmuch buffer, bury it. If no -notmuch buffers exist, run `notmuch'." - (interactive) - - (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.8.1