From cd694cd6f5ce727fbe4a488cb71f668b56509854 Mon Sep 17 00:00:00 2001 From: Adam Wolfe Gordon Date: Mon, 2 Apr 2012 09:24:21 +1800 Subject: [PATCH] [BUG/PATCH v4 2/4] emacs: Fix two bugs in reply --- 04/f00400e3cc5d4d8935fa968365974678893a71 | 151 ++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 04/f00400e3cc5d4d8935fa968365974678893a71 diff --git a/04/f00400e3cc5d4d8935fa968365974678893a71 b/04/f00400e3cc5d4d8935fa968365974678893a71 new file mode 100644 index 000000000..53154132d --- /dev/null +++ b/04/f00400e3cc5d4d8935fa968365974678893a71 @@ -0,0 +1,151 @@ +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 5395F421183 + for ; Sun, 1 Apr 2012 08:24:30 -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 WiwHSYmRGWOW for ; + Sun, 1 Apr 2012 08:24:29 -0700 (PDT) +Received: from idcmail-mo2no.shaw.ca (idcmail-mo2no.shaw.ca [64.59.134.9]) + by olra.theworths.org (Postfix) with ESMTP id 157FD429E54 + for ; Sun, 1 Apr 2012 08:24:29 -0700 (PDT) +Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd5ml1no-ssvc.prod.shaw.ca) + ([10.0.144.222]) + by pd7mo1no-svcs.prod.shaw.ca with ESMTP; 01 Apr 2012 09:24:28 -0600 +X-Cloudmark-SP-Filtered: true +X-Cloudmark-SP-Result: v=1.1 cv=bD0CuDYpMgGTku+nVSbZuKP/9fNjspX1F8zuwcoBWhM= + c=1 sm=1 + a=RGYJgmOjA4MA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17 + a=A1X0JdhQAAAA:8 a=7343-z1_AAAA:8 a=EHNZZYlXirAKnDWGDg4A:9 + a=lQqI-tqrjoMthOdKa7UA:7 a=Y6qChIQXU1wA:10 a=0c-eHkXYtrgA:10 + a=wGuX00AKz6gQ6_xQ:21 a=5F3Wtl96xUNS4dUm:21 + a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 +Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56]) + by pd5ml1no-dmz.prod.shaw.ca with ESMTP; 01 Apr 2012 09:24:27 -0600 +Received: by lagos.xvx.ca (Postfix, from userid 1000) + id D7F86800422D; Sun, 1 Apr 2012 09:24:26 -0600 (MDT) +From: Adam Wolfe Gordon +To: notmuch@notmuchmail.org +Subject: [BUG/PATCH v4 2/4] emacs: Fix two bugs in reply +Date: Sun, 1 Apr 2012 09:24:21 -0600 +Message-Id: <1333293863-14361-3-git-send-email-awg+notmuch@xvx.ca> +X-Mailer: git-send-email 1.7.5.4 +In-Reply-To: <1333293863-14361-1-git-send-email-awg+notmuch@xvx.ca> +References: <1333240404-13076-1-git-send-email-awg+notmuch@xvx.ca> + <1333293863-14361-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, 01 Apr 2012 15:24:30 -0000 + +Bug 1: Replying from alternate addresses +---------------------------------------- + +The reply code was inconsistent in its use of symbols and strings for +header names being passed to message.el functions. This caused the +>From header to be lookup up incorrectly, causing an additional From +header to be added with the user's primary address instead of the +correct alternate address. + +This is fixed by using symbols everywhere, i.e. never using strings +for header names when interacting with message.el. + +This change also removes our use of `mail-header`, since we don't use +it anywhere else, and using assq makes it clear how the header lists +are expected to work. + +Bug 2: Duplicate headers in emacs 23.2 +-------------------------------------- + +The message.el code in emacs 23.2 assumes that header names will +always be passed as symbols, so our use of strings caused +problems. The symptom was that on 23.2 (and presumably on earlier +versions) the reply message would end up with two of some headers. + +Converting everything to symbols also fixes this issue. +--- + emacs/notmuch-lib.el | 7 +++++-- + emacs/notmuch-mua.el | 10 +++++----- + test/emacs | 1 - + 3 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index c159dda..6907a5f 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -237,9 +237,12 @@ the given type." + (or (plist-get part :content) + (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) nth process-crypto))) + +-(defun notmuch-plist-to-alist (plist) ++;; Converts a plist of headers to an alist of headers. The input plist should ++;; have symbols of the form :Header as keys, and the resulting alist will have ++;; symbols of the form 'Header as keys. ++(defun notmuch-headers-plist-to-alist (plist) + (loop for (key value . rest) on plist by #'cddr +- collect (cons (substring (symbol-name key) 1) value))) ++ collect (cons (intern (substring (symbol-name key) 1)) value))) + + ;; Compatibility functions for versions of emacs before emacs 23. + ;; +diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +index 6aae3a0..cfa3d61 100644 +--- a/emacs/notmuch-mua.el ++++ b/emacs/notmuch-mua.el +@@ -127,7 +127,7 @@ list." + ((same-window-regexps '("\\*mail .*"))) + (notmuch-mua-mail (plist-get reply-headers :To) + (plist-get reply-headers :Subject) +- (notmuch-plist-to-alist reply-headers))) ++ (notmuch-headers-plist-to-alist reply-headers))) + ;; Insert the message body - but put it in front of the signature + ;; if one is present + (goto-char (point-max)) +@@ -185,11 +185,11 @@ OTHER-ARGS are passed through to `message-mail'." + (when notmuch-mua-user-agent-function + (let ((user-agent (funcall notmuch-mua-user-agent-function))) + (when (not (string= "" user-agent)) +- (push (cons "User-Agent" user-agent) other-headers)))) ++ (push (cons 'User-Agent user-agent) other-headers)))) + +- (unless (mail-header 'From other-headers) +- (push (cons "From" (concat +- (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers)) ++ (unless (assq 'From other-headers) ++ (push (cons 'From (concat ++ (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers)) + + (apply #'message-mail to subject other-headers other-args) + (message-sort-headers) +diff --git a/test/emacs b/test/emacs +index 576bc1f..30654bb 100755 +--- a/test/emacs ++++ b/test/emacs +@@ -286,7 +286,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 + +-- +1.7.5.4 + -- 2.26.2