Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 55 / a06619968953de7025c792bb2f25c88b244a0d
1 Return-Path: <felipe.contreras@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 95AC4431FC7\r
6         for <notmuch@notmuchmail.org>; Thu,  1 May 2014 16:09:06 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 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, RCVD_IN_DNSWL_LOW=-0.7] 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 Zq3qBGSF5S94 for <notmuch@notmuchmail.org>;\r
17         Thu,  1 May 2014 16:08:59 -0700 (PDT)\r
18 Received: from mail-oa0-f46.google.com (mail-oa0-f46.google.com\r
19         [209.85.219.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 58382431FCF\r
22         for <notmuch@notmuchmail.org>; Thu,  1 May 2014 16:08:46 -0700 (PDT)\r
23 Received: by mail-oa0-f46.google.com with SMTP id i4so3635589oah.33\r
24         for <notmuch@notmuchmail.org>; Thu, 01 May 2014 16:08:45 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
27         bh=nPvjm+fSKBytOKLMOx75NLA3uuT451ifQo99d8PTe/c=;\r
28         b=PUD0I7+ruz/vuNKhKwAivuyjptWvG9tUmQoU6Umz3fCcD73aoC/3X+vUilSzDtEKqz\r
29         l2xHmCp8DIeUwGJNzCdbVUj6o0NfGyKsuiavN7ofz56EaWy5Ib8LXXrgDGpkx6XT5/IG\r
30         esItSM7ibfcSOXKswV9IUailo1mplXZIHfjLxSDRpKfLAtUvMtL2qx14HFFvpGcaz7/v\r
31         OrcDtG3OydRtRuaPw+Vky5XjCCSGE4vdIv0rw5wfRRGbOtBZi46ieewHrUUrKd86L/zJ\r
32         NgZ62rcH69h8/Y6skFxJibInud06//0rxn2qFCj2Ao1FU5EswxcKWRG+Or3kTPiy5NRh\r
33         GPQQ==\r
34 X-Received: by 10.60.51.136 with SMTP id k8mr13555298oeo.33.1398985725880;\r
35         Thu, 01 May 2014 16:08:45 -0700 (PDT)\r
36 Received: from localhost (189-211-224-40.static.axtel.net. [189.211.224.40])\r
37         by mx.google.com with ESMTPSA id\r
38         cq1sm122272455oeb.4.2014.05.01.16.08.43 for <multiple recipients>\r
39         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
40         Thu, 01 May 2014 16:08:44 -0700 (PDT)\r
41 From: Felipe Contreras <felipe.contreras@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2 3/3] vim: improve the way messages are sent\r
44 Date: Thu,  1 May 2014 17:57:54 -0500\r
45 Message-Id: <1398985074-17646-4-git-send-email-felipe.contreras@gmail.com>\r
46 X-Mailer: git-send-email 1.9.2+fc1.19.g85b6256\r
47 In-Reply-To: <1398985074-17646-1-git-send-email-felipe.contreras@gmail.com>\r
48 References: <1398985074-17646-1-git-send-email-felipe.contreras@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Thu, 01 May 2014 23:09:06 -0000\r
62 \r
63 We want the proper encoding and content-type to be set when sending the\r
64 mail, but human-readable plain-text for composing. So split the code in\r
65 two parts: the presentation and the transport conversion.\r
66 \r
67 This fixes an issue while sending non-ascii mails to strict servers; the\r
68 mail needs to be encoded.\r
69 \r
70 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\r
71 ---\r
72  vim/notmuch.vim | 34 +++++++++++++++++++++-------------\r
73  1 file changed, 21 insertions(+), 13 deletions(-)\r
74 \r
75 diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
76 index 0cb94f6..331e930 100644\r
77 --- a/vim/notmuch.vim\r
78 +++ b/vim/notmuch.vim\r
79 @@ -86,17 +86,22 @@ endfunction\r
80  function! s:compose_send()\r
81         let b:compose_done = 1\r
82         let fname = expand('%')\r
83 +       let lines = getline(5, '$')\r
84  \r
85 -       " remove headers\r
86 -       0,4d\r
87 -       write\r
88 +ruby << EOF\r
89 +       # Generate proper mail to send\r
90 +       text = VIM::evaluate('lines').join("\n")\r
91 +       fname = VIM::evaluate('fname')\r
92 +       transport = Mail.new(text)\r
93 +       transport.message_id = generate_message_id\r
94 +       transport.charset = 'utf-8'\r
95 +       File.write(fname, transport.to_s)\r
96 +EOF\r
97  \r
98         let cmdtxt = g:notmuch_sendmail . ' -t -f ' . s:reply_from . ' < ' . fname\r
99         let out = system(cmdtxt)\r
100         let err = v:shell_error\r
101         if err\r
102 -               undo\r
103 -               write\r
104                 echohl Error\r
105                 echo 'Eeek! unable to send mail'\r
106                 echo out\r
107 @@ -572,9 +577,7 @@ ruby << EOF\r
108                         end\r
109                         m.cc = orig[:cc]\r
110                         m.from = $email\r
111 -                       m.message_id = generate_message_id\r
112                         m.charset = 'utf-8'\r
113 -                       m.content_transfer_encoding = '7bit'\r
114                 end\r
115  \r
116                 lines = []\r
117 @@ -600,7 +603,7 @@ ruby << EOF\r
118  \r
119                 reply.body = body_lines.join("\n")\r
120  \r
121 -               lines += reply.to_s.lines.map { |e| e.chomp }\r
122 +               lines += reply.present.lines.map { |e| e.chomp }\r
123                 lines << ""\r
124  \r
125                 cur = lines.count - 1\r
126 @@ -611,18 +614,13 @@ ruby << EOF\r
127         def open_compose()\r
128                 lines = []\r
129  \r
130 -               lines << "Date: #{Time.now().strftime('%a, %-d %b %Y %T %z')}"\r
131                 lines << "From: #{$email}"\r
132                 lines << "To: "\r
133                 cur = lines.count\r
134  \r
135                 lines << "Cc: "\r
136                 lines << "Bcc: "\r
137 -               lines << "Message-Id: #{generate_message_id}"\r
138                 lines << "Subject: "\r
139 -               lines << "Mime-Version: 1.0"\r
140 -               lines << "Content-Type: text/plain; charset=utf-8"\r
141 -               lines << "Content-Transfer-Encoding: 7bit"\r
142                 lines << ""\r
143                 lines << ""\r
144                 lines << ""\r
145 @@ -928,6 +926,16 @@ ruby << EOF\r
146                                 end\r
147                                 text\r
148                         end\r
149 +\r
150 +                       def present\r
151 +                               buffer = ''\r
152 +                               header.fields.each do |f|\r
153 +                                       buffer << "%s: %s\r\n" % [f.name, f.to_s]\r
154 +                               end\r
155 +                               buffer << "\r\n"\r
156 +                               buffer << body.to_s\r
157 +                               buffer\r
158 +                       end\r
159                 end\r
160         end\r
161  \r
162 -- \r
163 1.9.2+fc1.19.g85b6256\r
164 \r