[PATCH] added keys to hide/show a portion of the thread

notmuch at dima.secretsauce.net notmuch at dima.secretsauce.net
Sun May 29 01:56:44 PDT 2011


From: Dima Kogan <dima at secretsauce.net>

---

 Here's another improvement. In the notmuch-show display this binds '[' to
 expand all the children messages (replies). Analogously ']' collapses all the
 children messages.

 dima

 emacs/notmuch-show.el |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 2ba151e..600f3ec 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -813,6 +813,8 @@ function is used. "
 	(define-key map " " 'notmuch-show-advance-and-archive)
 	(define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
 	(define-key map (kbd "RET") 'notmuch-show-toggle-message)
+	(define-key map "]" 'notmuch-show-hide-hierarchy)
+	(define-key map "[" 'notmuch-show-show-hierarchy)
 	map)
       "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
@@ -1266,6 +1268,38 @@ argument, hide all of the messages."
 	  until (not (notmuch-show-goto-message-next))))
   (force-window-update))
 
+; get the depth, assuming the point is at the start of the header line
+(defun notmuch-show-get-depth ()
+  (save-excursion
+    (let ((start (point)))
+      (- (re-search-forward "^ *") start))))
+
+(defun notmuch-show-hideshow-hierarchy (doshow)
+  "Hides or shows this message and all its replies"
+  (interactive)
+  (save-excursion
+    (notmuch-show-move-to-message-top)
+
+    (let ((depth0 (notmuch-show-get-depth)))
+      (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties)
+                                             doshow)
+            until (or (not (notmuch-show-goto-message-next))
+                      (<= (notmuch-show-get-depth) depth0))))
+  (force-window-update))
+)
+
+(defun notmuch-show-show-hierarchy ()
+  "Show this message and all its replies"
+  (interactive)
+  (notmuch-show-hideshow-hierarchy 1)
+)
+
+(defun notmuch-show-hide-hierarchy ()
+  "Hide this message and all its replies"
+  (interactive)
+  (notmuch-show-hideshow-hierarchy nil)
+)
+
 (defun notmuch-show-next-button ()
   "Advance point to the next button in the buffer."
   (interactive)
-- 
1.7.4.4



More information about the notmuch mailing list