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