Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / b8 / 39fa0a0040361a10c79befd5639f1b5b662c00
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 5556B431FAF\r
6         for <notmuch@notmuchmail.org>; Sat,  2 Nov 2013 07:03:52 -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 R7WjF3S+pRCg for <notmuch@notmuchmail.org>;\r
17         Sat,  2 Nov 2013 07:03:47 -0700 (PDT)\r
18 Received: from mail-oa0-f47.google.com (mail-oa0-f47.google.com\r
19         [209.85.219.47]) (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 D5947429E2F\r
22         for <notmuch@notmuchmail.org>; Sat,  2 Nov 2013 07:03:09 -0700 (PDT)\r
23 Received: by mail-oa0-f47.google.com with SMTP id i1so5600758oag.20\r
24         for <notmuch@notmuchmail.org>; Sat, 02 Nov 2013 07:03:09 -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=nUfpfnyEzVAgubSTNofFIM/3EdIsp9KtsuFNEDp4SOU=;\r
28         b=sAK5o+tEj6oraTSBusDpfG79PUgRF2gy9sKwR3hCq4Wb6vuiUMMrBOtJKzzW19ELFB\r
29         6Y67tvu8nRYuT/AkWUk9uLCejZUQBOtFVKgOc/XNhQYxSjjnUzfYqwm85mCvHZHdmgf6\r
30         Wbq+gOWQgkhBxvJ0eGDcRL3MQICIrEVGNyuyjoX7Vz+Q9TPwqCPa0Hk+mZ86zmgOlzgi\r
31         wdADofOfZHPpincZRhsEw49LCCIBd5jvJf+dkE3Jgp9dLu3gpq7fm64tLYemI2vm9Pme\r
32         H2OAb6BbkZjK7yJB7mHviC6hrAl7XqB4Sehw6XITONZQJaj+9EVOgd03ZMD+EHNMc1eI\r
33         +f2w==\r
34 X-Received: by 10.60.116.230 with SMTP id jz6mr6619934oeb.21.1383400989318;\r
35         Sat, 02 Nov 2013 07:03:09 -0700 (PDT)\r
36 Received: from localhost (187-162-140-241.static.axtel.net. [187.162.140.241])\r
37         by mx.google.com with ESMTPSA id\r
38         ru3sm19958939obc.2.2013.11.02.07.03.07 for <multiple recipients>\r
39         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
40         Sat, 02 Nov 2013 07:03:08 -0700 (PDT)\r
41 From: Felipe Contreras <felipe.contreras@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 13/21] vim: refactor open_reply()\r
44 Date: Sat,  2 Nov 2013 07:55:46 -0600\r
45 Message-Id: <1383400554-1832-14-git-send-email-felipe.contreras@gmail.com>\r
46 X-Mailer: git-send-email 1.8.4.2+fc1\r
47 In-Reply-To: <1383400554-1832-1-git-send-email-felipe.contreras@gmail.com>\r
48 References: <1383400554-1832-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: Sat, 02 Nov 2013 14:03:52 -0000\r
62 \r
63 In preparation for composing new messages.\r
64 \r
65 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\r
66 ---\r
67  vim/notmuch.vim | 92 ++++++++++++++++++++++++++++++---------------------------\r
68  1 file changed, 49 insertions(+), 43 deletions(-)\r
69 \r
70 diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
71 index 9a45300..8383fd6 100644\r
72 --- a/vim/notmuch.vim\r
73 +++ b/vim/notmuch.vim\r
74 @@ -504,12 +504,37 @@ ruby << EOF\r
75                 return "<#{random_tag}@#{Socket.gethostname}.notmuch>"\r
76         end\r
77  \r
78 -       def open_reply(orig)\r
79 +       def open_compose_helper(lines, cur)\r
80                 help_lines = [\r
81                         'Notmuch-Help: Type in your message here; to help you use these bindings:',\r
82                         'Notmuch-Help:   ,s    - send the message (Notmuch-Help lines will be removed)',\r
83                         'Notmuch-Help:   ,q    - abort the message',\r
84                         ]\r
85 +\r
86 +               dir = File.expand_path('~/.notmuch/compose')\r
87 +               FileUtils.mkdir_p(dir)\r
88 +               Tempfile.open(['nm-', '.mail'], dir) do |f|\r
89 +                       f.puts(help_lines)\r
90 +                       f.puts\r
91 +                       f.puts(lines)\r
92 +\r
93 +                       sig_file = File.expand_path('~/.signature')\r
94 +                       if File.exists?(sig_file)\r
95 +                               f.puts("-- ")\r
96 +                               f.write(File.read(sig_file))\r
97 +                       end\r
98 +\r
99 +                       f.flush\r
100 +\r
101 +                       cur += help_lines.size + 1\r
102 +\r
103 +                       VIM::command("let s:reply_from='%s'" % $email_address)\r
104 +                       VIM::command("call s:new_file_buffer('compose', '#{f.path}')")\r
105 +                       VIM::command("call cursor(#{cur}, 0)")\r
106 +               end\r
107 +       end\r
108 +\r
109 +       def open_reply(orig)\r
110                 reply = orig.reply do |m|\r
111                         # fix headers\r
112                         if not m[:reply_to]\r
113 @@ -522,54 +547,35 @@ ruby << EOF\r
114                         m.content_transfer_encoding = '7bit'\r
115                 end\r
116  \r
117 -               dir = File.expand_path('~/.notmuch/compose')\r
118 -               FileUtils.mkdir_p(dir)\r
119 -               Tempfile.open(['nm-', '.mail'], dir) do |f|\r
120 -                       lines = []\r
121 -\r
122 -                       lines += help_lines\r
123 -                       lines << ''\r
124 -\r
125 -                       body_lines = []\r
126 -                       if $mail_installed\r
127 -                               addr = Mail::Address.new(orig[:from].value)\r
128 -                               name = addr.name\r
129 -                               name = addr.local + "@" if name.nil? && !addr.local.nil?\r
130 -                       else\r
131 -                               name = orig[:from]\r
132 -                       end\r
133 -                       name = "somebody" if name.nil?\r
134 -\r
135 -                       body_lines << "%s wrote:" % name\r
136 -                       part = orig.find_first_text\r
137 -                       part.convert.each_line do |l|\r
138 -                               body_lines << "> %s" % l.chomp\r
139 -                       end\r
140 -                       body_lines << ""\r
141 -                       body_lines << ""\r
142 -                       body_lines << ""\r
143 -\r
144 -                       reply.body = body_lines.join("\n")\r
145 +               lines = []\r
146  \r
147 -                       lines += reply.to_s.lines.map { |e| e.chomp }\r
148 -                       lines << ""\r
149 +               body_lines = []\r
150 +               if $mail_installed\r
151 +                       addr = Mail::Address.new(orig[:from].value)\r
152 +                       name = addr.name\r
153 +                       name = addr.local + "@" if name.nil? && !addr.local.nil?\r
154 +               else\r
155 +                       name = orig[:from]\r
156 +               end\r
157 +               name = "somebody" if name.nil?\r
158  \r
159 -                       old_count = lines.count - 1\r
160 +               body_lines << "%s wrote:" % name\r
161 +               part = orig.find_first_text\r
162 +               part.convert.each_line do |l|\r
163 +                       body_lines << "> %s" % l.chomp\r
164 +               end\r
165 +               body_lines << ""\r
166 +               body_lines << ""\r
167 +               body_lines << ""\r
168  \r
169 -                       f.puts(lines)\r
170 +               reply.body = body_lines.join("\n")\r
171  \r
172 -                       sig_file = File.expand_path('~/.signature')\r
173 -                       if File.exists?(sig_file)\r
174 -                               f.puts("-- ")\r
175 -                               f.write(File.read(sig_file))\r
176 -                       end\r
177 +               lines += reply.to_s.lines.map { |e| e.chomp }\r
178 +               lines << ""\r
179  \r
180 -                       f.flush\r
181 +               cur = lines.count - 1\r
182  \r
183 -                       VIM::command("let s:reply_from='%s'" % $email_address)\r
184 -                       VIM::command("call s:new_file_buffer('compose', '#{f.path}')")\r
185 -                       VIM::command("call cursor(#{old_count}, 0)")\r
186 -               end\r
187 +               open_compose_helper(lines, cur)\r
188         end\r
189  \r
190         def folders_render()\r
191 -- \r
192 1.8.4.2+fc1\r
193 \r