--- /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 olra.theworths.org (Postfix) with ESMTP id D4CDE431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 4 May 2013 06:01:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 xtJAYDQnDQJu for <notmuch@notmuchmail.org>;\r
+ Sat, 4 May 2013 06:01:28 -0700 (PDT)\r
+Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com\r
+ [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 29B90431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 4 May 2013 06:01:28 -0700 (PDT)\r
+Received: by mail-wi0-f179.google.com with SMTP id l13so1365123wie.6\r
+ for <notmuch@notmuchmail.org>; Sat, 04 May 2013 06:01:27 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+ :references; bh=b2dzy7QmwGFP+t+dbduyCCJCKQvVTX9zeZNIO0wy4GY=;\r
+ b=q5PGVB2aSnPkVJVlSWvI9Y7COul9DmT7VSR2tjiu7whViE8V/BnJ6gLn2yPRvP9dKj\r
+ +c/+62LTidvumvO7uFNL3vdnfAWP6V17yso6T3NO85dtkhpJJrrGBCvaXTCq4EMTu7pV\r
+ 3M9LbC40Pwgke+vjJ8SJI6FLdRXrB2qxcaylY6gifhXWUW+tMukiovHdFgFEq2xfoWnK\r
+ Y9fiaLClKNDJDRYhgIEFp12Z1/79XtUBq2ErmPspIkeSH3KmgAtayxcsyVkn0ZtrjjQA\r
+ +oFsCT0j+o/jNi46+TnVKdX9fFlTyCiLX+lW8nuBBz6IofOSLGGm+yBjtVwtJBcsMVvk\r
+ Aixg==\r
+X-Received: by 10.194.5.196 with SMTP id u4mr18216453wju.54.1367672487061;\r
+ Sat, 04 May 2013 06:01:27 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id x13sm3143486wib.3.2013.05.04.06.01.26\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 04 May 2013 06:01:26 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/4] emacs:show: separate out handling of\r
+ application/octet-stream\r
+Date: Sat, 4 May 2013 14:01:14 +0100\r
+Message-Id: <1367672478-12247-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1367672478-12247-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1367672478-12247-1-git-send-email-markwalters1009@gmail.com>\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: Sat, 04 May 2013 13:01:34 -0000\r
+\r
+Currently mime parts are basically handled based on their mime-type\r
+with the exception of application/octet-stream parts. Deal with these\r
+parts at the top level (notmuch-show-insert-bodypart).\r
+\r
+This is needed later in the series as we need to put in a part button\r
+for each part (which means knowing its mime type) while deferring the\r
+actual insertion of the part.\r
+---\r
+ emacs/notmuch-show.el | 19 +++++++++++--------\r
+ 1 files changed, 11 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index face2a0..3b9a2ad 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -796,9 +796,9 @@ message at DEPTH in the current thread."\r
+ (defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type)\r
+ (notmuch-show-insert-part-text/calendar msg part content-type nth depth declared-type))\r
+ \r
+-(defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type)\r
++(defun notmuch-show-get-mime-type-of-application/octet-stream (part)\r
+ ;; If we can deduce a MIME type from the filename of the attachment,\r
+- ;; do so and pass it on to the handler for that type.\r
++ ;; we return that.\r
+ (if (plist-get part :filename)\r
+ (let ((extension (file-name-extension (plist-get part :filename)))\r
+ mime-type)\r
+@@ -808,7 +808,7 @@ message at DEPTH in the current thread."\r
+ (setq mime-type (mailcap-extension-to-mime extension))\r
+ (if (and mime-type\r
+ (not (string-equal mime-type "application/octet-stream")))\r
+- (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type)\r
++ mime-type\r
+ nil))\r
+ nil))))\r
+ \r
+@@ -885,11 +885,14 @@ message at DEPTH in the current thread."\r
+ "Insert the body part PART at depth DEPTH in the current thread.\r
+ \r
+ If HIDE is non-nil then initially hide this part."\r
+- (let ((content-type (downcase (plist-get part :content-type)))\r
+- (nth (plist-get part :id))\r
+- (beg (point)))\r
+-\r
+- (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)\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
++ content-type))\r
++ (nth (plist-get part :id))\r
++ (beg (point)))\r
++\r
++ (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type)\r
+ ;; Some of the body part handlers leave point somewhere up in the\r
+ ;; part, so we make sure that we're down at the end.\r
+ (goto-char (point-max))\r
+-- \r
+1.7.9.1\r
+\r