Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 06 / a4cb4a2dec73469b10032488ea29b7f9f21517
1 Return-Path: <tomi.ollila@iki.fi>\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 B44C5431FAF\r
6         for <notmuch@notmuchmail.org>; Wed,  3 Oct 2012 07:06:44 -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 tests=[none]\r
12         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 qTnUrX9WPGI4 for <notmuch@notmuchmail.org>;\r
16         Wed,  3 Oct 2012 07:06:43 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id E1839431FAE\r
19         for <notmuch@notmuchmail.org>; Wed,  3 Oct 2012 07:06:42 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id B8D07100150;\r
22         Wed,  3 Oct 2012 17:06:47 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Aaron Ecay <aaronecay@gmail.com>, Robert Horn <rjhorn@alum.mit.edu>,\r
25         notmuch@notmuchmail.org\r
26 Subject: Re: bug related to ical\r
27 In-Reply-To: <m2obkjlm3f.fsf@guru.guru-group.fi>\r
28 References: <m31ul3qo4w.fsf@quad.robs.office> <87d319b899.fsf@gmail.com>\r
29         <m2obkjlm3f.fsf@guru.guru-group.fi>\r
30 User-Agent: Notmuch/0.14+51~g62cd13b (http://notmuchmail.org) Emacs/24.2.1\r
31         (x86_64-unknown-linux-gnu)\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
33         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
34         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
35 Date: Wed, 03 Oct 2012 17:06:47 +0300\r
36 Message-ID: <m2391vir9k.fsf@guru.guru-group.fi>\r
37 MIME-Version: 1.0\r
38 Content-Type: text/plain; charset=utf-8\r
39 Content-Transfer-Encoding: quoted-printable\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: Wed, 03 Oct 2012 14:06:44 -0000\r
53 \r
54 On Wed, Oct 03 2012, Tomi Ollila wrote:\r
55 \r
56 > On Wed, Sep 26 2012, Aaron Ecay wrote:\r
57 >\r
58 >> The problem is in the =E2=80=98notmuch-show-insert-part-text/calendar=E2=\r
59 =80=99\r
60 >> function.  The call to =E2=80=98icalendar--convert-ical-to-diary=E2=80=\r
61 =99 does not\r
62 >> create a buffer visiting the temp file, so the call to =E2=80=98set-buff=\r
63 er=E2=80=99\r
64 >> fails.  The following patch fixes the problem.\r
65 >>\r
66 >> The ical->diary conversion also doesn=E2=80=99t seem to work =E2=80=93 t=\r
67 he calendar\r
68 >> attachment shows up as an empty part =E2=80=93 but I guess that=E2=80=99=\r
69 s a separate\r
70 >> issue (and not addressed by the patch).\r
71 >>\r
72 >> I guess that part insertion handlers should be called inside a\r
73 >> =E2=80=98condition-case=E2=80=99, so that an error inside of one can be =\r
74 recovered from,\r
75 >> and doesn=E2=80=99t entirely derail the insertion of the messages in the=\r
76  buffer.\r
77 >> (I actually made this patch because I was so annoyed that Olivier=E2=80=\r
78 =99s\r
79 >> buggy test attachment made it impossible for me to read Tomi=E2=80=99s r=\r
80 eply.)\r
81 >>\r
82 >> ----- cut here -----\r
83 >>\r
84 >> diff --git i/emacs/notmuch-show.el w/emacs/notmuch-show.el\r
85 >> index ce5ea6f..4c89d7e 100644\r
86 >> --- i/emacs/notmuch-show.el\r
87 >> +++ w/emacs/notmuch-show.el\r
88 >> @@ -746,7 +746,7 @@ message at DEPTH in the current thread."\r
89 >>            (icalendar--convert-ical-to-diary\r
90 >>             (icalendar--read-element nil nil)\r
91 >>             file t)\r
92 >> -          (set-buffer (get-file-buffer file))\r
93 >> +          (set-buffer (find-file-noselect file))\r
94 >>            (setq result (buffer-substring (point-min) (point-max)))\r
95 >>            (set-buffer-modified-p nil)\r
96 >>            (kill-buffer (current-buffer))\r
97 >>\r
98 >> ----- cut here -----\r
99 >\r
100 > The problem seems to be carriage returns in the attachment -- which goes\r
101 > unnotified when converting from octet-stream content.\r
102 >\r
103 > I've got the example in question to "work" with the following patch_\r
104 >\r
105 > --8<----8<----8<-- cut here  --8<----8<----8<--\r
106 >\r
107 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
108 > index 86130ce..f7c08ee 100644\r
109 > --- a/emacs/notmuch-show.el\r
110 > +++ b/emacs/notmuch-show.el\r
111 > @@ -747,17 +747,21 @@ message at DEPTH in the current thread."\r
112 >    (notmuch-show-insert-part-header nth declared-type content-type (plist=\r
113 -get part :filename))\r
114 >    (insert (with-temp-buffer\r
115 >           (insert (notmuch-get-bodypart-content msg part nth notmuch-show-pro=\r
116 cess-crypto))\r
117 > -         (goto-char (point-min))\r
118 >           (let ((file (make-temp-file "notmuch-ical"))\r
119 >                 result)\r
120 > +           (set-buffer (icalendar--get-unfolded-buffer (current-buffer)))\r
121 > +           (beginning-of-buffer)\r
122 > +           (replace-string "" "")\r
123 \r
124 OK, something mangled my email, there used to be ^M above (as one char, CR\r
125 .. maybe "\r" would have worked ?)\r
126 \r
127 Tomi\r
128 \r
129 \r
130 > +           (beginning-of-buffer)\r
131 >             (icalendar--convert-ical-to-diary\r
132 >              (icalendar--read-element nil nil)\r
133 >              file t)\r
134 > +           (kill-buffer (current-buffer))\r
135 >             (set-buffer (get-file-buffer file))\r
136 >             (setq result (buffer-substring (point-min) (point-max)))\r
137 >             (set-buffer-modified-p nil)\r
138 >             (kill-buffer (current-buffer))\r
139 > -           (delete-file file)\r
140 > +           ;;;(delete-file file)\r
141 >             result)))\r
142 >    t)\r
143 >=20=20\r
144 > --8<----8<----8<-- cut here  --8<----8<----8<--\r
145 >\r
146 > In our case the icalendar--get-unfolded-buffer doesn't seem\r
147 > to do any conversions (the docstring mentions some LF/CR/BLANK\r
148 > replacements) -- I just copied that line from icalendar-import-buffer\r
149 > which I tried first.\r
150 >\r
151 > The interesting thing is that the notmuch-icalXXXXXX file is\r
152 > still empty ... hmm, the buffer is just not saved (would /dev/null work ;=\r
153 ))\r
154 >\r
155 > To do:\r
156 > Check why icalendar--get-unfolded-buffer did not do what it advertised;\r
157 > the code seems to support the replacements mentioned -- or maybe I failed=\r
158  ;/\r
159 >\r
160 > The problem with failing to icalendar--convert-ical-to-diary is that\r
161 > the buffer is not created. The find-file-noselect shields about that\r
162 > problem here but not elsewhere (and why that failure is so "fatal" ???)\r
163 > Some shielding in higher level should be implemented (i.e. the\r
164 > "condition-case" suggestion Aaron mentioned or something :)\r
165 >\r
166 >\r
167 > self to remember:  M-x debug-on-entry and keys 'd', 'u' and 'c' in debugg=\r
168 er :)\r
169 >\r
170 > Tomi\r
171 >\r
172 >>\r
173 >> --=20\r
174 >> Aaron Ecay\r