--- /dev/null
+Return-Path: <james@hackervisions.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 3AD9C431FBC\r
+ for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 19:43:16 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.486\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.486 tagged_above=-999 required=5\r
+ tests=[AWL=-0.587, BAYES_50=0.001, RDNS_DYNAMIC=0.1] autolearn=no\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 4duFci62MBSE for <notmuch@notmuchmail.org>;\r
+ Wed, 24 Feb 2010 19:43:15 -0800 (PST)\r
+Received: from hackervisions.org (67-207-143-141.slicehost.net\r
+ [67.207.143.141])\r
+ by olra.theworths.org (Postfix) with ESMTP id 661FB431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 24 Feb 2010 19:43:15 -0800 (PST)\r
+Received: from ool-18bd392a.dyn.optonline.net ([24.189.57.42] helo=localhost)\r
+ by hv with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69)\r
+ (envelope-from <james@hackervisions.org>) id 1NkUd5-0007mS-RI\r
+ for notmuch@notmuchmail.org; Wed, 24 Feb 2010 22:43:12 -0500\r
+From: James Vasile <james@hackervisions.org>\r
+To: notmuch <notmuch@notmuchmail.org>\r
+Date: Wed, 24 Feb 2010 22:43:04 -0500\r
+Message-ID: <87mxyyou9j.fsf@hackervisions.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Subject: [notmuch] [PATCH] Refactor notmuch-folder-add to avoid recursion.\r
+ Allow notmuch-folders to contain folders with empty search criteria.\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 25 Feb 2010 03:43:16 -0000\r
+\r
+Refactor notmuch-folder-add to avoid recursion. Allow notmuch-folders\r
+to contain folders with empty search criteria.\r
+\r
+Setting a folder's search criteria to "" in notmuch-folders causes a\r
+label to be printed in notmuch-folder view. This is good for helping\r
+organizing folders, e.g. by using ("Mailing lists" . "").\r
+\r
+The old, recursive version ran the risk of exceeding\r
+max-lisp-eval-depth.\r
+---\r
+ notmuch.el | 36 +++++++++++++++++++++---------------\r
+ 1 files changed, 21 insertions(+), 15 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 6482170..5eb6bd1 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -1699,21 +1699,27 @@ Currently available key bindings:\r
+ (notmuch-folder))\r
+ \r
+ (defun notmuch-folder-add (folders)\r
+- (if folders\r
+- (let* ((name (car (car folders)))\r
+- (inhibit-read-only t)\r
+- (search (cdr (car folders)))\r
+- (count (notmuch-folder-count search)))\r
+- (if (or notmuch-folder-show-empty\r
+- (not (equal count "0")))\r
+- (progn\r
+- (insert name)\r
+- (indent-to 16 1)\r
+- (insert count)\r
+- (insert "\n")\r
+- )\r
+- )\r
+- (notmuch-folder-add (cdr folders)))))\r
++ (mapc\r
++ (lambda (folder)\r
++ (let ((name (car folder)))\r
++ (if (not (string= "" (cdr folder)))\r
++ (let* ((inhibit-read-only t)\r
++ (search (cdr folder))\r
++ (count (notmuch-folder-count search)))\r
++ (if (or notmuch-folder-show-empty\r
++ (not (equal count "0")))\r
++ (progn\r
++ (insert name)\r
++ (indent-to 16 1)\r
++ (insert (notmuch-folder-count (format "(%s) and tag:unread" search)))\r
++ (insert "/")\r
++ (insert count)\r
++ (insert "\n"))))\r
++ (progn\r
++ (insert "\n")\r
++ (insert name)\r
++ (insert "\n")))))\r
++ folders))\r
+ \r
+ (defun notmuch-folder-find-name ()\r
+ (save-excursion\r
+-- \r
+1.6.3.3\r
+\r