unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: show: allow user to hide some mime types by default.
@ 2015-01-22 21:07 Mark Walters
  2015-01-22 21:28 ` Daniel Kahn Gillmor
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mark Walters @ 2015-01-22 21:07 UTC (permalink / raw)
  To: notmuch

This commit adds a customize variable that allows the user to choose
to hide some mime types by default. They can still choose to view the
part by toggling the part button.

One use is for hiding all text/html parts. This would mean that some
explicit user action was required before the part was loaded which
would mitigate some of the problems of remote image loading by the
emacs html renderer as detailed by dkg in
id:87ppa7q25w.fsf@alice.fifthhorseman.net.
---

I think this might be useful anyway (dkg asked for it before he found
the bug) but seems particularly relevant now.

To use set the variable notmuch-show-always-hide-types to '(text/html)
or use the customize setting to add text/html to the list.

Given the lack of control we have over the emacs renderers (so
possibility of future problems) we could even set this by default.

Best wishes

Mark

emacs/notmuch-show.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9f6fe07..8f49f17 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -234,6 +234,15 @@ every user interaction with notmuch."
   :type 'function
   :group 'notmuch-show)
 
+(defcustom notmuch-show-always-hide-types nil
+  "List of mime types that should always be hidden.
+
+This is a list of mime types that should be initally displayed in
+the show buffer as hidden parts; they can be displayed by
+toggling the part button. Wildcards are allowed in the list."
+  :type '(repeat string)
+  :group 'notmuch-show)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -798,6 +807,12 @@ message at DEPTH in the current thread."
 		(intern (concat "notmuch-show-insert-part-" content-type))))
     result))
 
+(defun notmuch-show-always-hide (mime-type)
+  "Is mime-type in notmuch-show-always-hide-types"
+  (let (match)
+    (dolist (type notmuch-show-always-hide-types match)
+      (setq match (or match (notmuch-match-content-type mime-type type))))))
+
 ;; \f
 
 (defun notmuch-show-insert-bodypart-internal (msg part content-type nth depth button)
@@ -900,7 +915,8 @@ useful for quoting in replies)."
 	 (nth (plist-get part :id))
 	 (beg (point))
 	 ;; Hide the part initially if HIDE is t.
-	 (show-part (not (equal hide t)))
+	 (show-part (and (not (equal hide t))
+			 (not (notmuch-show-always-hide mime-type))))
 	 ;; We omit the part button for the first (or only) part if
 	 ;; this is text/plain, or HIDE is 'no-buttons.
 	 (button (unless (or (equal hide 'no-buttons)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-22 19:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22 21:07 [PATCH] emacs: show: allow user to hide some mime types by default Mark Walters
2015-01-22 21:28 ` Daniel Kahn Gillmor
2015-01-23  7:21 ` David Edmondson
2015-01-23 18:26   ` Daniel Kahn Gillmor
2015-02-22 19:11 ` David Bremner

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).