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 20432431FBD for ; Wed, 18 Jan 2012 02:06:41 -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 WRonpE4ZEM9i for ; Wed, 18 Jan 2012 02:06:40 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 66F30431FAE for ; Wed, 18 Jan 2012 02:06:40 -0800 (PST) Received: by wgbdr13 with SMTP id dr13so2152275wgb.2 for ; Wed, 18 Jan 2012 02:06:39 -0800 (PST) Received: by 10.180.104.5 with SMTP id ga5mr29837096wib.21.1326881199197; Wed, 18 Jan 2012 02:06:39 -0800 (PST) Received: from localhost ([109.131.97.13]) by mx.google.com with ESMTPS id eb2sm21593141wib.0.2012.01.18.02.06.38 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jan 2012 02:06:38 -0800 (PST) From: Pieter Praet To: David Edmondson Subject: [RFC] [PATCH v3] emacs: rewrite `notmuch-cycle-notmuch-buffers' Date: Wed, 18 Jan 2012 11:04:44 +0100 Message-Id: <1326881084-25432-1-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <87fwfd8h0i.fsf@praet.org> References: <87fwfd8h0i.fsf@praet.org> 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: Wed, 18 Jan 2012 10:06:41 -0000 Get rid of the compile-time `cl' requirement for this particular function. --- emacs/notmuch.el | 40 ++++++++++++++++++++++------------------ 1 files changed, 22 insertions(+), 18 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index ef4dcc7..2426c0a 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -1084,24 +1084,28 @@ current search results AND that are tagged with the given tag." 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)) + (let* ((old-buffer (current-buffer)) + (next-buffer (first + ;; Find interesting buffers: + ;; Loop over all existing buffers and return those that + ;; satisfy the predicate (`notmuch-interesting-buffer' and + ;; not `eq' to current buffer) integrally; All others are + ;; replaced with `nil'. Then strip out all `nil's using + ;; `delq'. Basically a re-implementation of `cl' package's + ;; `delete-if-not'. + (delq nil + (mapcar (lambda (b) + (and (notmuch-interesting-buffer b) + (not (eq old-buffer b)) + b)) + (buffer-list)))))) + + ;; If there's a next buffer, switch to it and bury the + ;; original current buffer. Otherwise run `notmuch-hello'. + (if next-buffer + (progn + (switch-to-buffer next-buffer) + (bury-buffer old-buffer)) (notmuch)))) (setq mail-user-agent 'notmuch-user-agent) -- 1.7.8.1