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