unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Pieter Praet <pieter@praet.org>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH v2 6/7] emacs: make `notmuch-show-toggle-visibility-messages' live up to its new name
Date: Wed, 22 Feb 2012 19:43:33 +0100	[thread overview]
Message-ID: <1329936214-30959-6-git-send-email-pieter@praet.org> (raw)
In-Reply-To: <1327469139-1968-1-git-send-email-pieter@praet.org>

* 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:f35dbb950911171435ieecd458o853c873e35f4be95@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:f35dbb950911171435ieecd458o853c873e35f4be95@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

  parent reply	other threads:[~2012-02-22 18:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-25  5:25 [PATCH] emacs: make `notmuch-show-open-or-close-all' toggle visibility Pieter Praet
2012-01-25  6:35 ` David Edmondson
2012-01-25 13:03   ` Tomi Ollila
2012-01-26 13:02   ` Pieter Praet
2012-01-26 15:04     ` David Edmondson
2012-01-26 15:58 ` Tomi Ollila
2012-02-13 10:51 ` Dmitry Kurochkin
2012-02-22 18:41   ` Pieter Praet
2012-02-22 18:43 ` [PATCH v2 1/7] test: emacs: new tests "notmuch-show: {show, hide} message headers" Pieter Praet
2012-10-20 20:40   ` David Bremner
2012-02-22 18:43 ` [PATCH v2 2/7] test: emacs: new tests "notmuch-show: {, un}collapse all messages in thread" Pieter Praet
2012-02-22 18:43 ` [PATCH v2 3/7] emacs: rename `notmuch-show-toggle-headers' to `notmuch-show-toggle-visibility-headers' Pieter Praet
2012-10-12 21:36   ` Ethan Glasser-Camp
2012-10-18  0:29     ` Ethan Glasser-Camp
2012-10-18  9:47       ` Tomi Ollila
2012-10-18  9:50       ` Tomi Ollila
2012-10-18 13:37         ` Ethan
2012-10-18 13:59           ` Tomi Ollila
2012-02-22 18:43 ` [PATCH v2 4/7] emacs: rename `notmuch-show-toggle-message' to `notmuch-show-toggle-visibility-message' Pieter Praet
2012-02-22 18:43 ` [PATCH v2 5/7] emacs: rename `notmuch-show-open-or-close-all' to `notmuch-show-toggle-visibility-messages' Pieter Praet
2012-02-22 18:43 ` Pieter Praet [this message]
2012-02-22 18:43 ` [PATCH v2 7/7] emacs: `notmuch-show-toggle-visibility-messages' with prefix arg filters by tag Pieter Praet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329936214-30959-6-git-send-email-pieter@praet.org \
    --to=pieter@praet.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).