[BUG/PATCH v3 2/4] emacs: Fix two bugs in reply
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>
Sun, 1 Apr 2012 00:33:22 +0000 (18:33 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:56 +0000 (09:45 -0800)
ec/8568c5127dcf326d395dad65afdc79d0bd86c6 [new file with mode: 0644]

diff --git a/ec/8568c5127dcf326d395dad65afdc79d0bd86c6 b/ec/8568c5127dcf326d395dad65afdc79d0bd86c6
new file mode 100644 (file)
index 0000000..0eb13b2
--- /dev/null
@@ -0,0 +1,149 @@
+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 D81B0421191\r
+       for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 17:33:31 -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 lvrtwSaMJUre for <notmuch@notmuchmail.org>;\r
+       Sat, 31 Mar 2012 17:33:29 -0700 (PDT)\r
+Received: from idcmail-mo1so.shaw.ca (idcmail-mo1so.shaw.ca [24.71.223.10])\r
+       by olra.theworths.org (Postfix) with ESMTP id 71D7E431FAF\r
+       for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 17:33:29 -0700 (PDT)\r
+Received: from pd3ml2so-ssvc.prod.shaw.ca ([10.0.141.138])\r
+       by pd2mo1so-svcs.prod.shaw.ca with ESMTP; 31 Mar 2012 18:33:27 -0600\r
+X-Cloudmark-SP-Filtered: true\r
+X-Cloudmark-SP-Result: v=1.1 cv=w8ylZ/s5/CpB4NtJ57cq/Y3wf+h+jIFeVVN4WVEh/uc=\r
+       c=1 sm=1\r
+       a=SFdlMaQKxd0A:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
+       a=A1X0JdhQAAAA:8 a=7343-z1_AAAA:8 a=EHNZZYlXirAKnDWGDg4A:9\r
+       a=lQqI-tqrjoMthOdKa7UA:7 a=Y6qChIQXU1wA:10 a=0c-eHkXYtrgA:10\r
+       a=FHjBVMKmimTZ8ffj:21 a=1LJpIBYLlS5Vr_m5:21\r
+       a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
+Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
+       by pd3ml2so-dmz.prod.shaw.ca with ESMTP; 31 Mar 2012 18:33:27 -0600\r
+Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
+       id 18DFF800422C; Sat, 31 Mar 2012 18:33:26 -0600 (MDT)\r
+From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+To: notmuch@notmuchmail.org\r
+Subject: [BUG/PATCH v3 2/4] emacs: Fix two bugs in reply\r
+Date: Sat, 31 Mar 2012 18:33:22 -0600\r
+Message-Id: <1333240404-13076-3-git-send-email-awg+notmuch@xvx.ca>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1333240404-13076-1-git-send-email-awg+notmuch@xvx.ca>\r
+References: <1333240404-13076-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, 01 Apr 2012 00:33:32 -0000\r
+\r
+Bug 1: Replying from alternate addresses\r
+----------------------------------------\r
+\r
+The reply code was inconsistent in its use of symbols and strings for\r
+header names being passed to message.el functions. This caused the\r
+>From header to be lookup up incorrectly, causing an additional From\r
+header to be added with the user's primary address instead of the\r
+correct alternate address.\r
+\r
+This is fixed by using symbols everywhere, i.e. never using strings\r
+for header names when interacting with message.el.\r
+\r
+This change also removes our use of `mail-header`, since we don't use\r
+it anywhere else, and using assq makes it clear how the header lists\r
+are expected to work.\r
+\r
+Bug 2: Duplicate headers in emacs 23.2\r
+--------------------------------------\r
+\r
+The message.el code in emacs 23.2 assumes that header names will\r
+always be passed as symbols, so our use of strings caused\r
+problems. The symptom was that on 23.2 (and presumably on earlier\r
+versions) the reply message would end up with two of some headers.\r
+\r
+Converting everything to symbols also fixes this issue.\r
+---\r
+ emacs/notmuch-lib.el |    7 +++++--\r
+ emacs/notmuch-mua.el |   10 +++++-----\r
+ test/emacs           |    1 -\r
+ 3 files changed, 10 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index c146748..0effe24 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -232,9 +232,12 @@ the given type."\r
+   (or (plist-get part :content)\r
+       (notmuch-get-bodypart-internal (concat "id:" (plist-get msg :id)) nth process-crypto)))\r
\r
+-(defun notmuch-plist-to-alist (plist)\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
++(defun notmuch-headers-plist-to-alist (plist)\r
+   (loop for (key value . rest) on plist by #'cddr\r
+-      collect (cons (substring (symbol-name key) 1) value)))\r
++      collect (cons (intern (substring (symbol-name key) 1)) value)))\r
\r
+ ;; Compatibility functions for versions of emacs before emacs 23.\r
+ ;;\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 6aae3a0..cfa3d61 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -127,7 +127,7 @@ list."\r
+         ((same-window-regexps '("\\*mail .*")))\r
+       (notmuch-mua-mail (plist-get reply-headers :To)\r
+                         (plist-get reply-headers :Subject)\r
+-                        (notmuch-plist-to-alist reply-headers)))\r
++                        (notmuch-headers-plist-to-alist reply-headers)))\r
+       ;; Insert the message body - but put it in front of the signature\r
+       ;; if one is present\r
+       (goto-char (point-max))\r
+@@ -185,11 +185,11 @@ OTHER-ARGS are passed through to `message-mail'."\r
+   (when notmuch-mua-user-agent-function\r
+     (let ((user-agent (funcall notmuch-mua-user-agent-function)))\r
+       (when (not (string= "" user-agent))\r
+-      (push (cons "User-Agent" user-agent) other-headers))))\r
++      (push (cons 'User-Agent user-agent) other-headers))))\r
\r
+-  (unless (mail-header 'From other-headers)\r
+-    (push (cons "From" (concat\r
+-                      (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers))\r
++  (unless (assq 'From other-headers)\r
++    (push (cons 'From (concat\r
++                     (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers))\r
\r
+   (apply #'message-mail to subject other-headers other-args)\r
+   (message-sort-headers)\r
+diff --git a/test/emacs b/test/emacs\r
+index 3402efb..06291d3 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -275,7 +275,6 @@ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
\r
+ test_begin_subtest "Reply from alternate address within emacs"\r
+-test_subtest_known_broken\r
+ add_message '[from]="Sender <sender@example.com>"' \\r
+            [to]=test_suite_other@notmuchmail.org\r
\r
+-- \r
+1.7.5.4\r
+\r