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

2011-06-07 Thread Dima Kogan
> On Sun, 29 May 2011 01:56:44 -0700
> notmuch at dima.secretsauce.net wrote:
>
>  Here's another improvement. In the notmuch-show display this binds
> '[' to expand all the children messages (replies). Analogously ']'
> collapses all the children messages.

Here's an update of the patch to conform with notmuch's indentation style.
-- next part --
A non-text attachment was scrubbed...
Name: 0001-added-keys-to-hide-show-a-portion-of-the-thread.patch
Type: text/x-patch
Size: 2119 bytes
Desc: not available
URL: 



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

2011-06-07 Thread Dima Kogan
 On Sun, 29 May 2011 01:56:44 -0700
 notm...@dima.secretsauce.net wrote:

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

Here's an update of the patch to conform with notmuch's indentation style.
From 0e2ef657fe0f6e7f8f2f7e87acd1fbbf58d8d95d Mon Sep 17 00:00:00 2001
From: Dima Kogan d...@secretsauce.net
Date: Sun, 29 May 2011 00:37:55 -0700
Subject: [PATCH] added keys to hide/show a portion of the thread

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

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 2ba151e..5ecf5ca 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,35 @@ 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.5.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

2011-05-29 Thread notm...@dima.secretsauce.net
From: Dima Kogan 

---

 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