[PATCH 2/2] emacs: Correctly quote non-text/plain parts in reply
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>
Sun, 22 Apr 2012 00:54:53 +0000 (18:54 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:36 +0000 (09:46 -0800)
a6/766cfd3d063916fc10b6e835d5b2275f104cbc [new file with mode: 0644]

diff --git a/a6/766cfd3d063916fc10b6e835d5b2275f104cbc b/a6/766cfd3d063916fc10b6e835d5b2275f104cbc
new file mode 100644 (file)
index 0000000..216b5bb
--- /dev/null
@@ -0,0 +1,123 @@
+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 46518431FC0\r
+       for <notmuch@notmuchmail.org>; Sat, 21 Apr 2012 17:55:07 -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 Ig1ZCXn0vodQ for <notmuch@notmuchmail.org>;\r
+       Sat, 21 Apr 2012 17:54:56 -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 4B3B3431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 21 Apr 2012 17:54:56 -0700 (PDT)\r
+Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd7ml2no-ssvc.prod.shaw.ca)\r
+       ([10.0.144.222])\r
+       by pd7mo1no-svcs.prod.shaw.ca with ESMTP; 21 Apr 2012 18:54:55 -0600\r
+X-Cloudmark-SP-Filtered: true\r
+X-Cloudmark-SP-Result: v=1.1 cv=GZn8e3lTBEeJrlGK3+GUWyR5aYe1SJcDn5uEERMe9yQ=\r
+       c=1 sm=1\r
+       a=B06ZCV3J_Z4A:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
+       a=m7wnEdaWTtPIwypKjJwA:9 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
+Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
+       by pd7ml2no-dmz.prod.shaw.ca with ESMTP; 21 Apr 2012 18:54:55 -0600\r
+Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
+       id EEBB48004814; Sat, 21 Apr 2012 18:54:54 -0600 (MDT)\r
+From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] emacs: Correctly quote non-text/plain parts in reply\r
+Date: Sat, 21 Apr 2012 18:54:53 -0600\r
+Message-Id: <1335056093-17621-3-git-send-email-awg+notmuch@xvx.ca>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1335056093-17621-1-git-send-email-awg+notmuch@xvx.ca>\r
+References: <1335056093-17621-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: Sun, 22 Apr 2012 00:55:07 -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.\r
+\r
+Mark the test for this feature as not broken.\r
+---\r
+ emacs/notmuch-mua.el |   20 +++++++++++++++-----\r
+ test/emacs           |    1 -\r
+ 2 files changed, 15 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 87bd88d..f7af789 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,19 @@ 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
++  (save-restriction\r
++    (narrow-to-region (point) (point))\r
++    (insert (notmuch-get-bodypart-content message part\r
++                                        (plist-get part :id)\r
++                                        notmuch-show-process-crypto))\r
++    (let ((handle (mm-make-handle (current-buffer)\r
++                                (list (plist-get part :content-type))))\r
++        (end-of-orig (point-max)))\r
++      (mm-display-part handle)\r
++      (kill-region (point-min) end-of-orig))\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 +183,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/test/emacs b/test/emacs\r
+index e648f80..579844f 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