1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 20FBA431FD8
\r
6 for <notmuch@notmuchmail.org>; Thu, 20 Feb 2014 11:17:25 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 4ZzhO0ASWFuq for <notmuch@notmuchmail.org>;
\r
16 Thu, 20 Feb 2014 11:17:21 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 45A6D431FD9
\r
22 for <notmuch@notmuchmail.org>; Thu, 20 Feb 2014 11:16:56 -0800 (PST)
\r
23 X-AuditID: 1209190f-f790b6d000000c3a-e0-530654a7ec8d
\r
24 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
25 (using TLS with cipher AES256-SHA (256/256 bits))
\r
26 (Client did not present a certificate)
\r
27 by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id B4.71.03130.7A456035; Thu, 20 Feb 2014 14:16:55 -0500 (EST)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s1KJGhuo014147;
\r
31 Thu, 20 Feb 2014 14:16:43 -0500
\r
32 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])
\r
33 (authenticated bits=0)
\r
34 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
35 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s1KJGfVH012828
\r
36 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
37 Thu, 20 Feb 2014 14:16:42 -0500
\r
38 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
39 (envelope-from <amdragon@mit.edu>)
\r
40 id 1WGZ6v-0004Z6-1T; Thu, 20 Feb 2014 14:16:41 -0500
\r
41 From: Austin Clements <amdragon@MIT.EDU>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 1/4] emacs: Build forwarded message buffer more directly
\r
44 Date: Thu, 20 Feb 2014 14:16:34 -0500
\r
45 Message-Id: <1392923797-17045-2-git-send-email-amdragon@mit.edu>
\r
46 X-Mailer: git-send-email 1.8.4.rc3
\r
47 In-Reply-To: <1392923797-17045-1-git-send-email-amdragon@mit.edu>
\r
48 References: <1392923797-17045-1-git-send-email-amdragon@mit.edu>
\r
49 X-Brightmail-Tracker:
\r
50 H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixCmqrLs8hC3Y4ORCMYvXCyaxWVy/OZPZ
\r
51 gclj9dpOFo9nq24xBzBFcdmkpOZklqUW6dslcGW8fj+TvWCebMXF509YGhg3S3QxcnJICJhI
\r
52 vF3UzgJhi0lcuLeerYuRi0NIYDaTRM/TuUwQzkZGifvzTkE5R5gk5m1dDlU2l1HiwYw5YP1s
\r
53 AhoS2/YvZwSxRQSkJXbenc0KYjML2Ehs/vgYLC4s4CHxs+8QmM0ioCpxY/NpMJtXwEHi2II3
\r
54 jBB3KEksPLUNrJdTwFFiaf8HIJsDaJmDROdWnQmM/AsYGVYxyqbkVunmJmbmFKcm6xYnJ+bl
\r
55 pRbpmujlZpbopaaUbmIEh5Ik/w7GbweVDjEKcDAq8fCekGILFmJNLCuuzD3EKMnBpCTKuyIA
\r
56 KMSXlJ9SmZFYnBFfVJqTWnyIUYKDWUmEt8kGKMebklhZlVqUD5OS5mBREuettfgVJCSQnliS
\r
57 mp2aWpBaBJOV4eBQkuD1AMaMkGBRanpqRVpmTglCmomDE2Q4D9DwfcEgw4sLEnOLM9Mh8qcY
\r
58 FaXEeV1AmgVAEhmleXC9sFh/xSgO9IowbxBIFQ8wTcB1vwIazAQ0uGQjK8jgkkSElFQDo4r9
\r
59 G+GUfz4l2a7Om3MO7bf7NnMmZ+r2XYqvtl5wly2WFjvoZJI+4eaORfO7Jx/YOGPWzRTZDKm/
\r
60 woeOXck7H80quqpe0Oanxtfd4lsvHlDnijTc6/rikoXFZlvVrwfiVkaq1HsFeAleal3GJSa2
\r
61 YlrJj4x9joUW52Y9OzLLuevbboVDf5ZI2SuxFGckGmoxFxUnAgAdlMeP0AIAAA==
\r
62 Cc: bjonnh-nm@bjonnh.net
\r
63 X-BeenThere: notmuch@notmuchmail.org
\r
64 X-Mailman-Version: 2.1.13
\r
66 List-Id: "Use and development of the notmuch mail system."
\r
67 <notmuch.notmuchmail.org>
\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
71 List-Post: <mailto:notmuch@notmuchmail.org>
\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
75 X-List-Received-Date: Thu, 20 Feb 2014 19:17:25 -0000
\r
77 Previously, we used `message-forward' to build forwarded messages, but
\r
78 this function is simply too high-level to be a good fit for some of
\r
81 First, since `message-forward' builds a full forward message buffer
\r
82 given the message to forward, we have to duplicate much of the logic
\r
83 in `notmuch-mua-mail' to patch the notmuch-y things into the built
\r
86 Second, `message-forward' constructs the From header from
\r
87 user-full-name and user-mail-address. As a result, if we prompt the
\r
88 user for an identity, we have to parse it into name and address
\r
89 components, just to have it put back together by `message-forward'.
\r
90 This process is not entirely loss-less because
\r
91 `mail-extract-address-components' does a lot of canonicalization
\r
92 (since it's intended for displaying addresses, not for parsing them).
\r
94 To fix these problems, don't use `message-forward' at all.
\r
95 `message-forward' itself is basically just a call to `message-mail'
\r
96 and `message-forward-make-body'. Do this ourselves, but call
\r
97 `notmuch-mua-mail' instead of `message-mail' so we can directly build
\r
98 a notmuch-y message and control the From header.
\r
100 This also fixes a bug that was a direct consequence of our use of
\r
101 `mail-extract-address-components': if the user chose an identity that
\r
102 had no name part (or the name part matched the mailbox), we would bind
\r
103 user-full-name to nil, which would cause an exception in the bowels of
\r
104 message-mode because user-full-name is expected to always be a string
\r
105 (even if it's just "").
\r
107 emacs/notmuch-mua.el | 33 +++++++++++----------------------
\r
108 1 file changed, 11 insertions(+), 22 deletions(-)
\r
110 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
\r
111 index 481abd7..f2df770 100644
\r
112 --- a/emacs/notmuch-mua.el
\r
113 +++ b/emacs/notmuch-mua.el
\r
114 @@ -231,21 +231,6 @@ list."
\r
115 (message-goto-body)
\r
116 (set-buffer-modified-p nil))
\r
118 -(defun notmuch-mua-forward-message ()
\r
119 - (funcall (notmuch-mua-get-switch-function) (current-buffer))
\r
120 - (message-forward)
\r
122 - (when notmuch-mua-user-agent-function
\r
123 - (let ((user-agent (funcall notmuch-mua-user-agent-function)))
\r
124 - (when (not (string= "" user-agent))
\r
125 - (message-add-header (format "User-Agent: %s" user-agent)))))
\r
126 - (message-sort-headers)
\r
127 - (message-hide-headers)
\r
128 - (set-buffer-modified-p nil)
\r
129 - (notmuch-mua-maybe-set-window-dedicated)
\r
131 - (message-goto-to))
\r
133 (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)
\r
134 "Invoke the notmuch mail composition window.
\r
136 @@ -345,13 +330,17 @@ The current buffer must contain an RFC2822 message to forward.
\r
138 If PROMPT-FOR-SENDER is non-nil, the user will be prompted for
\r
139 the From: address first."
\r
140 - (if (or prompt-for-sender notmuch-always-prompt-for-sender)
\r
141 - (let* ((sender (notmuch-mua-prompt-for-sender))
\r
142 - (address-components (mail-extract-address-components sender))
\r
143 - (user-full-name (car address-components))
\r
144 - (user-mail-address (cadr address-components)))
\r
145 - (notmuch-mua-forward-message))
\r
146 - (notmuch-mua-forward-message)))
\r
147 + (let* ((cur (current-buffer))
\r
148 + (message-forward-decoded-p nil)
\r
149 + (subject (message-make-forward-subject))
\r
151 + (when (or prompt-for-sender notmuch-always-prompt-for-sender)
\r
152 + (list (cons 'From (notmuch-mua-prompt-for-sender))))))
\r
153 + (notmuch-mua-mail nil subject other-headers nil (notmuch-mua-get-switch-function))
\r
154 + (message-forward-make-body cur)
\r
155 + ;; `message-forward-make-body' shows the User-agent header. Hide
\r
157 + (message-hide-headers)))
\r
159 (defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all)
\r
160 "Compose a reply to the message identified by QUERY-STRING.
\r