Re: Hi all
[notmuch-archives.git] / 30 / 92391269e9f05af9abcbfa06256a372ac47b20
1 Return-Path: <awg@lagos.xvx.ca>\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 5C1ED421169\r
6         for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 17:33:29 -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: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 j9JcXbbQIkQb for <notmuch@notmuchmail.org>;\r
16         Sat, 31 Mar 2012 17:33:28 -0700 (PDT)\r
17 Received: from idcmail-mo2no.shaw.ca (idcmail-mo2no.shaw.ca [64.59.134.9])\r
18         by olra.theworths.org (Postfix) with ESMTP id 36D4E431FAF\r
19         for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 17:33:28 -0700 (PDT)\r
20 Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd7ml1no-ssvc.prod.shaw.ca)\r
21         ([10.0.144.222])\r
22         by pd7mo1no-svcs.prod.shaw.ca with ESMTP; 31 Mar 2012 18:33:27 -0600\r
23 X-Cloudmark-SP-Filtered: true\r
24 X-Cloudmark-SP-Result: v=1.1 cv=Ro8QOmc0aMDfanRtxUddlQ8SbE2D0zCZP8MBHZpYE5w=\r
25         c=1 sm=1\r
26         a=-0qw98XiWg0A:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
27         a=A1X0JdhQAAAA:8 a=7343-z1_AAAA:8 a=pGLkceISAAAA:8\r
28         a=8gnJ_Gl0cEducP-3I3oA:9\r
29         a=o7ssWKy88mDHYupUGScA:7 a=0BPXsuqt4rsA:10 a=Y6qChIQXU1wA:10\r
30         a=0c-eHkXYtrgA:10 a=W1FlNvOLpxFuk1rg:21 a=F3cdPcKHmORucg4O:21\r
31         a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
32 Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
33         by pd7ml1no-dmz.prod.shaw.ca with ESMTP; 31 Mar 2012 18:33:27 -0600\r
34 Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
35         id 352858004827; Sat, 31 Mar 2012 18:33:27 -0600 (MDT)\r
36 From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
37 To: notmuch@notmuchmail.org\r
38 Subject: [BUG/PATCH v3 4/4] emacs: Fix the References header in reply\r
39 Date: Sat, 31 Mar 2012 18:33:24 -0600\r
40 Message-Id: <1333240404-13076-5-git-send-email-awg+notmuch@xvx.ca>\r
41 X-Mailer: git-send-email 1.7.5.4\r
42 In-Reply-To: <1333240404-13076-1-git-send-email-awg+notmuch@xvx.ca>\r
43 References: <1333240404-13076-1-git-send-email-awg+notmuch@xvx.ca>\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Sun, 01 Apr 2012 00:33:29 -0000\r
57 \r
58 In the new reply code, the References header gets inserted by\r
59 message.el using a function called message-shorten-references. Unlike\r
60 all the other header-inserting functions, it doesn't put a newline\r
61 after the header, causing the next header to end up on the same\r
62 line. In our case, this header happened to be User-Agent, so it's hard\r
63 to notice. This is probably a bug in message.el, but we need to work\r
64 around it.\r
65 \r
66 This fixes the problem by wrapping message-shorten-references in a\r
67 function that inserts a newline after if necessary. This should\r
68 protect against the message.el bug being fixed in the future.\r
69 ---\r
70  emacs/notmuch-mua.el |   28 +++++++++++++++++++++++++---\r
71  test/emacs           |    6 ------\r
72  2 files changed, 25 insertions(+), 9 deletions(-)\r
73 \r
74 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
75 index cfa3d61..9f279d9 100644\r
76 --- a/emacs/notmuch-mua.el\r
77 +++ b/emacs/notmuch-mua.el\r
78 @@ -90,6 +90,15 @@ list."\r
79         else if (notmuch-match-content-type (plist-get part :content-type) "text/*")\r
80           collect part))\r
81  \r
82 +;; There is a bug in emacs 23's message.el that results in a newline\r
83 +;; not being inserted after the References header, so the next header\r
84 +;; is concatenated to the end of it. This function fixes the problem,\r
85 +;; while guarding against the possibility that some current or future\r
86 +;; version of emacs has the bug fixed.\r
87 +(defun notmuch-mua-insert-references (original-func header references)\r
88 +  (funcall original-func header references)\r
89 +  (unless (bolp) (insert "\n")))\r
90 +\r
91  (defun notmuch-mua-reply (query-string &optional sender reply-all)\r
92    (let ((args '("reply" "--format=json"))\r
93         reply\r
94 @@ -125,9 +134,22 @@ list."\r
95           ;; Overlay the composition window on that being used to read\r
96           ;; the original message.\r
97           ((same-window-regexps '("\\*mail .*")))\r
98 -       (notmuch-mua-mail (plist-get reply-headers :To)\r
99 -                         (plist-get reply-headers :Subject)\r
100 -                         (notmuch-headers-plist-to-alist reply-headers)))\r
101 +\r
102 +       ;; We modify message-header-format-alist to get around a bug in message.el.\r
103 +       ;; See the comment above on notmuch-mua-insert-references.\r
104 +       (let ((message-header-format-alist\r
105 +              (loop for pair in message-header-format-alist\r
106 +                    if (eq (car pair) 'References)\r
107 +                    collect (cons 'References \r
108 +                                  (apply-partially\r
109 +                                   'notmuch-mua-insert-references\r
110 +                                   (cdr pair)))\r
111 +                    else\r
112 +                    collect pair)))\r
113 +         (notmuch-mua-mail (plist-get reply-headers :To)\r
114 +                           (plist-get reply-headers :Subject)\r
115 +                           (notmuch-headers-plist-to-alist reply-headers))))\r
116 +\r
117        ;; Insert the message body - but put it in front of the signature\r
118        ;; if one is present\r
119        (goto-char (point-max))\r
120 diff --git a/test/emacs b/test/emacs\r
121 index 7d00cae..e319f83 100755\r
122 --- a/test/emacs\r
123 +++ b/test/emacs\r
124 @@ -256,7 +256,6 @@ EOF\r
125  test_expect_equal_file OUTPUT EXPECTED\r
126  \r
127  test_begin_subtest "Reply within emacs"\r
128 -test_subtest_known_broken\r
129  test_emacs '(let ((message-hidden-headers ''()))\r
130             (notmuch-search "subject:\"testing message sent via SMTP\"")\r
131             (notmuch-test-wait)\r
132 @@ -281,7 +280,6 @@ EOF\r
133  test_expect_equal_file OUTPUT EXPECTED\r
134  \r
135  test_begin_subtest "Reply from alternate address within emacs"\r
136 -test_subtest_known_broken\r
137  add_message '[from]="Sender <sender@example.com>"' \\r
138              [to]=test_suite_other@notmuchmail.org\r
139  \r
140 @@ -307,7 +305,6 @@ EOF\r
141  test_expect_equal_file OUTPUT EXPECTED\r
142  \r
143  test_begin_subtest "Reply from address in named group list within emacs"\r
144 -test_subtest_known_broken\r
145  add_message '[from]="Sender <sender@example.com>"' \\r
146              '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \\r
147               [cc]=test_suite_other@notmuchmail.org\r
148 @@ -334,7 +331,6 @@ EOF\r
149  test_expect_equal_file OUTPUT EXPECTED\r
150  \r
151  test_begin_subtest "Reply within emacs to a multipart/mixed message"\r
152 -test_subtest_known_broken\r
153  test_emacs '(let ((message-hidden-headers ''()))\r
154             (notmuch-show "id:20091118002059.067214ed@hikari")\r
155                 (notmuch-show-reply)\r
156 @@ -398,7 +394,6 @@ EOF\r
157  test_expect_equal_file OUTPUT EXPECTED\r
158  \r
159  test_begin_subtest "Reply within emacs to a multipart/alternative message"\r
160 -test_subtest_known_broken\r
161  test_emacs '(let ((message-hidden-headers ''()))\r
162             (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")\r
163                 (notmuch-show-reply)\r
164 @@ -439,7 +434,6 @@ EOF\r
165  test_expect_equal_file OUTPUT EXPECTED\r
166  \r
167  test_begin_subtest "Quote MML tags in reply"\r
168 -test_subtest_known_broken\r
169  message_id='test-emacs-mml-quoting@message.id'\r
170  add_message [id]="$message_id" \\r
171             "[subject]='$test_subtest_name'" \\r
172 -- \r
173 1.7.5.4\r
174 \r