unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] added keys to hide/show a portion of the thread
@ 2011-05-29  8:56 notmuch
  2011-06-07  6:37 ` Dima Kogan
  0 siblings, 1 reply; 2+ messages in thread
From: notmuch @ 2011-05-29  8:56 UTC (permalink / raw)
  To: notmuch

From: Dima Kogan <dima@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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-07  6:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-29  8:56 [PATCH] added keys to hide/show a portion of the thread notmuch
2011-06-07  6:37 ` Dima Kogan

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).