[PATCH 04/21] vim: refactor database handling
[notmuch-archives.git] / ea / 10545104fb0e4f0eaa9a2ad6c23b4480422c89
1 Return-Path: <ethan.glasser.camp@gmail.com>\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 AED04431FAF\r
6         for <notmuch@notmuchmail.org>; Sat, 17 Nov 2012 21:29:37 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 1.7\r
10 X-Spam-Level: *\r
11 X-Spam-Status: No, score=1.7 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, FREEMAIL_REPLY=2.499, RCVD_IN_DNSWL_LOW=-0.7]\r
14         autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id c-DuE+xgLewG for <notmuch@notmuchmail.org>;\r
18         Sat, 17 Nov 2012 21:29:36 -0800 (PST)\r
19 Received: from mail-qa0-f46.google.com (mail-qa0-f46.google.com\r
20         [209.85.216.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 963A7431FAE\r
23         for <notmuch@notmuchmail.org>; Sat, 17 Nov 2012 21:29:36 -0800 (PST)\r
24 Received: by mail-qa0-f46.google.com with SMTP id c11so4919206qad.5\r
25         for <notmuch@notmuchmail.org>; Sat, 17 Nov 2012 21:29:36 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
28         :mime-version:content-type;\r
29         bh=5SyJn52b3ILvGjmTDka1q2VrY7pb+68yyMaU5hgGDF8=;\r
30         b=jF8RpRQXpDxXA1qzMX+S4kn0Jo58b/gojeMbsnxOkXgNBWbS8RcZpDk5sj98vrFcie\r
31         qQva+w/oaKIO6SS48RUSopfxHu4Vyo9l3VCF8TswmF+Ml1utjVe+aSq917WvxZKoA09Q\r
32         tiDZmujFKMsFF/LS6phYzKm0boQxiR1PcYtyRZcsqwLqwQk1A1KAyeS995y9fSZdUUsV\r
33         CmE/mkeYxTBKr1ABmlk7GNiZKmzCPhgMJ6vMxYQEFEC5C0nehHrGQ965J/HKoHdk81m5\r
34         3b6V6i0skiML73rwvHh9WMhY6jduIS9h+jbtOiZRd1VhNdOAl3r2XucgcjR7+siGokTR\r
35         G3/Q==\r
36 Received: by 10.49.24.163 with SMTP id v3mr9571296qef.48.1353216576087;\r
37         Sat, 17 Nov 2012 21:29:36 -0800 (PST)\r
38 Received: from smtp.gmail.com ([66.114.71.21])\r
39         by mx.google.com with ESMTPS id ho6sm3479195qeb.3.2012.11.17.21.29.33\r
40         (version=TLSv1/SSLv3 cipher=OTHER);\r
41         Sat, 17 Nov 2012 21:29:33 -0800 (PST)\r
42 From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
43 To: Tomi Ollila <tomi.ollila@iki.fi>,\r
44         Michael Stapelberg <michael+nm@stapelberg.de>, notmuch@notmuchmail.org\r
45 Subject: Re: [BUG] Saving attachments containing UTF-8 chars\r
46 In-Reply-To: <m2pq416xzl.fsf@guru.guru-group.fi>\r
47 References: <x6sj8xiexi.fsf@midna.zekjur.net>\r
48         <m2pq416xzl.fsf@guru.guru-group.fi>\r
49 User-Agent: Notmuch/0.14+45~g6ea9330 (http://notmuchmail.org) Emacs/24.1.1\r
50         (x86_64-pc-linux-gnu)\r
51 Date: Sun, 18 Nov 2012 00:29:31 -0500\r
52 Message-ID: <87zk2f1nt0.fsf@betacantrips.com>\r
53 MIME-Version: 1.0\r
54 Content-Type: text/plain\r
55 X-BeenThere: notmuch@notmuchmail.org\r
56 X-Mailman-Version: 2.1.13\r
57 Precedence: list\r
58 List-Id: "Use and development of the notmuch mail system."\r
59         <notmuch.notmuchmail.org>\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
63 List-Post: <mailto:notmuch@notmuchmail.org>\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
67 X-List-Received-Date: Sun, 18 Nov 2012 05:29:37 -0000\r
68 \r
69 Tomi Ollila <tomi.ollila@iki.fi> writes:\r
70 \r
71 > I can verify this bug: I copied 'rawmail' to my mail store and attempted\r
72 > to 'w' the attacment and got the same result (after notmuch new).\r
73 >\r
74 > The saving code first does\r
75 > notmuch show --format=raw id:"508953E6.70006@gmail.com"\r
76 > which decodes OK on command line, and to the buffer when \r
77 > kill-buffer is outcommented in (with-current-notmuch-show-message ...) \r
78 > macro.\r
79 \r
80 I was able to see this behavior, and Tomi did a good job tracking down\r
81 where it was :)\r
82 \r
83 I even see the bytes as presented in the file. When moving point to the\r
84 problematic character, and doing M-x describe-char, it says:\r
85 \r
86           buffer code: #xE2 #x80 #x99\r
87             file code: #xE2 #x80 #x99 (encoded by coding system utf-8)\r
88 \r
89 buffer-file-coding-system is, of course, utf-8.\r
90 \r
91 Writing this buffer using C-x C-w encodes it correctly too. So I think\r
92 this is an emacs MIME problem. We call mm-save-part, which calls\r
93 mm-save-part-to-file, which calls mm-with-unibyte-buffer. Hmm..\r
94 \r
95 Indeed, it seems that inserting this character into a file that's been\r
96 marked "unibyte" using (set-buffer-multibyte nil) turns it into the ^Y\r
97 character (ASCII code 0x19 -- the character that comes out in the patch\r
98 file). There's probably a technical reason that this should be true, but\r
99 I can't think of why that would be.\r
100 \r
101 > I attempted a set of trial-&-error tricks to get the attachment\r
102 > saved "correctly", and at least this seems to do the trick:\r
103 >\r
104 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
105 > index f273eb4..a6a85c0 100644\r
106 > --- a/emacs/notmuch-show.el\r
107 > +++ b/emacs/notmuch-show.el\r
108 > @@ -203,9 +203,11 @@ For example, if you wanted to remove an \"unread\" tag and add a\r
109 >       (let ((id (notmuch-show-get-message-id)))\r
110 >         (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"))))\r
111 >           (with-current-buffer buf\r
112 > -         (call-process notmuch-command nil t nil "show" "--format=raw" id)\r
113 > -           ,@body)\r
114 > -      (kill-buffer buf)))))\r
115 > +        (let ((coding-system-for-read 'no-conversion)\r
116 > +              (coding-system-for-write 'no-conversion))\r
117 > +          (call-process notmuch-command nil t nil "show" "--format=raw" id)\r
118 > +          ,@body))))))\r
119 > +%%    (kill-buffer buf)))))\r
120 [snip]\r
121 > (kill-buffer is outcommented above for testing purposes)\r
122 >\r
123 > To test this this needs to me evaluated and then the functions\r
124 > using this macro (notmuch-show-save-attachments  in this case)\r
125 >\r
126 > Smart suggestions for proper fix ?\r
127 \r
128 Well, we could limit it just to saving attachments (putting the let\r
129 around the with-current-notmuch-show-message). That feels like it could\r
130 be right, because intuitively saving an attachment should be done\r
131 without any conversions. Or even the above doesn't seem so bad. My vague\r
132 feeling is that messages should always be ASCII, or at least mm-* will\r
133 interpret it that way, so decoding them into any other character set\r
134 might cause problems. Anyone understand character sets?\r
135 \r
136 Ethan\r