Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / d1 / b9d9fd53a6d0211e6d3e07afc1b7fc7e18c73e
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 5912F431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 28 Mar 2012 20:20:34 -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 X1VT6TniCEG0 for <notmuch@notmuchmail.org>;\r
16         Wed, 28 Mar 2012 20:20:32 -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 54185431FAE\r
19         for <notmuch@notmuchmail.org>; Wed, 28 Mar 2012 20:20:32 -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; 28 Mar 2012 21:20:30 -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=FsaaOiQHy1oA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
27         a=4U69qDNLMXPqwlrapeIA:9 a=fDyG4HWkrDR3ieODuEMA:7\r
28         a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
29 Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
30         by pd7ml1no-dmz.prod.shaw.ca with ESMTP; 28 Mar 2012 21:20:30 -0600\r
31 Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
32         id DB8F18004204; Wed, 28 Mar 2012 21:20:29 -0600 (MDT)\r
33 From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [BUG/PATCH] emacs: Fix the References header in reply\r
36 Date: Wed, 28 Mar 2012 21:20:26 -0600\r
37 Message-Id: <1332991226-510-1-git-send-email-awg+notmuch@xvx.ca>\r
38 X-Mailer: git-send-email 1.7.5.4\r
39 In-Reply-To: <87iphos8s8.fsf@servo.finestructure.net>\r
40 References: <87iphos8s8.fsf@servo.finestructure.net>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Thu, 29 Mar 2012 03:20:34 -0000\r
54 \r
55 In the new reply code, the References header gets inserted by\r
56 message.el using a function called message-shorten-references. Unlike\r
57 all the other header-inserting functions, it doesn't put a newline\r
58 after the header, causing the next header to end up on the same\r
59 line. In our case, this header happened to be User-Agent, so it's hard\r
60 to notice. This is probably a bug in message.el, but we need to work\r
61 around it.\r
62 \r
63 This fixes the problem by wrapping message-shorten-references in a\r
64 function that inserts a newline after if necessary. This should\r
65 protect against the message.el bug being fixed in the future.\r
66 ---\r
67  emacs/notmuch-mua.el |   22 +++++++++++++++++++---\r
68  1 files changed, 19 insertions(+), 3 deletions(-)\r
69 \r
70 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
71 index 24918d3..b5d91b7 100644\r
72 --- a/emacs/notmuch-mua.el\r
73 +++ b/emacs/notmuch-mua.el\r
74 @@ -90,6 +90,15 @@ list."\r
75         else if (notmuch-match-content-type (plist-get part :content-type) "text/*")\r
76           collect part))\r
77  \r
78 +;; There is a bug in emacs 23's message.el that results in a newline\r
79 +;; not being inserted after the References header, so the next header\r
80 +;; is concatenated to the end of it. This function fixes the problem,\r
81 +;; while guarding against the possibility that some current or future\r
82 +;; version of emacs has the bug fixed.\r
83 +(defun notmuch-mua-insert-references (header references)\r
84 +  (message-shorten-references header references)\r
85 +  (unless (bolp) (insert "\n")))\r
86 +\r
87  (defun notmuch-mua-reply (query-string &optional sender reply-all)\r
88    (let ((args '("reply" "--format=json"))\r
89         reply\r
90 @@ -125,9 +134,16 @@ list."\r
91           ;; Overlay the composition window on that being used to read\r
92           ;; the original message.\r
93           ((same-window-regexps '("\\*mail .*")))\r
94 -       (notmuch-mua-mail (plist-get reply-headers :To)\r
95 -                         (plist-get reply-headers :Subject)\r
96 -                         (notmuch-plist-to-alist reply-headers)))\r
97 +\r
98 +       ;; We modify message-header-format-alist to get around a bug in message.el.\r
99 +       ;; See the comment above on notmuch-mua-insert-references.\r
100 +       (let ((message-header-format-alist\r
101 +              (append '((References . notmuch-mua-insert-references))\r
102 +                      (remove-if (lambda (x) (eq (car x) 'References))\r
103 +                                 message-header-format-alist))))\r
104 +         (notmuch-mua-mail (plist-get reply-headers :To)\r
105 +                           (plist-get reply-headers :Subject)\r
106 +                           (notmuch-plist-to-alist reply-headers))))\r
107        ;; Insert the message body - but put it in front of the signature\r
108        ;; if one is present\r
109        (goto-char (point-max))\r
110 -- \r
111 1.7.5.4\r
112 \r