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] emacs: make `notmuch-show-open-or-close-all' toggle visibility
Date: Wed, 25 Jan 2012 06:25:39 +0100	[thread overview]
Message-ID: <1327469139-1968-1-git-send-email-pieter@praet.org> (raw)

* emacs/notmuch-show.el (notmuch-show-open-or-close-all):
  Rename to `notmuch-show-toggle-all-messages', and make it toggle
  visibility of all messages based on the visibility of the current
  message, instead of setting visibility based on whether or not a
  prefix arg was supplied.

Same functionality, less effort (reaching for 'C-u' is a pain)...

---
 emacs/notmuch-show.el |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..2d17f74 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1050,8 +1050,8 @@ thread id.  If a prefix is given, crypto processing is toggled."
 	(define-key map "p" 'notmuch-show-previous-open-message)
 	(define-key map (kbd "DEL") 'notmuch-show-rewind)
 	(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 (kbd "M-RET") 'notmuch-show-toggle-all-messages)
 	(define-key map "#" 'notmuch-show-print-message)
 	map)
       "Keymap for \"notmuch show\" buffers.")
@@ -1502,16 +1502,18 @@ the result."
      (not (plist-get props :message-visible))))
   (force-window-update))
 
-(defun notmuch-show-open-or-close-all ()
-  "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."
+(defun notmuch-show-toggle-all-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 ((toggle (notmuch-show-message-visible-p)))
+    (save-excursion
+      (goto-char (point-min))
+      (loop do (notmuch-show-message-visible
+		(notmuch-show-get-message-properties)
+		(not toggle))
+	    until (not (notmuch-show-goto-message-next)))))
+  (recenter-top-bottom 1)
   (force-window-update))
 
 (defun notmuch-show-next-button ()
-- 
1.7.8.1

             reply	other threads:[~2012-01-25  5:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-25  5:25 Pieter Praet [this message]
2012-01-25  6:35 ` [PATCH] emacs: make `notmuch-show-open-or-close-all' toggle visibility 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 ` [PATCH v2 6/7] emacs: make `notmuch-show-toggle-visibility-messages' live up to its new name Pieter Praet
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=1327469139-1968-1-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).