[PATCH] emacs: add function to toggle display of all multipart/alternative parts

Jani Nikula jani at nikula.org
Fri Jun 15 08:55:51 PDT 2012


Add function notmuch-show-toggle-multipart-alternative to make
notmuch-show-all-multipart/alternative-parts buffer local, toggle its
value in the buffer, and redisplay the thread with either all or
preferred alternative parts expanded.

A small wrinkle is that in order to make the variable survive
notmuch-show-refresh-view (which is required for expanding/collapsing
the parts, but ends up calling kill-all-local-variables through
notmuch-show-mode) it is necessary to give it the permanent-local
property.
---
 emacs/notmuch-show.el |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 36cad93..9c177d9 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -99,6 +99,17 @@ any given message."
   :type 'boolean
   :group 'notmuch-show)
 
+(defun notmuch-show-toggle-multipart-alternative ()
+  "Toggle `notmuch-show-all-multipart/alternative-parts' in the buffer."
+  (interactive)
+  (unless (local-variable-p 'notmuch-show-all-multipart/alternative-parts)
+    (make-local-variable 'notmuch-show-all-multipart/alternative-parts)
+    ;; Make it permanently local to survive notmuch-show-refresh-view.
+    (put 'notmuch-show-all-multipart/alternative-parts 'permanent-local t))
+  (setq notmuch-show-all-multipart/alternative-parts
+	(not notmuch-show-all-multipart/alternative-parts))
+  (notmuch-show-refresh-view))
+
 (defcustom notmuch-show-indent-messages-width 1
   "Width of message indentation in threads.
 
-- 
1.7.9.5



More information about the notmuch mailing list