Re: [PATCH 2/2] emacs: Correctly quote non-text/plain parts in reply
authorAustin Clements <amdragon@MIT.EDU>
Fri, 4 May 2012 19:05:07 +0000 (15:05 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:54 +0000 (09:46 -0800)
be/4d8e2f3fec4488f9b778a6c3f9c1d0689ff575 [new file with mode: 0644]

diff --git a/be/4d8e2f3fec4488f9b778a6c3f9c1d0689ff575 b/be/4d8e2f3fec4488f9b778a6c3f9c1d0689ff575
new file mode 100644 (file)
index 0000000..ed836ed
--- /dev/null
@@ -0,0 +1,181 @@
+Return-Path: <amdragon@mit.edu>\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 1A110431FB6\r
+       for <notmuch@notmuchmail.org>; Fri,  4 May 2012 12:05:12 -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 spuVHow3GV2V for <notmuch@notmuchmail.org>;\r
+       Fri,  4 May 2012 12:05:11 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+       [18.9.25.15])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3400F431FAE\r
+       for <notmuch@notmuchmail.org>; Fri,  4 May 2012 12:05:11 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f4f6d00000092b-66-4fa428657d90\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 87.2E.02347.56824AF4; Fri,  4 May 2012 15:05:09 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q44J59Kf000362; \r
+       Fri, 4 May 2012 15:05:09 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q44J57wP017437\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Fri, 4 May 2012 15:05:08 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SQNoR-0005PT-NA; Fri, 04 May 2012 15:05:07 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Adam Wolfe Gordon <awg+notmuch@xvx.ca>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] emacs: Correctly quote non-text/plain parts in reply\r
+In-Reply-To: <1335056093-17621-3-git-send-email-awg+notmuch@xvx.ca>\r
+References: <1335056093-17621-1-git-send-email-awg+notmuch@xvx.ca>\r
+       <1335056093-17621-3-git-send-email-awg+notmuch@xvx.ca>\r
+User-Agent: Notmuch/0.12+132~gf2f390b (http://notmuchmail.org) Emacs/23.3.1\r
+       (i486-pc-linux-gnu)\r
+Date: Fri, 04 May 2012 15:05:07 -0400\r
+Message-ID: <87obq3ahss.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrEIsWRmVeSWpSXmKPExsUixG6nrpuqscTf4OtVK4sje2axW1y/OZPZ\r
+       gcnj2apbzB5NPxazBjBFcdmkpOZklqUW6dslcGUsnHiYqaBDsaJ310W2BsabUl2MnBwSAiYS\r
+       11ZuZoWwxSQu3FvP1sXIxSEksI9RYsvX/ywQznpGiQl3NjJDOCeYJKZt+M8E4SxhlLi78zE7\r
+       SD+bgIbEtv3LGUFsEQFniS3HXrOB2MICvhIvNp0A28EJFL+wZR1YXEigUuLnnYVMILaoQLzE\r
+       n97NYHEWAVWJ5bc6wep5ge7r+L6QHcIWlDg58wkLiM0soCVx499LpgmMArOQpGYhSS1gZFrF\r
+       KJuSW6Wbm5iZU5yarFucnJiXl1qka6KXm1mil5pSuokRFJSckvw7GL8dVDrEKMDBqMTDm8G7\r
+       xF+INbGsuDL3EKMkB5OSKG+APFCILyk/pTIjsTgjvqg0J7X4EKMEB7OSCG/S18X+QrwpiZVV\r
+       qUX5MClpDhYlcV41rXd+QgLpiSWp2ampBalFMFkZDg4lCd6J6kBDBYtS01Mr0jJzShDSTByc\r
+       IMN5gIYvA6nhLS5IzC3OTIfIn2JUlBLnnQuSEABJZJTmwfXCksYrRnGgV4R5t4NU8QATDlz3\r
+       K6DBTECDpQ0WgQwuSURISTUwSn5wm97gIfSb//Pv2K1ial+37Q8t7Ddojc274/3J6+Oio8f9\r
+       ZhZU85kkcNwqONlnY3qp5/uCE4+zH7ppJxvsSXH6uWbrxJnRm7jXrWmf5Rj7wihh38mXSd+/\r
+       vbFQF4gOOcL6N33d1DtTvrU0vTkWEyF2vdjs9LU/qa/0nORmHtz0PqfnyTXteiWW4oxEQy3m\r
+       ouJEAGjPyyn1AgAA\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: Fri, 04 May 2012 19:05:12 -0000\r
+\r
+Personally I think the narrowing trick is clever, but I worry that it\r
+assumes too much about how mm-display-part works, since mm-display-part\r
+just takes a buffer in the handle.  Is there a reason this doesn't\r
+simply use notmuch-show-mm-display-part-inline?  Something like\r
+(untested)\r
+\r
+(defun notmuch-mua-insert-quotable-part (message part)\r
+  (notmuch-show-mm-display-part-inline \r
+   message part (plist-get part :id) (plist-get part :content-type)))\r
+\r
+You might not even need notmuch-mua-insert-quotable-part.  (Why does\r
+notmuch-show-mm-display-part-inline take all of those redundant\r
+arguments?)\r
+\r
+If there's a reason that doesn't work, I still think it would be better\r
+to use a temporary buffer; something like (untested)\r
+\r
+(defun notmuch-mua-insert-quotable-part (message part)\r
+  (let ((orig-buffer (current-buffer)))\r
+    (notmuch-with-temp-part-buffer message (plist-get part :id)\r
+      (let ((handle ...))\r
+        (with-current-buffer orig-buffer\r
+           (mm-display-part handle))))))\r
+\r
+In general, I feel like the reply code should share more structure with\r
+the notmuch-show code.  I worry that the quoted text people wind up with\r
+may not resemble the text they saw in the show buffer because the two\r
+code paths use different rules.  But addressing that (if it's\r
+addressable) should be done in a later series.\r
+\r
+On Sat, 21 Apr 2012, Adam Wolfe Gordon <awg+notmuch@xvx.ca> wrote:\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r