1 Return-Path: <imain@redhat.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 1C671431FDB
\r
6 for <notmuch@notmuchmail.org>; Mon, 27 Oct 2014 11:35:38 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 2W-XsJVbevEP for <notmuch@notmuchmail.org>;
\r
16 Mon, 27 Oct 2014 11:35:30 -0700 (PDT)
\r
17 Received: from cmta7.telus.net (cmta7.telus.net [209.171.16.80])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 1802E431FB6
\r
19 for <notmuch@notmuchmail.org>; Mon, 27 Oct 2014 11:35:30 -0700 (PDT)
\r
20 Received: from ovo.mains.priv ([207.102.88.62]) by cmta7.telus.net with TELUS
\r
21 id 8JbT1p00P1LiWEf01JbTg8; Mon, 27 Oct 2014 12:35:29 -0600
\r
22 X-Authority-Analysis: v=2.0 cv=TdpIQ2sh c=1 sm=2
\r
23 a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=IkcTkHD0fZMA:10 a=tsa3CZZnAAAA:8
\r
24 a=7343-z1_AAAA:8 a=Spc8_jQpWGS_ruRPf4sA:9 a=QEXdDO2ut3YA:10
\r
25 a=8yfeakL6c_qzeTDR:21 a=iGprzabvlFtTil7d:21
\r
26 a=EcQDfIwDZEqJA1f7rVUV8Q==:117
\r
27 X-Telus-Outbound-IP: 207.102.88.62
\r
28 Received: from ovo.mains.priv (localhost.localdomain [127.0.0.1])
\r
29 by ovo.mains.priv (8.14.8/8.14.8) with ESMTP id s9RIZPsd006631;
\r
30 Mon, 27 Oct 2014 11:35:25 -0700
\r
31 Received: (from imain@localhost)
\r
32 by ovo.mains.priv (8.14.8/8.14.8/Submit) id s9RIZMmX006630;
\r
33 Mon, 27 Oct 2014 11:35:22 -0700
\r
34 X-Authentication-Warning: ovo.mains.priv: imain set sender to imain@redhat.com
\r
36 Date: Mon, 27 Oct 2014 11:35:22 -0700
\r
37 From: Ian Main <imain@stemwinder.org>
\r
38 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
\r
39 Message-ID: <544e906a73522_1795163fe8839@ovo.mains.priv.notmuch>
\r
40 In-Reply-To: <m2vbn8mnx7.fsf@guru.guru-group.fi>
\r
41 References: <1414168720-1574-1-git-send-email-imain@stemwinder.org>
\r
42 <m2vbn8mnx7.fsf@guru.guru-group.fi>
\r
43 Subject: Re: [PATCH v4 1/2] VIM: Add better attachment support
\r
45 Content-Type: text/plain;
\r
47 Content-Transfer-Encoding: 7bit
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Mon, 27 Oct 2014 18:35:38 -0000
\r
63 > On Fri, Oct 24 2014, Ian Main <imain@stemwinder.org> wrote:
\r
65 > > Change how the notmuch vim client supports attachments:
\r
67 > > - For each message part a 'Part <number>: <filename>' is added to the
\r
69 > > - You can then use 'e' to extract the attachment under the cursor or
\r
70 > > use it elsewhere to extract all attachments (the prior behavior)
\r
71 > > - You can use 'v' to 'view' the attachment/part using xdg-open by
\r
73 > > - If the message is 'text/html' we include a 'Part:' for the body of
\r
74 > > the message so you can easily view it in a web browser if you so
\r
80 > > - Fixed commit message
\r
81 > > - Fixed documentation
\r
83 > > vim/notmuch.txt | 8 +++++-
\r
84 > > vim/notmuch.vim | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
\r
85 > > 2 files changed, 89 insertions(+), 3 deletions(-)
\r
87 > > diff --git a/vim/notmuch.txt b/vim/notmuch.txt
\r
88 > > index 4374102..d5e1ad2 100644
\r
89 > > --- a/vim/notmuch.txt
\r
90 > > +++ b/vim/notmuch.txt
\r
91 > > @@ -72,6 +72,9 @@ q Quit view
\r
92 > > A Archive (-inbox -unread)
\r
93 > > I Mark as read (-unread)
\r
94 > > t Tag (prompted)
\r
95 > > +e Extract attachment on the current 'Part' line or all
\r
97 > This and the following patch use spaces instead of tab in the line above
\r
98 > (and following patch few lines below) -- the indentation looked weird and
\r
99 > that got me to look more.
\r
101 > I was going to look more of this but run out of time. I'll look the
\r
102 > this through after someone else who uses vim has tested these patched
\r
103 > and reported their experiences.
\r
107 Ah, good catch. Thanks Tomi. I generally run with expandtab which makes
\r
108 vim use spaces instead of tabs. I see in the .vim src file it's set to turn
\r
109 that off but not in the docs. I'll check it myself too.
\r
114 > > + attachments if the cursor is elsewhere.
\r
115 > > +<enter> View attachment on the current 'Part' line.
\r
119 > > @@ -148,6 +151,9 @@ You can also configure your externail mail reader and sendemail program:
\r
121 > > let g:notmuch_reader = 'mutt -f %s'
\r
122 > > let g:notmuch_sendmail = 'sendmail'
\r
125 > > +You can also configure what probram is used to view attachments:
\r
127 > > + let g:notmuch_view_attachment = 'xdg-open'
\r
129 > > vim:tw=78:ts=8:noet:ft=help:
\r
130 > > diff --git a/vim/notmuch.vim b/vim/notmuch.vim
\r
131 > > index cad9517..1466e50 100644
\r
132 > > --- a/vim/notmuch.vim
\r
133 > > +++ b/vim/notmuch.vim
\r
134 > > @@ -35,6 +35,7 @@ let g:notmuch_show_maps = {
\r
135 > > \ 't': 'show_tag("")',
\r
136 > > \ 'o': 'show_open_msg()',
\r
137 > > \ 'e': 'show_extract_msg()',
\r
138 > > + \ '<Enter>': 'show_view_attachment()',
\r
139 > > \ 's': 'show_save_msg()',
\r
140 > > \ 'p': 'show_save_patches()',
\r
141 > > \ 'r': 'show_reply()',
\r
142 > > @@ -58,6 +59,8 @@ let s:notmuch_date_format_default = '%d.%m.%y'
\r
143 > > let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
\r
144 > > let s:notmuch_reader_default = 'mutt -f %s'
\r
145 > > let s:notmuch_sendmail_default = 'sendmail'
\r
146 > > +let s:notmuch_view_attachment_default = 'xdg-open'
\r
147 > > +let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'
\r
148 > > let s:notmuch_folders_count_threads_default = 0
\r
149 > > let s:notmuch_compose_start_insert_default = 1
\r
151 > > @@ -152,13 +155,72 @@ function! s:show_info()
\r
152 > > ruby vim_puts get_message.inspect
\r
155 > > +function! s:show_view_attachment()
\r
156 > > + let line = getline(".")
\r
158 > > + m = get_message
\r
159 > > + line = VIM::evaluate('line')
\r
161 > > + match = line.match(/^Part (\d*):/)
\r
162 > > + if match and match.length == 2
\r
163 > > + # Set up the tmpdir
\r
164 > > + tmpdir = VIM::evaluate('g:notmuch_attachment_tmpdir')
\r
165 > > + tmpdir = File.expand_path(tmpdir)
\r
166 > > + Dir.mkdir(tmpdir) unless Dir.exists?(tmpdir)
\r
168 > > + p = m.mail.parts[match[1].to_i - 1]
\r
170 > > + # Not a multipart message, use the message itself.
\r
173 > > + if p.filename and p.filename.length > 0
\r
174 > > + filename = p.filename
\r
177 > > + if p.mime_type == 'text/html'
\r
178 > > + suffix = '.html'
\r
180 > > + filename = "part-#{match[1]}#{suffix}"
\r
183 > > + # Sanitize just in case..
\r
184 > > + filename.gsub!(/[^0-9A-Za-z.\-]/, '_')
\r
186 > > + fullpath = File.expand_path("#{tmpdir}/#{filename}")
\r
187 > > + vim_puts "Viewing attachment #{fullpath}"
\r
188 > > + File.open(fullpath, 'w') do |f|
\r
189 > > + f.write p.body.decoded
\r
190 > > + cmd = VIM::evaluate('g:notmuch_view_attachment')
\r
191 > > + system(cmd, fullpath)
\r
194 > > + vim_puts "No attachment on this line."
\r
199 > > function! s:show_extract_msg()
\r
200 > > + let line = getline(".")
\r
202 > > m = get_message
\r
203 > > - m.mail.attachments.each do |a|
\r
204 > > + line = VIM::evaluate('line')
\r
206 > > + # If the user is on a line that has an 'Part'
\r
207 > > + # line, we just extract the one attachment.
\r
208 > > + match = line.match(/^Part (\d*):/)
\r
209 > > + if match and match.length == 2
\r
210 > > + a = m.mail.parts[match[1].to_i - 1]
\r
211 > > File.open(a.filename, 'w') do |f|
\r
212 > > f.write a.body.decoded
\r
213 > > - print "Extracted '#{a.filename}'"
\r
214 > > + vim_puts "Extracted #{a.filename}"
\r
217 > > + # Extract them all..
\r
218 > > + m.mail.attachments.each do |a|
\r
219 > > + File.open(a.filename, 'w') do |f|
\r
220 > > + f.write a.body.decoded
\r
221 > > + vim_puts "Extracted #{a.filename}"
\r
226 > > @@ -331,6 +393,16 @@ ruby << EOF
\r
227 > > b << "To: %s" % msg['to']
\r
228 > > b << "Cc: %s" % msg['cc']
\r
229 > > b << "Date: %s" % msg['date']
\r
231 > > + m.parts.each do |p|
\r
233 > > + b << "Part %d: %s (%s)" % [cnt, p.mime_type, p.filename]
\r
235 > > + # Add a special case for text/html messages. Here we show the
\r
236 > > + # only 'part' so that we can view it in a web browser if we want.
\r
237 > > + if m.parts.length == 0 and part.mime_type == 'text/html'
\r
238 > > + b << "Part 1: text/html"
\r
240 > > nm_m.body_start = b.count
\r
241 > > b << "--- %s ---" % part.mime_type
\r
242 > > part.convert.each_line do |l|
\r
243 > > @@ -425,6 +497,14 @@ function! s:set_defaults()
\r
247 > > + if !exists('g:notmuch_attachment_tmpdir')
\r
248 > > + let g:notmuch_attachment_tmpdir = s:notmuch_attachment_tmpdir_default
\r
251 > > + if !exists('g:notmuch_view_attachment')
\r
252 > > + let g:notmuch_view_attachment = s:notmuch_view_attachment_default
\r
255 > > if !exists('g:notmuch_folders_count_threads')
\r
256 > > if exists('g:notmuch_rb_count_threads')
\r
257 > > let g:notmuch_count_threads = g:notmuch_rb_count_threads
\r
261 > > _______________________________________________
\r
262 > > notmuch mailing list
\r
263 > > notmuch@notmuchmail.org
\r
264 > > http://notmuchmail.org/mailman/listinfo/notmuch
\r