1 Return-Path: <james@hackervisions.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 3AD9C431FBC
\r
6 for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 19:43:16 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.486 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.587, BAYES_50=0.001, RDNS_DYNAMIC=0.1] autolearn=no
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 4duFci62MBSE for <notmuch@notmuchmail.org>;
\r
16 Wed, 24 Feb 2010 19:43:15 -0800 (PST)
\r
17 Received: from hackervisions.org (67-207-143-141.slicehost.net
\r
19 by olra.theworths.org (Postfix) with ESMTP id 661FB431FAE
\r
20 for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 19:43:15 -0800 (PST)
\r
21 Received: from ool-18bd392a.dyn.optonline.net ([24.189.57.42] helo=localhost)
\r
22 by hv with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69)
\r
23 (envelope-from <james@hackervisions.org>) id 1NkUd5-0007mS-RI
\r
24 for notmuch@notmuchmail.org; Wed, 24 Feb 2010 22:43:12 -0500
\r
25 From: James Vasile <james@hackervisions.org>
\r
26 To: notmuch <notmuch@notmuchmail.org>
\r
27 Date: Wed, 24 Feb 2010 22:43:04 -0500
\r
28 Message-ID: <87mxyyou9j.fsf@hackervisions.org>
\r
30 Content-Type: text/plain; charset=us-ascii
\r
31 Subject: [notmuch] [PATCH] Refactor notmuch-folder-add to avoid recursion.
\r
32 Allow notmuch-folders to contain folders with empty search criteria.
\r
33 X-BeenThere: notmuch@notmuchmail.org
\r
34 X-Mailman-Version: 2.1.13
\r
36 List-Id: "Use and development of the notmuch mail system."
\r
37 <notmuch.notmuchmail.org>
\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
41 List-Post: <mailto:notmuch@notmuchmail.org>
\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
45 X-List-Received-Date: Thu, 25 Feb 2010 03:43:16 -0000
\r
47 Refactor notmuch-folder-add to avoid recursion. Allow notmuch-folders
\r
48 to contain folders with empty search criteria.
\r
50 Setting a folder's search criteria to "" in notmuch-folders causes a
\r
51 label to be printed in notmuch-folder view. This is good for helping
\r
52 organizing folders, e.g. by using ("Mailing lists" . "").
\r
54 The old, recursive version ran the risk of exceeding
\r
55 max-lisp-eval-depth.
\r
57 notmuch.el | 36 +++++++++++++++++++++---------------
\r
58 1 files changed, 21 insertions(+), 15 deletions(-)
\r
60 diff --git a/notmuch.el b/notmuch.el
\r
61 index 6482170..5eb6bd1 100644
\r
64 @@ -1699,21 +1699,27 @@ Currently available key bindings:
\r
67 (defun notmuch-folder-add (folders)
\r
69 - (let* ((name (car (car folders)))
\r
70 - (inhibit-read-only t)
\r
71 - (search (cdr (car folders)))
\r
72 - (count (notmuch-folder-count search)))
\r
73 - (if (or notmuch-folder-show-empty
\r
74 - (not (equal count "0")))
\r
82 - (notmuch-folder-add (cdr folders)))))
\r
85 + (let ((name (car folder)))
\r
86 + (if (not (string= "" (cdr folder)))
\r
87 + (let* ((inhibit-read-only t)
\r
88 + (search (cdr folder))
\r
89 + (count (notmuch-folder-count search)))
\r
90 + (if (or notmuch-folder-show-empty
\r
91 + (not (equal count "0")))
\r
95 + (insert (notmuch-folder-count (format "(%s) and tag:unread" search)))
\r
102 + (insert "\n")))))
\r
105 (defun notmuch-folder-find-name ()
\r