--- /dev/null
+Return-Path: <awg@lagos.xvx.ca>\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 00D48431FBC\r
+ for <notmuch@notmuchmail.org>; Sat, 5 May 2012 12:24:37 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 NQ+2nBSBqjPm for <notmuch@notmuchmail.org>;\r
+ Sat, 5 May 2012 12:24:37 -0700 (PDT)\r
+Received: from idcmail-mo2no.shaw.ca (idcmail-mo2no.shaw.ca [64.59.134.9])\r
+ by olra.theworths.org (Postfix) with ESMTP id B4D64431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 5 May 2012 12:24:36 -0700 (PDT)\r
+Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd5ml1no-ssvc.prod.shaw.ca)\r
+ ([10.0.144.222])\r
+ by pd7mo1no-svcs.prod.shaw.ca with ESMTP; 05 May 2012 13:24:34 -0600\r
+X-Cloudmark-SP-Filtered: true\r
+X-Cloudmark-SP-Result: v=1.1 cv=bD0CuDYpMgGTku+nVSbZuKP/9fNjspX1F8zuwcoBWhM=\r
+ c=1 sm=1\r
+ a=0FXa78-lThQA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
+ a=H2UTGGZU_1RtzGQqgokA:9 a=JivfGXD8Il3uE6aJGmwA:7\r
+ a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
+Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
+ by pd5ml1no-dmz.prod.shaw.ca with ESMTP; 05 May 2012 13:24:34 -0600\r
+Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
+ id 15BD38004809; Sat, 5 May 2012 13:24:34 -0600 (MDT)\r
+From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 2/2] emacs: Correctly quote non-text/plain parts in reply\r
+Date: Sat, 5 May 2012 13:24:29 -0600\r
+Message-Id: <1336245869-32699-3-git-send-email-awg+notmuch@xvx.ca>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1336245869-32699-1-git-send-email-awg+notmuch@xvx.ca>\r
+References: <1336245869-32699-1-git-send-email-awg+notmuch@xvx.ca>\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, 05 May 2012 19:24:38 -0000\r
+\r
+Quote non-text parts nicely by displaying them with mm-display-part\r
+before calling message-cite-original to quote them. HTML-only emails\r
+can now be quoted correctly. We re-use some code from notmuch-show\r
+(notmuch-show-mm-display-part-inline), which has been moved to\r
+notmuch-lib.el.\r
+\r
+Mark the test for this feature as not broken.\r
+---\r
+ emacs/notmuch-lib.el | 19 +++++++++++++++++++\r
+ emacs/notmuch-mua.el | 13 ++++++++-----\r
+ emacs/notmuch-show.el | 19 +------------------\r
+ test/emacs | 1 -\r
+ 4 files changed, 28 insertions(+), 24 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 6907a5f..7fa441a 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -21,6 +21,8 @@\r
+ \r
+ ;; This is an part of an emacs-based interface to the notmuch mail system.\r
+ \r
++(require 'mm-view)\r
++(require 'mm-decode)\r
+ (eval-when-compile (require 'cl))\r
+ \r
+ (defvar notmuch-command "notmuch"\r
+@@ -237,6 +239,23 @@ the given type."\r
+ (or (plist-get part :content)\r
+ (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) nth process-crypto)))\r
+ \r
++(defun notmuch-mm-display-part-inline (msg part nth content-type process-crypto)\r
++ "Use the mm-decode/mm-view functions to display a part in the\r
++current buffer, if possible."\r
++ (let ((display-buffer (current-buffer)))\r
++ (with-temp-buffer\r
++ (let* ((charset (plist-get part :content-charset))\r
++ (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))\r
++ ;; If the user wants the part inlined, insert the content and\r
++ ;; test whether we are able to inline it (which includes both\r
++ ;; capability and suitability tests).\r
++ (when (mm-inlined-p handle)\r
++ (insert (notmuch-get-bodypart-content msg part nth process-crypto))\r
++ (when (mm-inlinable-p handle)\r
++ (set-buffer display-buffer)\r
++ (mm-display-part handle)\r
++ t))))))\r
++\r
+ ;; Converts a plist of headers to an alist of headers. The input plist should\r
+ ;; have symbols of the form :Header as keys, and the resulting alist will have\r
+ ;; symbols of the form 'Header as keys.\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 87bd88d..88d7505 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -21,6 +21,7 @@\r
+ \r
+ (require 'json)\r
+ (require 'message)\r
++(require 'mm-view)\r
+ (require 'format-spec)\r
+ \r
+ (require 'notmuch-lib)\r
+@@ -90,6 +91,12 @@ list."\r
+ else if (notmuch-match-content-type (plist-get part :content-type) "text/*")\r
+ collect part))\r
+ \r
++(defun notmuch-mua-insert-quotable-part (message part)\r
++ (notmuch-mm-display-part-inline message part (plist-get part :id)\r
++ (plist-get part :content-type)\r
++ notmuch-show-process-crypto)\r
++ (goto-char (point-max)))\r
++\r
+ ;; There is a bug in emacs 23's message.el that results in a newline\r
+ ;; not being inserted after the References header, so the next header\r
+ ;; is concatenated to the end of it. This function fixes the problem,\r
+@@ -169,11 +176,7 @@ list."\r
+ ;; Get the parts of the original message that should be quoted; this includes\r
+ ;; all the text parts, except the non-preferred ones in a multipart/alternative.\r
+ (let ((quotable-parts (notmuch-mua-get-quotable-parts (plist-get original :body))))\r
+- (mapc (lambda (part)\r
+- (insert (notmuch-get-bodypart-content original part\r
+- (plist-get part :id)\r
+- notmuch-show-process-crypto)))\r
+- quotable-parts))\r
++ (mapc (apply-partially 'notmuch-mua-insert-quotable-part original) quotable-parts))\r
+ \r
+ (set-mark (point))\r
+ (goto-char start)\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 37f0ebb..d318430 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -524,23 +524,6 @@ message at DEPTH in the current thread."\r
+ (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
+ (mm-interactively-view-part handle))))\r
+ \r
+-(defun notmuch-show-mm-display-part-inline (msg part nth content-type)\r
+- "Use the mm-decode/mm-view functions to display a part in the\r
+-current buffer, if possible."\r
+- (let ((display-buffer (current-buffer)))\r
+- (with-temp-buffer\r
+- (let* ((charset (plist-get part :content-charset))\r
+- (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))\r
+- ;; If the user wants the part inlined, insert the content and\r
+- ;; test whether we are able to inline it (which includes both\r
+- ;; capability and suitability tests).\r
+- (when (mm-inlined-p handle)\r
+- (insert (notmuch-get-bodypart-content msg part nth notmuch-show-process-crypto))\r
+- (when (mm-inlinable-p handle)\r
+- (set-buffer display-buffer)\r
+- (mm-display-part handle)\r
+- t))))))\r
+-\r
+ (defun notmuch-show-multipart/*-to-list (part)\r
+ (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
+ (plist-get part :content)))\r
+@@ -785,7 +768,7 @@ current buffer, if possible."\r
+ (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)\r
+ ;; This handler _must_ succeed - it is the handler of last resort.\r
+ (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))\r
+- (notmuch-show-mm-display-part-inline msg part nth content-type)\r
++ (notmuch-mm-display-part-inline msg part nth content-type notmuch-show-process-crypto)\r
+ t)\r
+ \r
+ ;; Functions for determining how to handle MIME parts.\r
+diff --git a/test/emacs b/test/emacs\r
+index 5f238d9..a615b39 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -445,7 +445,6 @@ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+ test_begin_subtest "Reply within emacs to an html-only message"\r
+-test_subtest_known_broken\r
+ add_message '[content-type]="text/html"' \\r
+ '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'\r
+ test_emacs "(let ((message-hidden-headers '()))\r
+-- \r
+1.7.5.4\r
+\r