[BUG/PATCH v4 2/4] emacs: Fix two bugs in reply
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>
Sun, 1 Apr 2012 15:24:21 +0000 (09:24 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:57 +0000 (09:45 -0800)
04/f00400e3cc5d4d8935fa968365974678893a71 [new file with mode: 0644]

diff --git a/04/f00400e3cc5d4d8935fa968365974678893a71 b/04/f00400e3cc5d4d8935fa968365974678893a71
new file mode 100644 (file)
index 0000000..5315413
--- /dev/null
@@ -0,0 +1,151 @@
+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 5395F421183\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Apr 2012 08:24:30 -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 WiwHSYmRGWOW for <notmuch@notmuchmail.org>;\r
+       Sun,  1 Apr 2012 08:24:29 -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 157FD429E54\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Apr 2012 08:24:29 -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; 01 Apr 2012 09:24:28 -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=RGYJgmOjA4MA: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=wGuX00AKz6gQ6_xQ:21 a=5F3Wtl96xUNS4dUm:21\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; 01 Apr 2012 09:24:27 -0600\r
+Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
+       id D7F86800422D; Sun,  1 Apr 2012 09:24:26 -0600 (MDT)\r
+From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+To: notmuch@notmuchmail.org\r
+Subject: [BUG/PATCH v4 2/4] emacs: Fix two bugs in reply\r
+Date: Sun,  1 Apr 2012 09:24:21 -0600\r
+Message-Id: <1333293863-14361-3-git-send-email-awg+notmuch@xvx.ca>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1333293863-14361-1-git-send-email-awg+notmuch@xvx.ca>\r
+References: <1333240404-13076-1-git-send-email-awg+notmuch@xvx.ca>\r
+       <1333293863-14361-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 15:24:30 -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 c159dda..6907a5f 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -237,9 +237,12 @@ 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-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 576bc1f..30654bb 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -286,7 +286,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