]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Fix two bugs in reply
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>
Sun, 1 Apr 2012 15:24:21 +0000 (09:24 -0600)
committerDavid Bremner <bremner@debian.org>
Mon, 2 Apr 2012 20:45:27 +0000 (17:45 -0300)
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
emacs/notmuch-mua.el
test/emacs

index c159dda9695b88f4e541a10bf3be999c49f19246..6907a5f910b4e33b8efc9f6d65bee3708a1a2c82 100644 (file)
@@ -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.
 ;;
index 6aae3a0578f6651a54758cc459476782f0b0a9fd..cfa3d613890fffc718b9da09faaa4e8e4e23d3f5 100644 (file)
@@ -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)
index 576bc1f050f3f4ac4e92628946f50f9a765c21a6..30654bb90e8cd23bfe66f14e6dff4c9cae288cf3 100755 (executable)
@@ -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 <sender@example.com>"' \
             [to]=test_suite_other@notmuchmail.org