[PATCH v5 3/7] emacs/mua: Generate improved cited text for replies
authorMark Walters <markwalters1009@gmail.com>
Sun, 14 Feb 2016 18:39:55 +0000 (18:39 +0000)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:07 +0000 (16:21 -0700)
9c/94653253e0437a6b90ac2e18f52d5fa77f1c1f [new file with mode: 0644]

diff --git a/9c/94653253e0437a6b90ac2e18f52d5fa77f1c1f b/9c/94653253e0437a6b90ac2e18f52d5fa77f1c1f
new file mode 100644 (file)
index 0000000..c689239
--- /dev/null
@@ -0,0 +1,148 @@
+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 arlo.cworth.org (Postfix) with ESMTP id 74E046DE1AC9\r
+ for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:25 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.246\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.246 tagged_above=-999 required=5 tests=[AWL=0.324,\r
+  DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id fKeVQVrWHz6d for <notmuch@notmuchmail.org>;\r
+ Sun, 14 Feb 2016 10:40:23 -0800 (PST)\r
+Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
+ [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id D7BC46DE1A2F for\r
+ <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:19 -0800 (PST)\r
+Received: by mail-wm0-f66.google.com with SMTP id b205so4795550wmb.1\r
+ for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:19 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=SLPZtgUXjVnynhWVP1tT8bXXJa+S2YrOZeXC6uMpJBU=;\r
+ b=yXX4ChvnYs/EoVFa12gVObwBMABh0wWGPkXDQRBBRc0hPkRSzR+GPVex9Yap8X3DjP\r
+ mSQ6rz61dzeWdxZvtRaeFLPQKTfOGz6fKPUe6fLEbPjIh+hKkmcheoxImDck+LE5axF9\r
+ rf9Bd/tSFpO5ruTDNc4PplKJuA+p6vqy76r1UVr8dZ9epcHsNh1yDcLuIdZZ2UINBiPH\r
+ 4xiZA4BTkjXNMoAXrH6dOSNvgzNbDiiJklHRYjNXoAdsMVuo7Jjn0MgEVP+3J0ydOH+V\r
+ YPPqYyDwbHxlBijbAtRSsU2EhBnUPBVZO1mFVUVZeojjPGaqDKiDdO32eDgmky49crX6\r
+ GUHw==\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:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=SLPZtgUXjVnynhWVP1tT8bXXJa+S2YrOZeXC6uMpJBU=;\r
+ b=CmkIjwwR76/Rv01bZ8FL6fRla9CLKSHvyCpo3hogQoIHLZ5lIDHUw/68h5N2sh6/iD\r
+ fzqtmOxCkCFCBa2OFrbBivn0gNzxG1GwG0BSdogz4EjFHsd6l2DqT+ElZ0lIdXYdYVN3\r
+ qtHUM9xEQhNsO79KpGKP+C2IqfQgf5WVZ0BMwu4WgIql/1sj/oirucNSL49jGxsJ2J5P\r
+ 5tY9NOGqU1Nd1eJVf8qne61/K8Dc/PhC+gdfkQZosS6Xy7ePm9h0dEffNbbkMSom1ilm\r
+ yPn/XiOyif0SPQ5YQyFYwfPfBjfmdOHBqqB3jk6VNKA3dv1mHAbyC1CH1nblSUWNNuEk\r
+ Bcig==\r
+X-Gm-Message-State:\r
+ AG10YORQEKkqz1ll6yfksjXSPKh27ah0aW9E70M0nKqsEL8O7wcapRsYqx/144XCiZhtJw==\r
+X-Received: by 10.195.12.113 with SMTP id ep17mr11795496wjd.102.1455475218586;\r
+  Sun, 14 Feb 2016 10:40:18 -0800 (PST)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id e77sm12107568wma.18.2016.02.14.10.40.17\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sun, 14 Feb 2016 10:40:18 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v5 3/7] emacs/mua: Generate improved cited text for replies\r
+Date: Sun, 14 Feb 2016 18:39:55 +0000\r
+Message-Id: <1455475199-32622-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1455475199-32622-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1455475199-32622-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 14 Feb 2016 18:40:25 -0000\r
+\r
+From: David Edmondson <dme@dme.org>\r
+\r
+Use the message display code to generate message text to cite in\r
+replies.\r
+---\r
+ emacs/notmuch-mua.el | 38 ++++++++------------------------------\r
+ 1 file changed, 8 insertions(+), 30 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index d4fad7b..a386d43 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -28,7 +28,7 @@\r
\r
+ (eval-when-compile (require 'cl))\r
\r
+-(declare-function notmuch-show-insert-bodypart "notmuch-show" (msg part depth &optional hide))\r
++(declare-function notmuch-show-insert-body "notmuch-show" (msg body depth))\r
+ (declare-function notmuch-fcc-header-setup "notmuch-maildir-fcc" ())\r
+ (declare-function notmuch-fcc-handler "notmuch-maildir-fcc" (destdir))\r
\r
+@@ -144,31 +144,6 @@ Note that these functions use `mail-citation-hook' if that is non-nil."\r
+       else if (notmuch-match-content-type (plist-get part :content-type) "multipart/*")\r
+         do (notmuch-mua-reply-crypto (plist-get part :content))))\r
\r
+-(defun notmuch-mua-get-quotable-parts (parts)\r
+-  (loop for part in parts\r
+-      if (notmuch-match-content-type (plist-get part :content-type) "multipart/alternative")\r
+-        collect (let* ((subparts (plist-get part :content))\r
+-                      (types (mapcar (lambda (part) (plist-get part :content-type)) subparts))\r
+-                      (chosen-type (car (notmuch-multipart/alternative-choose types))))\r
+-                 (loop for part in (reverse subparts)\r
+-                       if (notmuch-match-content-type (plist-get part :content-type) chosen-type)\r
+-                       return part))\r
+-      else if (notmuch-match-content-type (plist-get part :content-type) "multipart/*")\r
+-        append (notmuch-mua-get-quotable-parts (plist-get part :content))\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
+-  ;; We don't want text properties leaking from the show renderer into\r
+-  ;; the reply so we use a temp buffer. Also we don't want hooks, such\r
+-  ;; as notmuch-wash-*, to be run on the quotable part so we set\r
+-  ;; notmuch-show-insert-text/plain-hook to nil.\r
+-  (insert (with-temp-buffer\r
+-          (let ((notmuch-show-insert-text/plain-hook nil))\r
+-            ;; Show the part but do not add buttons.\r
+-            (notmuch-show-insert-bodypart message part 0 'no-buttons))\r
+-          (buffer-substring-no-properties (point-min) (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
+@@ -247,10 +222,13 @@ Note that these functions use `mail-citation-hook' if that is non-nil."\r
+       (insert "From: " from "\n")\r
+       (insert "Date: " date "\n\n")\r
\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 (apply-partially 'notmuch-mua-insert-quotable-part original) quotable-parts))\r
++      (insert (with-temp-buffer\r
++                ;; Don't attempt to clean up messages, excerpt\r
++                ;; citations, etc. in the original message before\r
++                ;; quoting.\r
++                (let ((notmuch-show-insert-text/plain-hook nil))\r
++                  (notmuch-show-insert-body original (plist-get original :body) 0)\r
++                  (buffer-substring-no-properties (point-min) (point-max)))))\r
\r
+       (set-mark (point))\r
+       (goto-char start)\r
+-- \r
+2.1.4\r
+\r