* emacs/notmuch-show.el (notmuch-show-toggle-visibility-messages):
  Toggle visibility of all messages in current thread based on visibility
  of the current message, instead of setting visibility based on whether
  or not a prefix arg was supplied.

  Also move current buffer line to the 2nd window line so the current
  message is put properly into focus, whilst making the presence of
  previous messages in the thread obvious.

Same functionality, less effort (reaching for 'C-u' is a pain)...
---
 emacs/notmuch-show.el |   20 ++++++++++++--------
 test/emacs            |    6 +++---
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e4d1f9c..82d4265 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1669,15 +1669,19 @@ (defun notmuch-show-toggle-visibility-message ()
   (force-window-update))
 
 (defun notmuch-show-toggle-visibility-messages ()
-  "Set the visibility all of the messages in the current thread.
-By default make all of the messages visible. With a prefix
-argument, hide all of the messages."
+  "Toggle the visibility of all messages in the current thread.
+If the current message is visible, hide all messages -- and vice versa."
   (interactive)
-  (save-excursion
-    (goto-char (point-min))
-    (loop do (notmuch-show-message-visible 
(notmuch-show-get-message-properties)
-                                          (not current-prefix-arg))
-         until (not (notmuch-show-goto-message-next))))
+  (let ((visible-p (notmuch-show-message-visible-p)))
+    (notmuch-show-mapc
+     (lambda () (notmuch-show-message-visible
+                (notmuch-show-get-message-properties)
+                (not visible-p)))))
+
+  ;; Put the current message properly into focus, but don't
+  ;; obscure the presence of previous messages in the thread.
+  (recenter-top-bottom 1)
+
   (force-window-update))
 
 (defun notmuch-show-next-button ()
diff --git a/test/emacs b/test/emacs
index 29fdec0..5c61743 100755
--- a/test/emacs
+++ b/test/emacs
@@ -410,14 +410,14 @@ test_expect_equal_file OUTPUT 
$EXPECTED/notmuch-show-message-with-headers-hidden
 
 test_begin_subtest "notmuch-show: collapse all messages in thread"
 test_emacs '(notmuch-show 
"id:f35dbb950911171435ieecd458o853c873e35f4b...@mail.gmail.com")
-       (let ((current-prefix-arg t))
-         (notmuch-show-toggle-visibility-messages)
-         (test-visible-output))'
+       (notmuch-show-toggle-visibility-messages)
+       (test-visible-output)'
 test_expect_equal_file OUTPUT 
$EXPECTED/notmuch-show-thread-with-all-messages-collapsed
 
 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
 test_emacs '(notmuch-show 
"id:f35dbb950911171435ieecd458o853c873e35f4b...@mail.gmail.com")
        (notmuch-show-toggle-visibility-messages)
+       (notmuch-show-toggle-visibility-messages)
        (test-visible-output)'
 test_expect_equal_file OUTPUT 
$EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
 
-- 
1.7.8.1

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

Reply via email to