[PATCH 1/7] cli/reply: push notmuch reply format abstraction lower in the stack
[notmuch-archives.git] / e5 / e2142501b352b6dcaadbe3240a2fbe912ed60d
1 Return-Path: <m.walters@qmul.ac.uk>\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 BAC00431FAF\r
6         for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 02:13:46 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id fO4cbGedxEYX for <notmuch@notmuchmail.org>;\r
17         Sat, 31 Mar 2012 02:13:46 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\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 CCE66431FAE\r
22         for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 02:13:45 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1SDuNU-0000Ks-1z; Sat, 31 Mar 2012 10:13:44 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1SDuNT-0001LC-L3; Sat, 31 Mar 2012 10:13:43 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Adam Wolfe Gordon <awg+notmuch@xvx.ca>, notmuch@notmuchmail.org\r
34 Subject: Re: [BUG/PATCH v2 1/2] emacs: Fix header problem in reply for emacs\r
35         23.2\r
36 In-Reply-To: <1333038410-17927-2-git-send-email-awg+notmuch@xvx.ca>\r
37 References: <1333038410-17927-1-git-send-email-awg+notmuch@xvx.ca>\r
38         <1333038410-17927-2-git-send-email-awg+notmuch@xvx.ca>\r
39 User-Agent: Notmuch/0.12+65~g8bf1842 (http://notmuchmail.org) Emacs/23.3.1\r
40         (x86_64-pc-linux-gnu)\r
41 Date: Sat, 31 Mar 2012 10:13:53 +0100\r
42 Message-ID: <87k42116b2.fsf@qmul.ac.uk>\r
43 MIME-Version: 1.0\r
44 Content-Type: text/plain; charset=us-ascii\r
45 X-Sender-Host-Address: 94.192.233.223\r
46 X-QM-SPAM-Info: Sender has good ham record.  :)\r
47 X-QM-Body-MD5: f595d6809c5f3991d98c43a8d9f4ce2c (of first 20000 bytes)\r
48 X-SpamAssassin-Score: -1.8\r
49 X-SpamAssassin-SpamBar: -\r
50 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
51         determine if it is\r
52         spam. We require at least 5.0 points to mark a message as spam.\r
53         This message scored -1.8 points.\r
54         Summary of the scoring: \r
55         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
56         *      medium trust\r
57         *      [138.37.6.40 listed in list.dnswl.org]\r
58         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
59         provider *      (markwalters1009[at]gmail.com)\r
60         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
61         *      domain\r
62         *  0.5 AWL AWL: From: address is in the auto white-list\r
63 X-QM-Scan-Virus: ClamAV says the message is clean\r
64 X-BeenThere: notmuch@notmuchmail.org\r
65 X-Mailman-Version: 2.1.13\r
66 Precedence: list\r
67 List-Id: "Use and development of the notmuch mail system."\r
68         <notmuch.notmuchmail.org>\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
72 List-Post: <mailto:notmuch@notmuchmail.org>\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
76 X-List-Received-Date: Sat, 31 Mar 2012 09:13:46 -0000\r
77 \r
78 Adam Wolfe Gordon <awg+notmuch@xvx.ca> writes:\r
79 \r
80 > The new reply code used strings instead of symbols for header names,\r
81 > which message-mail is OK with on emacs 23.3, but not 23.2. The symptom\r
82 > is that on 23.2 (and presumably on earlier versions) the reply message\r
83 > would end up with two of some headers.\r
84 >\r
85 > This fixes the problem by converting the header names to symbols of\r
86 > the type message.el usually expects before passing the headers to\r
87 > message-mail.\r
88 \r
89 A few minor comments:\r
90 \r
91 I think this code applies on top of   \r
92   id:"1332941635-21019-2-git-send-email-awg+notmuch@xvx.ca" and \r
93   id:"1332941635-21019-3-git-send-email-awg+notmuch@xvx.ca"\r
94 \r
95 Secondly it seems a little odd that the second patch above changes the\r
96 header stuff from 'From to "From" and then this patch changes it back\r
97 again. This is probably only a matter of a tidy history but I have to\r
98 admit I am confused about why the reply from alternate address still\r
99 works (but it does seem to)\r
100 \r
101 Finally, there is a trailing white-space in the second patch in this\r
102 series.\r
103 \r
104 Best wishes\r
105 \r
106 Mark\r
107 \r
108 > ---\r
109 >  emacs/notmuch-lib.el |    7 +++++--\r
110 >  emacs/notmuch-mua.el |   12 ++++++------\r
111 >  2 files changed, 11 insertions(+), 8 deletions(-)\r
112 >\r
113 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
114 > index c146748..0effe24 100644\r
115 > --- a/emacs/notmuch-lib.el\r
116 > +++ b/emacs/notmuch-lib.el\r
117 > @@ -232,9 +232,12 @@ the given type."\r
118 >    (or (plist-get part :content)\r
119 >        (notmuch-get-bodypart-internal (concat "id:" (plist-get msg :id)) nth process-crypto)))\r
120 >  \r
121 > -(defun notmuch-plist-to-alist (plist)\r
122 > +;; Converts a plist of headers to an alist of headers. The input plist should\r
123 > +;; have symbols of the form :Header as keys, and the resulting alist will have\r
124 > +;; symbols of the form 'Header as keys.\r
125 > +(defun notmuch-headers-plist-to-alist (plist)\r
126 >    (loop for (key value . rest) on plist by #'cddr\r
127 > -     collect (cons (substring (symbol-name key) 1) value)))\r
128 > +     collect (cons (intern (substring (symbol-name key) 1)) value)))\r
129 >  \r
130 >  ;; Compatibility functions for versions of emacs before emacs 23.\r
131 >  ;;\r
132 > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
133 > index 9805d79..cfa3d61 100644\r
134 > --- a/emacs/notmuch-mua.el\r
135 > +++ b/emacs/notmuch-mua.el\r
136 > @@ -127,7 +127,7 @@ list."\r
137 >         ((same-window-regexps '("\\*mail .*")))\r
138 >       (notmuch-mua-mail (plist-get reply-headers :To)\r
139 >                         (plist-get reply-headers :Subject)\r
140 > -                       (notmuch-plist-to-alist reply-headers)))\r
141 > +                       (notmuch-headers-plist-to-alist reply-headers)))\r
142 >        ;; Insert the message body - but put it in front of the signature\r
143 >        ;; if one is present\r
144 >        (goto-char (point-max))\r
145 > @@ -185,11 +185,11 @@ OTHER-ARGS are passed through to `message-mail'."\r
146 >    (when notmuch-mua-user-agent-function\r
147 >      (let ((user-agent (funcall notmuch-mua-user-agent-function)))\r
148 >        (when (not (string= "" user-agent))\r
149 > -     (push (cons "User-Agent" user-agent) other-headers))))\r
150 > +     (push (cons 'User-Agent user-agent) other-headers))))\r
151 >  \r
152 > -  (unless (assoc "From" other-headers)\r
153 > -    (push (cons "From" (concat\r
154 > -                     (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers))\r
155 > +  (unless (assq 'From other-headers)\r
156 > +    (push (cons 'From (concat\r
157 > +                    (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers))\r
158 >  \r
159 >    (apply #'message-mail to subject other-headers other-args)\r
160 >    (message-sort-headers)\r
161 > @@ -250,7 +250,7 @@ the From: address first."\r
162 >    (interactive "P")\r
163 >    (let ((other-headers\r
164 >        (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
165 > -        (list (cons "From" (notmuch-mua-prompt-for-sender))))))\r
166 > +        (list (cons 'From (notmuch-mua-prompt-for-sender))))))\r
167 >      (notmuch-mua-mail nil nil other-headers)))\r
168 >  \r
169 >  (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
170 > -- \r
171 > 1.7.5.4\r
172 >\r
173 > _______________________________________________\r
174 > notmuch mailing list\r
175 > notmuch@notmuchmail.org\r
176 > http://notmuchmail.org/mailman/listinfo/notmuch\r