From 0e2ef657fe0f6e7f8f2f7e87acd1fbbf58d8d95d Mon Sep 17 00:00:00 2001 From: Dima Kogan 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