Re: notmuch-tree display
[notmuch-archives.git] / f2 / d528c77ace8094147cb2a17258adde40a65a85
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 A712C429E34\r
6         for <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 09:27:01 -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 xk6Enu5u5q1H for <notmuch@notmuchmail.org>;\r
16         Thu, 29 Mar 2012 09:26:59 -0700 (PDT)\r
17 Received: from idcmail-mo1so.shaw.ca (idcmail-mo1so.shaw.ca [24.71.223.10])\r
18         by olra.theworths.org (Postfix) with ESMTP id D72D1431E62\r
19         for <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 09:26:56 -0700 (PDT)\r
20 Received: from pd4ml2so-ssvc.prod.shaw.ca ([10.0.141.136])\r
21         by pd3mo1so-svcs.prod.shaw.ca with ESMTP; 29 Mar 2012 10:26:56 -0600\r
22 X-Cloudmark-SP-Filtered: true\r
23 X-Cloudmark-SP-Result: v=1.1 cv=OAanaFJXxrU4geOiks1gk5+7cCarKPEnRlgRWHXA/ts=\r
24         c=1 sm=1\r
25         a=CTBuJuvJAFQA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
26         a=QtFthfrC4rEx_lj7qzYA:9 a=S68_BOFbyGUJK95SUOAA:7\r
27         a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
28 Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
29         by pd4ml2so-dmz.prod.shaw.ca with ESMTP; 29 Mar 2012 10:26:56 -0600\r
30 Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
31         id 5DB158004204; Thu, 29 Mar 2012 10:26:56 -0600 (MDT)\r
32 From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
33 To: notmuch@notmuchmail.org\r
34 Subject: [BUG/PATCH v2 2/2] emacs: Fix the References header in reply\r
35 Date: Thu, 29 Mar 2012 10:26:50 -0600\r
36 Message-Id: <1333038410-17927-3-git-send-email-awg+notmuch@xvx.ca>\r
37 X-Mailer: git-send-email 1.7.5.4\r
38 In-Reply-To: <1333038410-17927-1-git-send-email-awg+notmuch@xvx.ca>\r
39 References: <1333038410-17927-1-git-send-email-awg+notmuch@xvx.ca>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Thu, 29 Mar 2012 16:27:02 -0000\r
53 \r
54 In the new reply code, the References header gets inserted by\r
55 message.el using a function called message-shorten-references. Unlike\r
56 all the other header-inserting functions, it doesn't put a newline\r
57 after the header, causing the next header to end up on the same\r
58 line. In our case, this header happened to be User-Agent, so it's hard\r
59 to notice. This is probably a bug in message.el, but we need to work\r
60 around it.\r
61 \r
62 This fixes the problem by wrapping message-shorten-references in a\r
63 function that inserts a newline after if necessary. This should\r
64 protect against the message.el bug being fixed in the future.\r
65 ---\r
66  emacs/notmuch-mua.el |   28 +++++++++++++++++++++++++---\r
67  1 files changed, 25 insertions(+), 3 deletions(-)\r
68 \r
69 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
70 index cfa3d61..9f279d9 100644\r
71 --- a/emacs/notmuch-mua.el\r
72 +++ b/emacs/notmuch-mua.el\r
73 @@ -90,6 +90,15 @@ list."\r
74         else if (notmuch-match-content-type (plist-get part :content-type) "text/*")\r
75           collect part))\r
76  \r
77 +;; There is a bug in emacs 23's message.el that results in a newline\r
78 +;; not being inserted after the References header, so the next header\r
79 +;; is concatenated to the end of it. This function fixes the problem,\r
80 +;; while guarding against the possibility that some current or future\r
81 +;; version of emacs has the bug fixed.\r
82 +(defun notmuch-mua-insert-references (original-func header references)\r
83 +  (funcall original-func header references)\r
84 +  (unless (bolp) (insert "\n")))\r
85 +\r
86  (defun notmuch-mua-reply (query-string &optional sender reply-all)\r
87    (let ((args '("reply" "--format=json"))\r
88         reply\r
89 @@ -125,9 +134,22 @@ list."\r
90           ;; Overlay the composition window on that being used to read\r
91           ;; the original message.\r
92           ((same-window-regexps '("\\*mail .*")))\r
93 -       (notmuch-mua-mail (plist-get reply-headers :To)\r
94 -                         (plist-get reply-headers :Subject)\r
95 -                         (notmuch-headers-plist-to-alist reply-headers)))\r
96 +\r
97 +       ;; We modify message-header-format-alist to get around a bug in message.el.\r
98 +       ;; See the comment above on notmuch-mua-insert-references.\r
99 +       (let ((message-header-format-alist\r
100 +              (loop for pair in message-header-format-alist\r
101 +                    if (eq (car pair) 'References)\r
102 +                    collect (cons 'References \r
103 +                                  (apply-partially\r
104 +                                   'notmuch-mua-insert-references\r
105 +                                   (cdr pair)))\r
106 +                    else\r
107 +                    collect pair)))\r
108 +         (notmuch-mua-mail (plist-get reply-headers :To)\r
109 +                           (plist-get reply-headers :Subject)\r
110 +                           (notmuch-headers-plist-to-alist reply-headers))))\r
111 +\r
112        ;; Insert the message body - but put it in front of the signature\r
113        ;; if one is present\r
114        (goto-char (point-max))\r
115 -- \r
116 1.7.5.4\r
117 \r