Re: [PATCH] Fix typo in Message.maildir_flags_to_tags
[notmuch-archives.git] / 48 / e08c51ef2c21031d0511cf7fe594b814d40818
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 6045E429E25\r
6         for <notmuch@notmuchmail.org>; Thu,  5 Sep 2013 11:46:54 -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 yLCz72ibkO3T for <notmuch@notmuchmail.org>;\r
17         Thu,  5 Sep 2013 11:46:48 -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 44AD0431FDB\r
22         for <notmuch@notmuchmail.org>; Thu,  5 Sep 2013 11:46:48 -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 1VHeZj-0005Ug-6w; Thu, 05 Sep 2013 19:46:44 +0100\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1VHeZi-0001F0-UG; Thu, 05 Sep 2013 19:46:39 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH v2] emacs: show: lazy part bugfix\r
34 In-Reply-To: <20130904161628.GC1426@mit.edu>\r
35 References: <1377246875-7784-1-git-send-email-markwalters1009@gmail.com>\r
36         <1378279835-28288-1-git-send-email-markwalters1009@gmail.com>\r
37         <20130904145639.GB1426@mit.edu>\r
38         <87hae07fhs.fsf@servo.finestructure.net>\r
39         <20130904161628.GC1426@mit.edu>\r
40 User-Agent: Notmuch/0.15.2+269~g01f5508 (http://notmuchmail.org) Emacs/23.4.1\r
41         (x86_64-pc-linux-gnu)\r
42 Date: Thu, 05 Sep 2013 19:46:37 +0100\r
43 Message-ID: <87txhz14z6.fsf@qmul.ac.uk>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=utf-8\r
46 Content-Transfer-Encoding: quoted-printable\r
47 X-Sender-Host-Address: 93.97.24.31\r
48 X-QM-SPAM-Info: Sender has good ham record.  :)\r
49 X-QM-Body-MD5: 4e01612d53a146601ef488817f3523d1 (of first 20000 bytes)\r
50 X-SpamAssassin-Score: 0.0\r
51 X-SpamAssassin-SpamBar: /\r
52 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
53         determine if it is\r
54         spam. We require at least 5.0 points to mark a message as spam.\r
55         This message scored 0.0 points. Summary of the scoring: \r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         *  0.0 AWL AWL: From: address is in the auto white-list\r
59 X-QM-Scan-Virus: ClamAV says the message is clean\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Thu, 05 Sep 2013 18:46:54 -0000\r
73 \r
74 \r
75 Thanks to Austin's prodding and debugging and pointing out contradictory\r
76 evidence I have looked into this bug in more detail and think I have got\r
77 the actual cause this time.\r
78 \r
79 Having chased it all down I think there is a one line fix. Since I had\r
80 already written the rest of the email when I discovered this I include\r
81 the diagnosis below but most people will probably want to skip to the\r
82 patch at the end.\r
83 \r
84 ---\r
85 \r
86 The problem only occurs for message of this sort of form\r
87    =E2=94=94=E2=94=AC=E2=95=B4multipart/alternative 896783 bytes\r
88     =E2=94=9C=E2=94=80=E2=95=B4text/plain 379 bytes\r
89     =E2=94=94=E2=94=AC=E2=95=B4multipart/related 892556 bytes\r
90      =E2=94=9C=E2=94=80=E2=95=B4text/html 1236 bytes\r
91      =E2=94=94=E2=94=80=E2=95=B4image/jpeg inline [photo.JPG] 890841 bytes\r
92 \r
93 The important features are that initially the multipart/related is\r
94 hidden, and that when the multipart/related part is shown the child\r
95 image/jpeg is hidden (that is what happens in Istvan's patch and could\r
96 also happen with the inner part also being multipart/alternative but\r
97 not, I think, if the inner part were multipart/mixed).\r
98 \r
99 Now the code for hiding parts starts with the normal button and then\r
100 toggles the button (this is to make sure the button gets the correct\r
101 label text). When doing so this code looks at the first character of the\r
102 button, stores the text-properties, replaces the button with the toggled\r
103 button, puts the text-properties back. Since insert does not put in text\r
104 properties we do need this save restore.\r
105 \r
106 In the normal case where a hidden part is inserted it is on a newline\r
107 where the current text-properties are nil. Thus the save/restore of text\r
108 properties does nothing in this case; after this is done the correct\r
109 text-properties are applied to the whole part (with the proviso that\r
110 :notmuch-part does not over-ride subpart's :notmuch-part property)\r
111 \r
112 In the problem case above we have a line with=20\r
113 \r
114 [multipart/related (hidden)]\r
115 \r
116 The whole of this line including the \n has the multipart-related\r
117 :notmuch-part\r
118 \r
119 Now when we do the lazy insertion we toggle this button (which behaves\r
120 correctly), go to the end of the button insert a \n and then insert the\r
121 child parts.\r
122 \r
123 At this point we have\r
124 \r
125 [multipart/related]\n\r
126 \n\r
127 \r
128 the [multipart/related] has the multipart/related :notmuch-part info the\r
129 first \n does not (as we just inserted) and the second \n does because\r
130 it is the original \n\r
131 \r
132 Now if we insert a part button for a hidden part we insert the button\r
133 and toggle it. Finally we get the problem: this toggle saves and\r
134 restores (to the whole button) the text-properties from *point* which is\r
135 the \n so includes the multipart/related\r
136 :notmuch-part text-property\r
137 \r
138 If we save and restore from the start of the button we solve all of the\r
139 problems (I think)\r
140 \r
141 Best wishes=20\r
142 \r
143 Mark\r
144 \r
145 \r
146 ---\r
147  emacs/notmuch-show.el |    2 +-\r
148  1 files changed, 1 insertions(+), 1 deletions(-)\r
149 \r
150 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
151 index 20844f0..0267574 100644\r
152 --- a/emacs/notmuch-show.el\r
153 +++ b/emacs/notmuch-show.el\r
154 @@ -503,7 +503,7 @@ message at DEPTH in the current thread."\r
155              (new-start (button-start button))\r
156              (button-label (button-get button :base-label))\r
157              (old-point (point))\r
158 -            (properties (text-properties-at (point)))\r
159 +            (properties (text-properties-at (button-start button)))\r
160              (inhibit-read-only t))\r
161         ;; Toggle the button itself.\r
162         (button-put button :notmuch-part-hidden (not show))\r
163 --=20\r
164 1.7.9.1\r
165 \r