[PATCH] emacs: make `notmuch-show-open-or-close-all' toggle visibility

Pieter Praet pieter at praet.org
Tue Jan 24 21:25:39 PST 2012


* 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



More information about the notmuch mailing list