From 286240a83757f1643bcc48ef261164fa6268ea64 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 20 Feb 2016 18:24:36 +0000 Subject: [PATCH] [PATCH v6 2/6] emacs/show: Make the insertion of part headers overridable. --- 19/4fb50696531866e3e9632fd628a7e7e4048b08 | 133 ++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 19/4fb50696531866e3e9632fd628a7e7e4048b08 diff --git a/19/4fb50696531866e3e9632fd628a7e7e4048b08 b/19/4fb50696531866e3e9632fd628a7e7e4048b08 new file mode 100644 index 000000000..9dac6efc9 --- /dev/null +++ b/19/4fb50696531866e3e9632fd628a7e7e4048b08 @@ -0,0 +1,133 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id F348F6DE1401 + for ; Sat, 20 Feb 2016 10:24:59 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.28 +X-Spam-Level: +X-Spam-Status: No, score=-0.28 tagged_above=-999 required=5 tests=[AWL=0.290, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id RTEWGnFP5SJj for ; + Sat, 20 Feb 2016 10:24:58 -0800 (PST) +Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com + [74.125.82.53]) by arlo.cworth.org (Postfix) with ESMTPS id B4F096DE1579 for + ; Sat, 20 Feb 2016 10:24:51 -0800 (PST) +Received: by mail-wm0-f53.google.com with SMTP id g62so119128677wme.1 + for ; Sat, 20 Feb 2016 10:24:51 -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:in-reply-to:references; + bh=FXcGUjAVTxHcvwwxECM4Q8fuScHEKo9nfxsJ/iYw3F8=; + b=ejigbFROWmI0kRQ4WR+N2FccirYBft4dYJweACKVEbvWugh/NVmaZi+QVsrHLz7SpI + o2EhcG4uz6/uk7XmxCPEkpSaxzI+mysKGf0+I6SMkz6GyK917KcUgIzyKg/j8CV0IeqO + LCpU7dFR9zpfDnX3QgFHrEfcdNRtjPgGbuBKiqBpn3SRGyzEtp3OJscTXR9r0J8m2lOW + jy7FhSqD22l/sQtg4v83cyz9S3JhUrS//aEJNMFOHlu4VQrYTmxxLvNzPhuYyaGqLJ/z + 60W2gTUTm+OYQ51pSe1hifGZyJP1J1Vo9omBpsb7l6nbHq9wsTVypGshVeUxKck0wvUQ + uKXw== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=FXcGUjAVTxHcvwwxECM4Q8fuScHEKo9nfxsJ/iYw3F8=; + b=ME9PdOHbIIT83djmT6GaS/s70ntIgApinZkE+cf6Z/lFu0srWk1wOXIFWXUwpyLQxt + GB8eTfjNX3wsxj+WKp9OCCEbudruLQJTnp5u52uuG578C6gvek8LUmjkDaX98GiV4cqs + nYoQ6wlYE9RCyjmGgvhTmYTriDtCupRYzjC6lhAO4AYeD6Fz1LK8H/lkIcOuB0BJGZXf + d/qlQkco969pfjHeGD+soMCXxrQM0n6IllutDbGl7o8p7SKJybzJN2Fd33sF1z75gdto + Y5plrBlxHAb7EhDfj24SoRFaYoPp9G+7IvjblrKMuH9HybPP4pmu9aZOtQE1VSo4gRPI + RlAQ== +X-Gm-Message-State: + AG10YOSX4yIjHuRhAhnRzcrXF2dKvxi7BARhpsU05s0PI+4O6jfLyweZ4U618g6pre0Gmg== +X-Received: by 10.194.76.161 with SMTP id l1mr19319654wjw.108.1455992690499; + Sat, 20 Feb 2016 10:24:50 -0800 (PST) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id u4sm16701886wjz.4.2016.02.20.10.24.49 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 20 Feb 2016 10:24:50 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v6 2/6] emacs/show: Make the insertion of part headers + overridable. +Date: Sat, 20 Feb 2016 18:24:36 +0000 +Message-Id: <1455992680-24978-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1455992680-24978-1-git-send-email-markwalters1009@gmail.com> +References: <1455992680-24978-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Sat, 20 Feb 2016 18:25:00 -0000 + +From: David Edmondson + +This allows callers of notmuch-show-insert-bodypart to use a `let' +binding to override the default function for specifying when part +headers should be inserted. + +We also add an option to never show part buttons which will be used by +the test suites for the reply tests. +--- + emacs/notmuch-show.el | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 9d9c89f..ddb9c65 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -930,13 +930,23 @@ (defun notmuch-show-mime-type (part) + "text/x-diff") + content-type))) + ++;; The following variable can be overridden by let bindings. ++(defvar notmuch-show-insert-header-p-function 'notmuch-show-insert-header-p ++ "Specify which function decides which part headers get inserted. ++ ++The function should take two parameters, PART and HIDE, and ++should return non-NIL if a header button should be inserted for ++this part.") ++ + (defun notmuch-show-insert-header-p (part hide) +- "Return non-NIL if a header button should be inserted for this part." + ;; Show all part buttons except for the first part if it is text/plain. + (let ((mime-type (notmuch-show-mime-type part))) + (not (and (string= mime-type "text/plain") + (<= (plist-get part :id) 1))))) + ++(defun notmuch-show-reply-insert-header-p-never (part hide) ++ nil) ++ + (defun notmuch-show-insert-bodypart (msg part depth &optional hide) + "Insert the body part PART at depth DEPTH in the current thread. + +@@ -953,10 +963,10 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide) + (> notmuch-show-max-text-part-size 0) + (> (length (plist-get part :content)) notmuch-show-max-text-part-size))) + (beg (point)) +- ;; We show the part button if notmuch-show-insert-header-p +- ;; says to, unless HIDE is 'no-buttons. ++ ;; This default header-p function omits the part button for ++ ;; the first (or only) part if this is text/plain. + (button (when (and (not (equal hide 'no-buttons)) +- (notmuch-show-insert-header-p part hide)) ++ (funcall notmuch-show-insert-header-p-function part hide)) + (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))) + ;; Hide the part initially if HIDE is t, or if it is too long + ;; and we have a button to allow toggling (thus reply which +-- +2.1.4 + -- 2.26.2