From 6c4b5be63ba218ef207e5402f3c2b9c9f81006c8 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Thu, 22 Jan 2015 21:07:32 +0000 Subject: [PATCH] [PATCH] emacs: show: allow user to hide some mime types by default. --- 00/cb95e73514a98c845914ff01c6aada03a70a47 | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 00/cb95e73514a98c845914ff01c6aada03a70a47 diff --git a/00/cb95e73514a98c845914ff01c6aada03a70a47 b/00/cb95e73514a98c845914ff01c6aada03a70a47 new file mode 100644 index 000000000..73e04efee --- /dev/null +++ b/00/cb95e73514a98c845914ff01c6aada03a70a47 @@ -0,0 +1,134 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 8AE41431FD2 + for ; Thu, 22 Jan 2015 13:07:46 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.639 +X-Spam-Level: ** +X-Spam-Status: No, score=2.639 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + DNS_FROM_AHBL_RHSBL=2.438, FREEMAIL_ENVFROM_END_DIGIT=1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id XMz5rhSmhbfi for ; + Thu, 22 Jan 2015 13:07:43 -0800 (PST) +Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com + [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 21E80431FCB for ; Thu, 22 Jan 2015 13:07:43 -0800 + (PST) +Received: by mail-wg0-f45.google.com with SMTP id x12so4066622wgg.4 + for ; Thu, 22 Jan 2015 13:07:42 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id; + bh=sh2PsD2N96QBs5RroDPKtfX7pAtfEuQy59mST5Lez1w=; + b=ve2LRDVzQX8qDAj57/3SqMeGGeHrLZ3UqeU/eFEx7ZrCkSvmuTdODascoPyszlKU2Q + b0AX8Ca6zHpwtnxbC8l5UGhWhLeLhs9kxFi0uoOPgbhedCLXqeEStuX39uF8Hb/w8f8X + lI3zYbQlslbZ3hQSPycgqbUe8QITD7Eovpt0A78dLnme0J5rX1GQ35O7LKX51+iw+t5F + gZaVam39DC2cLTHvFpsa40Dw4sVtaO1W8UML5Wkj7P+aSR/8iXVk6sgmeAzyQ+qz/X9/ + GqzoFmcsguckzO3aMw/ZRbCLaB3dGUv2eLQVVdjh65RTFVuecxlt5ryWU2PzZxyiiazU + 3aqw== +X-Received: by 10.180.206.165 with SMTP id lp5mr8894367wic.83.1421960862151; + Thu, 22 Jan 2015 13:07:42 -0800 (PST) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by mx.google.com with ESMTPSA id l6sm5480649wjx.33.2015.01.22.13.07.34 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Thu, 22 Jan 2015 13:07:41 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: show: allow user to hide some mime types by default. +Date: Thu, 22 Jan 2015 21:07:32 +0000 +Message-Id: <1421960852-26424-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 22 Jan 2015 21:07:46 -0000 + +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)))))) ++ + ;; + + + (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 + -- 2.26.2