[PATCH] lib: provide _notmuch_database_log_append
[notmuch-archives.git] / 57 / 47b9452017a15847d22fd91f1674a036467f9c
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 10762431FC9\r
6         for <notmuch@notmuchmail.org>; Wed, 23 Apr 2014 15:00:27 -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 6c2cbsoe-EyT for <notmuch@notmuchmail.org>;\r
17         Wed, 23 Apr 2014 15:00:19 -0700 (PDT)\r
18 Received: from mail-oa0-f51.google.com (mail-oa0-f51.google.com\r
19         [209.85.219.51]) (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 118BA431FC0\r
22         for <notmuch@notmuchmail.org>; Wed, 23 Apr 2014 15:00:19 -0700 (PDT)\r
23 Received: by mail-oa0-f51.google.com with SMTP id i4so1744627oah.10\r
24         for <notmuch@notmuchmail.org>; Wed, 23 Apr 2014 15:00:18 -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=5WZrBGwG+Wq/OIRrgoXg0bUVHp8n8sI5fjDkKl0vLcE=;\r
28         b=uVkI9/AGQKAq6+991s0LF9bSa4bhze0Utf6+6ZjekeunRmPOomBNRrGsIfe9gRIOkP\r
29         ioKqwnUZyfetohPh4qk/CVDAIQczcY4HEYTadq+Qsfy+Fhl+rawEPTTfJDJVu3UMZxbR\r
30         bdHcrpUzJnV0A4LAezYUokdiAnknbXBmYS1/ugD1BjyJBantD3dF6NkpmBVFxTCYFfn8\r
31         uqRxNWzse6Kalhu+jtwYbCOi4kSyxvDUrNflbHoGpZe+mgpNu0kboCLYqO/Op2i1K55M\r
32         v/nQC99K4L+aQFDKcQXjpEqRrSK2YI/TkoD9N2d/b156AwfQhMyikmvKYxxckr9GY82Q\r
33         hTNA==\r
34 X-Received: by 10.60.159.36 with SMTP id wz4mr45262159oeb.30.1398290418554;\r
35         Wed, 23 Apr 2014 15:00:18 -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 pa3sm4331609obb.6.2014.04.23.15.00.16\r
38         for <multiple recipients>\r
39         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
40         Wed, 23 Apr 2014 15:00:17 -0700 (PDT)\r
41 From: Felipe Contreras <felipe.contreras@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 3/3] Improve the way messages are sent\r
44 Date: Wed, 23 Apr 2014 16:49:44 -0500\r
45 Message-Id: <1398289784-18203-4-git-send-email-felipe.contreras@gmail.com>\r
46 X-Mailer: git-send-email 1.9.2+fc1.2.gfbaae8c\r
47 In-Reply-To: <1398289784-18203-1-git-send-email-felipe.contreras@gmail.com>\r
48 References: <1398289784-18203-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: Wed, 23 Apr 2014 22:00:27 -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 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\r
68 ---\r
69  vim/notmuch.vim | 34 +++++++++++++++++++++-------------\r
70  1 file changed, 21 insertions(+), 13 deletions(-)\r
71 \r
72 diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
73 index 0cb94f6..331e930 100644\r
74 --- a/vim/notmuch.vim\r
75 +++ b/vim/notmuch.vim\r
76 @@ -86,17 +86,22 @@ endfunction\r
77  function! s:compose_send()\r
78         let b:compose_done = 1\r
79         let fname = expand('%')\r
80 +       let lines = getline(5, '$')\r
81  \r
82 -       " remove headers\r
83 -       0,4d\r
84 -       write\r
85 +ruby << EOF\r
86 +       # Generate proper mail to send\r
87 +       text = VIM::evaluate('lines').join("\n")\r
88 +       fname = VIM::evaluate('fname')\r
89 +       transport = Mail.new(text)\r
90 +       transport.message_id = generate_message_id\r
91 +       transport.charset = 'utf-8'\r
92 +       File.write(fname, transport.to_s)\r
93 +EOF\r
94  \r
95         let cmdtxt = g:notmuch_sendmail . ' -t -f ' . s:reply_from . ' < ' . fname\r
96         let out = system(cmdtxt)\r
97         let err = v:shell_error\r
98         if err\r
99 -               undo\r
100 -               write\r
101                 echohl Error\r
102                 echo 'Eeek! unable to send mail'\r
103                 echo out\r
104 @@ -572,9 +577,7 @@ ruby << EOF\r
105                         end\r
106                         m.cc = orig[:cc]\r
107                         m.from = $email\r
108 -                       m.message_id = generate_message_id\r
109                         m.charset = 'utf-8'\r
110 -                       m.content_transfer_encoding = '7bit'\r
111                 end\r
112  \r
113                 lines = []\r
114 @@ -600,7 +603,7 @@ ruby << EOF\r
115  \r
116                 reply.body = body_lines.join("\n")\r
117  \r
118 -               lines += reply.to_s.lines.map { |e| e.chomp }\r
119 +               lines += reply.present.lines.map { |e| e.chomp }\r
120                 lines << ""\r
121  \r
122                 cur = lines.count - 1\r
123 @@ -611,18 +614,13 @@ ruby << EOF\r
124         def open_compose()\r
125                 lines = []\r
126  \r
127 -               lines << "Date: #{Time.now().strftime('%a, %-d %b %Y %T %z')}"\r
128                 lines << "From: #{$email}"\r
129                 lines << "To: "\r
130                 cur = lines.count\r
131  \r
132                 lines << "Cc: "\r
133                 lines << "Bcc: "\r
134 -               lines << "Message-Id: #{generate_message_id}"\r
135                 lines << "Subject: "\r
136 -               lines << "Mime-Version: 1.0"\r
137 -               lines << "Content-Type: text/plain; charset=utf-8"\r
138 -               lines << "Content-Transfer-Encoding: 7bit"\r
139                 lines << ""\r
140                 lines << ""\r
141                 lines << ""\r
142 @@ -928,6 +926,16 @@ ruby << EOF\r
143                                 end\r
144                                 text\r
145                         end\r
146 +\r
147 +                       def present\r
148 +                               buffer = ''\r
149 +                               header.fields.each do |f|\r
150 +                                       buffer << "%s: %s\r\n" % [f.name, f.to_s]\r
151 +                               end\r
152 +                               buffer << "\r\n"\r
153 +                               buffer << body.to_s\r
154 +                               buffer\r
155 +                       end\r
156                 end\r
157         end\r
158  \r
159 -- \r
160 1.9.2+fc1.2.gfbaae8c\r
161 \r