[notmuch] [PATCH 2/3] notmuch.el: Add collapse all and expand all to notmuch-show

Kan-Ru Chen kanru at kanru.info
Mon Nov 30 22:17:32 PST 2009


These two functions behave like gmail's collapse all and expand all
commands. notmuch-show-collapse-all is bound to 'B' but
notmuch-show-expand-all has no keybindig because I thought it is not often
used.

Signed-off-by: Kan-Ru Chen <kanru at kanru.info>
---
 notmuch.el |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 2526020..5b8513c 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -63,6 +63,7 @@
     (define-key map "a" 'notmuch-show-archive-thread)
     (define-key map "A" 'notmuch-show-mark-read-then-archive-thread)
     (define-key map "b" 'notmuch-show-toggle-current-body)
+    (define-key map "B" 'notmuch-show-collapse-all)
     (define-key map "f" 'notmuch-show-forward-current)
     (define-key map "h" 'notmuch-show-toggle-current-header)
     (define-key map "m" 'message-mail)
@@ -582,6 +583,30 @@ which this thread was originally shown."
     (push-button))
   )
 
+(defun notmuch-show-collapse-all ()
+  (interactive)
+  (save-excursion
+    (beginning-of-buffer)
+    (while (not (notmuch-show-last-message-p))
+      (unless (button-at (point))
+        (notmuch-show-next-button))
+      (let ((invis-spec (button-get (button-at (point)) 'invisibility-spec)))
+        (add-to-invisibility-spec invis-spec))
+      (notmuch-show-next-open-message)
+      )))
+
+(defun notmuch-show-expand-all ()
+  (interactive)
+  (save-excursion
+    (beginning-of-buffer)
+    (while (not (notmuch-show-last-message-p))
+      (unless (button-at (point))
+        (notmuch-show-next-button))
+      (let ((invis-spec (button-get (button-at (point)) 'invisibility-spec)))
+        (remove-from-invisibility-spec invis-spec))
+      (notmuch-show-next-message)
+      )))
+
 (define-button-type 'notmuch-button-invisibility-toggle-type 'action 'notmuch-toggle-invisible-action 'follow-link t)
 (define-button-type 'notmuch-button-citation-toggle-type 'help-echo "mouse-1, RET: Show citation"
   :supertype 'notmuch-button-invisibility-toggle-type)
-- 
1.6.5.3



More information about the notmuch mailing list