--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 EDE216DE1ABD\r
+ for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:22 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.245\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.245 tagged_above=-999 required=5 tests=[AWL=0.325,\r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-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 6_C7_sSPvTsp for <notmuch@notmuchmail.org>;\r
+ Sun, 14 Feb 2016 10:40:21 -0800 (PST)\r
+Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com\r
+ [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id AFEC06DE10C1 for\r
+ <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:13 -0800 (PST)\r
+Received: by mail-wm0-f67.google.com with SMTP id b205so4795312wmb.1\r
+ for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:13 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=cz2au64fdOj5I+AU71A0uiMe2HpsCJ7bi5iFMjCPT4U=;\r
+ b=W8ju5XDl9F1vbCbKoeQ+B4cyiCMisx18nahqNBl8UQM+XjgymU9sGN4/N9jhrkKn5Z\r
+ ZZA57zjjlgn7kI1MVD7oG60TUZnRN8ScKyD1HoSHHmpL0Yp+WO9tTQuDh9mLXWISaj8O\r
+ G8npDCX3uWFGwuYw4boW7Ek1cj/YzoOCpb+SyjwsgI5T6se9FmkXAQnxOea1dyq1iIN7\r
+ 5GfD7si6vgusAG59zlBiUIr7YIcZpJo7CS5QXtuLUaAip4VhnDKKmJTVbpdDfESQY/CO\r
+ u5loI20LsEGBgx/tuFvRmMSEAWeGd8A+36vNrE/pzlkQISEzMoRQ0nKjZZ5aobEotsVu\r
+ jg/A==\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:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=cz2au64fdOj5I+AU71A0uiMe2HpsCJ7bi5iFMjCPT4U=;\r
+ b=NbAEqy7+EhDW9oR03mrOAUw8Y1DNeWj/8qq9cZR27939HxP2HHQ1SDEWKYnpGSunYV\r
+ T5D4wdXyNpZpzWdQZPBxmaNctQWUS5asko1FuwSg4e+L+NZwPGH80KJJ47JfZ16at/o9\r
+ QTFULp9g7YGwdXA5bZK/Clan40TDbfrIz4o4XtNkBe6P/+cvFGCu4lBUHvEWhh55s56p\r
+ SKv4eTvV+bhfX3GDVDM6S9ubVjTj3m7s5S0uOD4y2bqftMF8Cj9/6Zyr2/4h2RkVb600\r
+ 1bzGgQteaSmhlYcpZKEInjnHEZYhyCsmYFdWhw92HCtPlwJtZd3V4uEnV7gFiJpJF5yz\r
+ OplA==\r
+X-Gm-Message-State:\r
+ AG10YOQy+d0BmgXCaZUKT+TpJ+LtPQh0FvpRBBEcFRuX+fsXGx7EimWslNAuiJ4gaSDx4w==\r
+X-Received: by 10.28.54.22 with SMTP id d22mr8191133wma.72.1455475212380;\r
+ Sun, 14 Feb 2016 10:40:12 -0800 (PST)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id a128sm12051876wmh.6.2016.02.14.10.40.10\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sun, 14 Feb 2016 10:40:11 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v5 1/7] emacs/show: Re-arrange determination if a part header\r
+ is necessary\r
+Date: Sun, 14 Feb 2016 18:39:53 +0000\r
+Message-Id: <1455475199-32622-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1455475199-32622-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1455475199-32622-1-git-send-email-markwalters1009@gmail.com>\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: Sun, 14 Feb 2016 18:40:23 -0000\r
+\r
+From: David Edmondson <dme@dme.org>\r
+\r
+Move the determination of whether a part header is required to a\r
+distinct function.\r
+---\r
+ emacs/notmuch-show.el | 30 +++++++++++++++++++++---------\r
+ 1 file changed, 21 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 3345878..70cdb9d 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -927,6 +927,22 @@ will return nil if the CID is unknown or cannot be retrieved."\r
+ ;; showable this returns nil.\r
+ (notmuch-show-create-part-overlays button part-beg part-end))))\r
+ \r
++(defun notmuch-show-mime-type (part)\r
++ "Return the correct mime-type to use for PART."\r
++ (let ((content-type (downcase (plist-get part :content-type))))\r
++ (or (and (string= content-type "application/octet-stream")\r
++ (notmuch-show-get-mime-type-of-application/octet-stream part))\r
++ (and (string= content-type "inline patch")\r
++ "text/x-diff")\r
++ content-type)))\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
++\r
+ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
+ "Insert the body part PART at depth DEPTH in the current thread.\r
+ \r
+@@ -937,20 +953,16 @@ is t, hide the part initially and show the button. If HIDE is\r
+ useful for quoting in replies)."\r
+ \r
+ (let* ((content-type (downcase (plist-get part :content-type)))\r
+- (mime-type (or (and (string= content-type "application/octet-stream")\r
+- (notmuch-show-get-mime-type-of-application/octet-stream part))\r
+- (and (string= content-type "inline patch")\r
+- "text/x-diff")\r
+- content-type))\r
++ (mime-type (notmuch-show-mime-type part))\r
+ (nth (plist-get part :id))\r
+ (long (and (notmuch-match-content-type mime-type "text/*")\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 (unless (or (equal hide 'no-buttons)\r
+- (and (string= mime-type "text/plain") (<= nth 1)))\r
++ ;; We show the part button if notmuch-show-insert-header-p\r
++ ;; says to, unless HIDE is 'no-buttons.\r
++ (button (when (and (not (equal hide 'no-buttons))\r
++ (notmuch-show-insert-header-p 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
+\r