Re: [PATCH v4 5/7] emacs/show: Make the insertion of part headers overridable.
authorDavid Edmondson <dme@dme.org>
Tue, 9 Feb 2016 20:32:13 +0000 (20:32 +0000)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:03 +0000 (16:21 -0700)
41/b02af9a1a412d7222d9553610fbcc520098a19 [new file with mode: 0644]

diff --git a/41/b02af9a1a412d7222d9553610fbcc520098a19 b/41/b02af9a1a412d7222d9553610fbcc520098a19
new file mode 100644 (file)
index 0000000..0610768
--- /dev/null
@@ -0,0 +1,132 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 35C136DE14FD\r
+ for <notmuch@notmuchmail.org>; Tue,  9 Feb 2016 12:32:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.087\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.087 tagged_above=-999 required=5\r
+ tests=[AWL=-0.020, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id jy1j5TzyHquY for <notmuch@notmuchmail.org>;\r
+ Tue,  9 Feb 2016 12:32:18 -0800 (PST)\r
+Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com\r
+ [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 0B6D96DE01D3 for\r
+ <notmuch@notmuchmail.org>; Tue,  9 Feb 2016 12:32:18 -0800 (PST)\r
+Received: by mail-wm0-f68.google.com with SMTP id p63so59099wmp.1\r
+ for <notmuch@notmuchmail.org>; Tue, 09 Feb 2016 12:32:17 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=dme-org.20150623.gappssmtp.com; s=20150623;\r
+ h=to:subject:in-reply-to:references:from:date:message-id:mime-version\r
+ :content-type; bh=tl4jJGpsyLPvEb1hWmKE0UmrCBIQbnCFKR+LaYlLLnE=;\r
+ b=V6b2thQNi43sbBO9DwWNXJwtLe5yKS89PgbFYu4QFzD9bDWCyNEa2ptOHyo29f1zxG\r
+ a8Cplm0e1OIY0WRbuTJQeP9NHhgQ+pmFfp67fuyvubegSAGNiyJy4vSuTeEcSrRz1hKm\r
+ yvmcArvnwMBEoYxzUuqWH5tkhsJ1oTE5G18UGuxgbwMHXH+L03Ee5z8UVgj3/3E53VV4\r
+ PEwZNkMiocuj2/on2KXzPPgMrZvTxoOvEyV3uMlanFADWjVyKxoaPrkb2r8Q0nWJZi2C\r
+ 0lpFea2h9aAWaX7sMUI7s8QsmAb1ABj1vqmiP01u7+4acT40qQeZYUtxEeN1dZLYjD6h\r
+ uSMQ==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:to:subject:in-reply-to:references:from:date\r
+ :message-id:mime-version:content-type;\r
+ bh=tl4jJGpsyLPvEb1hWmKE0UmrCBIQbnCFKR+LaYlLLnE=;\r
+ b=eZermYubUxb9qN5VT6K8Jq2RsmYme+CxXwqjIJXl/nFiOf/pYCoqklLula2b7zsZ+m\r
+ GxFVrIon1P7DMndAT7T5AP7crh0/0kCUEq5bsu3e2uHJ1Is9UXTRmTL3nC42wln15Pd3\r
+ GBjPHeYCqMFYrAgN5Z913OAWQKKqQuRc/q2ipgLoSxRzxsqrqgJ0kDVjt6J6EeOAxOfO\r
+ IUrXNVl1k0X9EO+o/G66v4XbkhkfEF9zsJrZUWKGzdTehksylPowDlQazIvXn5JczA4E\r
+ X9r7qTK+RcJw5QwHERp1cy40XotJk3wEd2ZXsKk7myCmWy7rVroXRokWWVRGBoacZDJg\r
+ 886w==\r
+X-Gm-Message-State:\r
+ AG10YOTugjPIhZrOu0lV/KwhkPKOXu4DZVmId0x5TeNobLZ3Ds4wkLCrH8XaLfUbY4wInA==\r
+X-Received: by 10.194.87.201 with SMTP id ba9mr35816752wjb.128.1455049936716; \r
+ Tue, 09 Feb 2016 12:32:16 -0800 (PST)\r
+Received: from disaster-area.hh.sledj.net\r
+ ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
+ by smtp.gmail.com with ESMTPSA id bg1sm36397861wjc.27.2016.02.09.12.32.15\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Tue, 09 Feb 2016 12:32:15 -0800 (PST)\r
+Received: from localhost (disaster-area.hh.sledj.net [local])\r
+ by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 33ba720f;\r
+ Tue, 9 Feb 2016 20:32:13 +0000 (UTC)\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 5/7] emacs/show: Make the insertion of part headers\r
+ overridable.\r
+In-Reply-To: <1446894276-7814-6-git-send-email-markwalters1009@gmail.com>\r
+References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com>\r
+ <1446894276-7814-6-git-send-email-markwalters1009@gmail.com>\r
+From: David Edmondson <dme@dme.org>\r
+Date: Tue, 09 Feb 2016 20:32:13 +0000\r
+Message-ID: <m24mdh4oc2.fsf@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 09 Feb 2016 20:32:20 -0000\r
+\r
+On Sat, Nov 07 2015, Mark Walters wrote:\r
+> From: David Edmondson <dme@dme.org>\r
+>\r
+> This allows callers of notmuch-show-insert-bodypart to use a `let'\r
+> binding to override the default function for specifying when part\r
+> headers should be inserted.\r
+\r
+Looks fine.\r
+\r
+> ---\r
+>  emacs/notmuch-show.el | 16 ++++++++++++----\r
+>  1 file changed, 12 insertions(+), 4 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index f8184e2..f4a65cc 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -945,8 +945,16 @@ (defun notmuch-show-mime-type (part)\r
+>           "text/x-diff")\r
+>      content-type)))\r
+>  \r
+> +;; The following variable can be overridden by let bindings.\r
+> +(defvar notmuch-show-insert-header-p-function 'notmuch-show-insert-header-p\r
+> +  "Specify which function decides which part headers get inserted.\r
+> +\r
+> +The function should take two parameters, PART and HIDE, and\r
+> +should return non-NIL if a header button should be inserted for\r
+> +this part.")\r
+> +\r
+>  (defun notmuch-show-insert-header-p (part hide)\r
+> -  "Return non-NIL if a header button should be inserted for this part."\r
+> +  ;; Show all part buttons except for the first part if it is text/plain.\r
+>    (let ((mime-type (notmuch-show-mime-type part)))\r
+>      (not (and (string= mime-type "text/plain")\r
+>            (<= (plist-get part :id) 1)))))\r
+> @@ -965,9 +973,9 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
+>                  (> notmuch-show-max-text-part-size 0)\r
+>                  (> (length (plist-get part :content)) notmuch-show-max-text-part-size)))\r
+>       (beg (point))\r
+> -     ;; We omit the part button for the first (or only) part if\r
+> -     ;; this is text/plain, or HIDE is 'no-buttons.\r
+> -     (button (when (notmuch-show-insert-header-p part hide)\r
+> +     ;; This default header-p function omits the part button for\r
+> +     ;; the first (or only) part if this is text/plain.\r
+> +     (button (when (funcall notmuch-show-insert-header-p-function part hide)\r
+>                 (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
+>       ;; Hide the part initially if HIDE is t, or if it is too long\r
+>       ;; and we have a button to allow toggling (thus reply which\r
+> -- \r
+> 2.1.4\r