aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-12-26 16:34:18 -0800
committerCarl Worth <cworth@cworth.org>2010-02-08 14:40:25 -0800
commit79d3f9773c58d6fd7113871362687d8cfc0b1a59 (patch)
tree0b36c94e6763585a4246b5390e8272ed80acb4d4
parentb16a767f51441471178eebeeef8496843cee59e5 (diff)
Allow folders with no messages to be elided from list
This makes it easier to see folders with messages. Eliding empty folders is togged with the 'e' binding. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--notmuch.el29
1 files changed, 24 insertions, 5 deletions
diff --git a/notmuch.el b/notmuch.el
index 065ea86f..6c9004ec 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1447,6 +1447,7 @@ current search results AND that are tagged with the given tag."
(define-key map "x" 'kill-this-buffer)
(define-key map "q" 'kill-this-buffer)
(define-key map "m" 'message-mail)
+ (define-key map "e" 'notmuch-folder-show-empty-toggle)
(define-key map ">" 'notmuch-folder-last)
(define-key map "<" 'notmuch-folder-first)
(define-key map "=" 'notmuch-folder)
@@ -1523,14 +1524,32 @@ Currently available key bindings:
(goto-char (point-max))
(forward-line -1))
+(defun notmuch-folder-count (search)
+ (car (process-lines notmuch-command "count" search)))
+
+(setq notmuch-folder-show-empty t)
+
+(defun notmuch-folder-show-empty-toggle ()
+ "Toggle the listing of empty folders"
+ (interactive)
+ (setq notmuch-folder-show-empty (not notmuch-folder-show-empty))
+ (notmuch-folder))
+
(defun notmuch-folder-add (folders)
(if folders
- (let ((name (car (car folders)))
+ (let* ((name (car (car folders)))
(inhibit-read-only t)
- (search (cdr (car folders))))
- (insert name)
- (indent-to 16 1)
- (call-process notmuch-command nil t nil "count" search)
+ (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)))))
(defun notmuch-folder-find-name ()