--- /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 9E3F46DE1704\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Nov 2015 03:04:47 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.216\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.216 tagged_above=-999 required=5 tests=[AWL=0.086, \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,\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 JPS_-oNifwib for <notmuch@notmuchmail.org>;\r
+ Sat, 7 Nov 2015 03:04:45 -0800 (PST)\r
+Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com\r
+ [74.125.82.43]) by arlo.cworth.org (Postfix) with ESMTPS id 79D4E6DE1638 for\r
+ <notmuch@notmuchmail.org>; Sat, 7 Nov 2015 03:04:45 -0800 (PST)\r
+Received: by wmec201 with SMTP id c201so36450094wme.1\r
+ for <notmuch@notmuchmail.org>; Sat, 07 Nov 2015 03:04:43 -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=J/qV1mSM63xzZqbo3TsxfCcFBNS/xFk3u/GRd8Szh6Q=;\r
+ b=PTVsNniNA+r61PuykV9umQAiYPkfK+PA+R2y8RIqPp3XUkPm2H7F8vZzp2YVyVWs7n\r
+ rJ8t36JEp8DwlRK18kQs+ZI7uF8rw7hAiFB86FivPa0wptHJS7iJvmkbs4x39MP4b68z\r
+ XE52qRXqcovDZp9IMxMnJ099smU+SHKfM+9ptKPS/5kZHiooXZUXTkggCV7eq2w3GJTC\r
+ XXFNVTxuv1pTA2pxu3GprvUPXcZHN4BkFzdp7evhmv98eu+XEsL+KjThKW2UA5boysH9\r
+ ACYO/Sf6Nfkun4yoCDI6F9X88qZBQm6KRy0lUCxQ8MMn4vZJponOJeAuPs+e/dqrQZTK\r
+ 7Unw==\r
+X-Received: by 10.28.137.194 with SMTP id l185mr14649082wmd.21.1446894283619; \r
+ Sat, 07 Nov 2015 03:04:43 -0800 (PST)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id 71sm3418994wmm.24.2015.11.07.03.04.42\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 07 Nov 2015 03:04:42 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v4 1/7] emacs/show: Re-arrange determination if a part header\r
+ is necessary\r
+Date: Sat, 7 Nov 2015 11:04:30 +0000\r
+Message-Id: <1446894276-7814-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1446894276-7814-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: Sat, 07 Nov 2015 11:04:47 -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 | 25 ++++++++++++++++++-------\r
+ 1 file changed, 18 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 49fd198..47a02e5 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -929,6 +929,21 @@ (defun notmuch-show-lazy-part (part-args button)\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
++ (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
+@@ -939,11 +954,7 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\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
+@@ -951,8 +962,8 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\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
++ (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