--- /dev/null
+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 olra.theworths.org (Postfix) with ESMTP id 1FFA8431FC2\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:44 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ws3jpj2D4Fee for <notmuch@notmuchmail.org>;\r
+ Mon, 12 May 2014 05:29:38 -0700 (PDT)\r
+Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com\r
+ [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 146AB431FCB\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:33 -0700 (PDT)\r
+Received: by mail-wi0-f173.google.com with SMTP id bs8so4359779wib.6\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:31 -0700 (PDT)\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:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=ipdvO6xL3t8JHovYHW3OTwGHJbS5OJkzs4NgmemMm2Y=;\r
+ b=YsojfmzIinrqYW4N/Mh3mkhfa9mNnBaxP5vp3wPpwsdvbVpfI0Hzx5RXOMtB9RgHLJ\r
+ nQmu2AdZjXtkzLJAPrA48/z4AzoRc52vDWO3MGGIjR62tkgj24QCmMEOOCLEQWFcUU/t\r
+ JZ4itzcs1O9Lgmw7kXC/9NPNKxLn4fmQvK4YPbnWyln3/Lp9e7A22dJG9xnECgvvMfor\r
+ 4D3Rvyhnf6oevi9R3LB4ETUzhkq7acmZDf07hvKI4RTTBFOxoex8FkpNhwNyrSnO5/Bq\r
+ Dm7/D73eI0pK6iZ+xtj34pbGA0SN9x6ECb0CEh6EG7knlBHSbxNhmbi/C1rUFkxvohcx\r
+ wZ2A==\r
+X-Gm-Message-State:\r
+ ALoCoQmpQhZzkdvQdMBVSBk0H0/FCyBR2zovZEq11OmV7oHjhe6zyeh9eM+n21GFDb9ejJN9vPKP\r
+X-Received: by 10.180.19.201 with SMTP id h9mr3258424wie.17.1399897771659;\r
+ Mon, 12 May 2014 05:29:31 -0700 (PDT)\r
+Received: from hotblack-desiato.hh.sledj.net (disaster-area.hh.sledj.net.\r
+ [81.149.164.25]) by mx.google.com with ESMTPSA id\r
+ l12sm17746272wjr.35.2014.05.12.05.29.29 for <notmuch@notmuchmail.org>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Mon, 12 May 2014 05:29:30 -0700 (PDT)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 3625610B308; Mon, 12 May 2014 13:29:29 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 1/9] emacs/show: Re-arrange determination if a part header\r
+ is necessary\r
+Date: Mon, 12 May 2014 13:29:21 +0100\r
+Message-Id: <1399897769-26809-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.0.0.rc0\r
+In-Reply-To: <1399897769-26809-1-git-send-email-dme@dme.org>\r
+References: <87sixdujkv.fsf@qmul.ac.uk>\r
+ <1399897769-26809-1-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 12 May 2014 12:29:44 -0000\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 10fc872..ec99141 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -871,6 +871,21 @@ message at DEPTH in the current thread."\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)\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
+@@ -881,19 +896,15 @@ 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
+ (beg (point))\r
+ ;; Hide the part initially if HIDE is t.\r
+ (show-part (not (equal hide t)))\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))\r
+ (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
+ (content-beg (point)))\r
+ \r
+-- \r
+2.0.0.rc0\r
+\r