[BUG/PATCH v2 2/2] emacs: Fix replying from alternate addresses
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>
Wed, 28 Mar 2012 13:33:55 +0000 (07:33 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:49 +0000 (09:45 -0800)
3f/6938bf43bc41afecf311d4fa4895bca2b0a91f [new file with mode: 0644]

diff --git a/3f/6938bf43bc41afecf311d4fa4895bca2b0a91f b/3f/6938bf43bc41afecf311d4fa4895bca2b0a91f
new file mode 100644 (file)
index 0000000..8d93b1e
--- /dev/null
@@ -0,0 +1,110 @@
+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 DA167431FBF\r
+       for <notmuch@notmuchmail.org>; Wed, 28 Mar 2012 06:33:59 -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 RORpNxCYrT3G for <notmuch@notmuchmail.org>;\r
+       Wed, 28 Mar 2012 06:33:59 -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 08AA5431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 28 Mar 2012 06:33:58 -0700 (PDT)\r
+Received: from pd2ml2so-ssvc.prod.shaw.ca ([10.0.141.134])\r
+       by pd2mo1so-svcs.prod.shaw.ca with ESMTP; 28 Mar 2012 07:33:58 -0600\r
+X-Cloudmark-SP-Filtered: true\r
+X-Cloudmark-SP-Result: v=1.1 cv=FBhiVrZmCxhz+jlnxOWeJaR14+PwdUeacMZGNnSzbtQ=\r
+       c=1 sm=1\r
+       a=orNGVW25YFkA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
+       a=A1X0JdhQAAAA:8 a=7343-z1_AAAA:8 a=kruYVQ-tQJgX6LSJxeAA:9\r
+       a=ErgTTcISGBnhqq40-fwA:7 a=Y6qChIQXU1wA:10 a=0c-eHkXYtrgA:10\r
+       a=WJfXdXBIiwVsjGxf:21 a=TlY5ANsmuuyg24_V:21\r
+       a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
+Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
+       by pd2ml2so-dmz.prod.shaw.ca with ESMTP; 28 Mar 2012 07:33:58 -0600\r
+Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
+       id DE38B800422C; Wed, 28 Mar 2012 07:33:57 -0600 (MDT)\r
+From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+To: notmuch@notmuchmail.org\r
+Subject: [BUG/PATCH v2 2/2] emacs: Fix replying from alternate addresses\r
+Date: Wed, 28 Mar 2012 07:33:55 -0600\r
+Message-Id: <1332941635-21019-3-git-send-email-awg+notmuch@xvx.ca>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1332941635-21019-1-git-send-email-awg+notmuch@xvx.ca>\r
+References: <1332635232-15269-1-git-send-email-awg+notmuch@xvx.ca>\r
+       <1332941635-21019-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: Wed, 28 Mar 2012 13:34:00 -0000\r
+\r
+The bug was that notmuch-mua-mail used `mail-header` to check whether\r
+it was passed a "From" header. The implementation of `mail-header`\r
+must try to compare symbols instead of strings when looking for\r
+headers, as it was returning nil when a From header was present. This\r
+is probably because the mail functions construct headers as alists\r
+with symbols for the header names, while our code uses strings for the\r
+header names.\r
+\r
+Since we don't use `mail-header` anywhere else, and `message-mail` is\r
+perfectly happy to accept string header names, the fix is just to use\r
+`assoc` to look for the From header, so that the strings get compared\r
+properly.\r
+---\r
+ emacs/notmuch-mua.el |    4 ++--\r
+ test/emacs           |    1 -\r
+ 2 files changed, 2 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 6aae3a0..9805d79 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -187,7 +187,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
+       (when (not (string= "" user-agent))\r
+       (push (cons "User-Agent" user-agent) other-headers))))\r
\r
+-  (unless (mail-header 'From other-headers)\r
++  (unless (assoc "From" other-headers)\r
+     (push (cons "From" (concat\r
+                       (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers))\r
\r
+@@ -250,7 +250,7 @@ the From: address first."\r
+   (interactive "P")\r
+   (let ((other-headers\r
+        (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
+-         (list (cons 'From (notmuch-mua-prompt-for-sender))))))\r
++         (list (cons "From" (notmuch-mua-prompt-for-sender))))))\r
+     (notmuch-mua-mail nil nil other-headers)))\r
\r
+ (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\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