From e29819b4fecc4cb1fbfeaf340f83be91a284e2aa Mon Sep 17 00:00:00 2001 From: Adam Wolfe Gordon Date: Sun, 25 Mar 2012 18:27:12 +1800 Subject: [PATCH] [BUG/PATCH 2/2] emacs: Fix replying from alternate addresses --- a9/97cbd5739f8e177082d9ebe92c676a91cbbade | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 a9/97cbd5739f8e177082d9ebe92c676a91cbbade diff --git a/a9/97cbd5739f8e177082d9ebe92c676a91cbbade b/a9/97cbd5739f8e177082d9ebe92c676a91cbbade new file mode 100644 index 000000000..5739a0b74 --- /dev/null +++ b/a9/97cbd5739f8e177082d9ebe92c676a91cbbade @@ -0,0 +1,109 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 23947431FB6 + for ; Sat, 24 Mar 2012 17:27:21 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id f6jFaa8SCuM1 for ; + Sat, 24 Mar 2012 17:27:20 -0700 (PDT) +Received: from idcmail-mo1so.shaw.ca (idcmail-mo1so.shaw.ca [24.71.223.10]) + by olra.theworths.org (Postfix) with ESMTP id 91091431FAF + for ; Sat, 24 Mar 2012 17:27:20 -0700 (PDT) +Received: from pd2ml3so-ssvc.prod.shaw.ca ([10.0.141.148]) + by pd3mo1so-svcs.prod.shaw.ca with ESMTP; 24 Mar 2012 18:27:19 -0600 +X-Cloudmark-SP-Filtered: true +X-Cloudmark-SP-Result: v=1.1 cv=W+ZrOcpwHTeQLvZQ9vbIxXRdvbK5p6H2/T6SuQCN924= + c=1 sm=1 + a=h0XYkkGVRQAA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17 + a=A1X0JdhQAAAA:8 a=7343-z1_AAAA:8 a=kruYVQ-tQJgX6LSJxeAA:9 + a=ErgTTcISGBnhqq40-fwA:7 a=Y6qChIQXU1wA:10 a=0c-eHkXYtrgA:10 + a=6DQpROzzP55a9Xli:21 a=buo2DCiuL2TCTNuT:21 + a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 +Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56]) + by pd2ml3so-dmz.prod.shaw.ca with ESMTP; 24 Mar 2012 18:27:19 -0600 +Received: by lagos.xvx.ca (Postfix, from userid 1000) + id 1EAE0800482B; Sat, 24 Mar 2012 18:27:19 -0600 (MDT) +From: Adam Wolfe Gordon +To: notmuch@notmuchmail.org +Subject: [BUG/PATCH 2/2] emacs: Fix replying from alternate addresses +Date: Sat, 24 Mar 2012 18:27:12 -0600 +Message-Id: <1332635232-15269-3-git-send-email-awg+notmuch@xvx.ca> +X-Mailer: git-send-email 1.7.5.4 +In-Reply-To: <1332635232-15269-1-git-send-email-awg+notmuch@xvx.ca> +References: <1332635232-15269-1-git-send-email-awg+notmuch@xvx.ca> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 25 Mar 2012 00:27:21 -0000 + +The bug was that notmuch-mua-mail used `mail-header` to check whether +it was passed a "From" header. The implementation of `mail-header` +must try to compare symbols instead of strings when looking for +headers, as it was returning nil when a From header was present. This +is probably because the mail functions construct headers as alists +with symbols for the header names, while our code uses strings for the +header names. + +Since we don't use `mail-header` anywhere else, and `message-mail` is +perfectly happy to accept string header names, the fix is just to use +`assoc` to look for the From header, so that the strings get compared +properly. +--- + emacs/notmuch-mua.el | 4 ++-- + test/emacs | 1 - + 2 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +index 6aae3a0..9805d79 100644 +--- a/emacs/notmuch-mua.el ++++ b/emacs/notmuch-mua.el +@@ -187,7 +187,7 @@ OTHER-ARGS are passed through to `message-mail'." + (when (not (string= "" user-agent)) + (push (cons "User-Agent" user-agent) other-headers)))) + +- (unless (mail-header 'From other-headers) ++ (unless (assoc "From" other-headers) + (push (cons "From" (concat + (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers)) + +@@ -250,7 +250,7 @@ the From: address first." + (interactive "P") + (let ((other-headers + (when (or prompt-for-sender notmuch-always-prompt-for-sender) +- (list (cons 'From (notmuch-mua-prompt-for-sender)))))) ++ (list (cons "From" (notmuch-mua-prompt-for-sender)))))) + (notmuch-mua-mail nil nil other-headers))) + + (defun notmuch-mua-new-forward-message (&optional prompt-for-sender) +diff --git a/test/emacs b/test/emacs +index fa5d706..08db1ee 100755 +--- a/test/emacs ++++ b/test/emacs +@@ -275,7 +275,6 @@ EOF + test_expect_equal_file OUTPUT EXPECTED + + test_begin_subtest "Reply from alternate address within emacs" +-test_subtest_known_broken + add_message '[from]="Sender "' \ + [to]=test_suite_other@notmuchmail.org \ + [subject]=notmuch-reply-test \ +-- +1.7.5.4 + -- 2.26.2