--- /dev/null
+Return-Path: <imain@redhat.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1C671431FDB\r
+ for <notmuch@notmuchmail.org>; Mon, 27 Oct 2014 11:35:38 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 2W-XsJVbevEP for <notmuch@notmuchmail.org>;\r
+ Mon, 27 Oct 2014 11:35:30 -0700 (PDT)\r
+Received: from cmta7.telus.net (cmta7.telus.net [209.171.16.80])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1802E431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 27 Oct 2014 11:35:30 -0700 (PDT)\r
+Received: from ovo.mains.priv ([207.102.88.62]) by cmta7.telus.net with TELUS\r
+ id 8JbT1p00P1LiWEf01JbTg8; Mon, 27 Oct 2014 12:35:29 -0600\r
+X-Authority-Analysis: v=2.0 cv=TdpIQ2sh c=1 sm=2\r
+ a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=IkcTkHD0fZMA:10 a=tsa3CZZnAAAA:8\r
+ a=7343-z1_AAAA:8 a=Spc8_jQpWGS_ruRPf4sA:9 a=QEXdDO2ut3YA:10\r
+ a=8yfeakL6c_qzeTDR:21 a=iGprzabvlFtTil7d:21\r
+ a=EcQDfIwDZEqJA1f7rVUV8Q==:117\r
+X-Telus-Outbound-IP: 207.102.88.62\r
+Received: from ovo.mains.priv (localhost.localdomain [127.0.0.1])\r
+ by ovo.mains.priv (8.14.8/8.14.8) with ESMTP id s9RIZPsd006631;\r
+ Mon, 27 Oct 2014 11:35:25 -0700\r
+Received: (from imain@localhost)\r
+ by ovo.mains.priv (8.14.8/8.14.8/Submit) id s9RIZMmX006630;\r
+ Mon, 27 Oct 2014 11:35:22 -0700\r
+X-Authentication-Warning: ovo.mains.priv: imain set sender to imain@redhat.com\r
+ using -f\r
+Date: Mon, 27 Oct 2014 11:35:22 -0700\r
+From: Ian Main <imain@stemwinder.org>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+Message-ID: <544e906a73522_1795163fe8839@ovo.mains.priv.notmuch>\r
+In-Reply-To: <m2vbn8mnx7.fsf@guru.guru-group.fi>\r
+References: <1414168720-1574-1-git-send-email-imain@stemwinder.org>\r
+ <m2vbn8mnx7.fsf@guru.guru-group.fi>\r
+Subject: Re: [PATCH v4 1/2] VIM: Add better attachment support\r
+Mime-Version: 1.0\r
+Content-Type: text/plain;\r
+ charset=utf-8\r
+Content-Transfer-Encoding: 7bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 27 Oct 2014 18:35:38 -0000\r
+\r
+Tomi Ollila wrote:\r
+> On Fri, Oct 24 2014, Ian Main <imain@stemwinder.org> wrote:\r
+> \r
+> > Change how the notmuch vim client supports attachments:\r
+> >\r
+> > - For each message part a 'Part <number>: <filename>' is added to the\r
+> > header.\r
+> > - You can then use 'e' to extract the attachment under the cursor or\r
+> > use it elsewhere to extract all attachments (the prior behavior)\r
+> > - You can use 'v' to 'view' the attachment/part using xdg-open by\r
+> > default.\r
+> > - If the message is 'text/html' we include a 'Part:' for the body of\r
+> > the message so you can easily view it in a web browser if you so\r
+> > choose.\r
+> >\r
+> > Ian\r
+> > ---\r
+> >\r
+> > - Fixed commit message\r
+> > - Fixed documentation\r
+> >\r
+> > vim/notmuch.txt | 8 +++++-\r
+> > vim/notmuch.vim | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--\r
+> > 2 files changed, 89 insertions(+), 3 deletions(-)\r
+> >\r
+> > diff --git a/vim/notmuch.txt b/vim/notmuch.txt\r
+> > index 4374102..d5e1ad2 100644\r
+> > --- a/vim/notmuch.txt\r
+> > +++ b/vim/notmuch.txt\r
+> > @@ -72,6 +72,9 @@ q Quit view\r
+> > A Archive (-inbox -unread)\r
+> > I Mark as read (-unread)\r
+> > t Tag (prompted)\r
+> > +e Extract attachment on the current 'Part' line or all\r
+> \r
+> This and the following patch use spaces instead of tab in the line above\r
+> (and following patch few lines below) -- the indentation looked weird and\r
+> that got me to look more.\r
+> \r
+> I was going to look more of this but run out of time. I'll look the\r
+> this through after someone else who uses vim has tested these patched\r
+> and reported their experiences.\r
+> \r
+> Tomi\r
+\r
+Ah, good catch. Thanks Tomi. I generally run with expandtab which makes\r
+vim use spaces instead of tabs. I see in the .vim src file it's set to turn\r
+that off but not in the docs. I'll check it myself too.\r
+\r
+ Ian\r
+\r
+\r
+> > + attachments if the cursor is elsewhere.\r
+> > +<enter> View attachment on the current 'Part' line.\r
+> > s Search\r
+> > p Save patches\r
+> > r Reply\r
+> > @@ -148,6 +151,9 @@ You can also configure your externail mail reader and sendemail program:\r
+> > >\r
+> > let g:notmuch_reader = 'mutt -f %s'\r
+> > let g:notmuch_sendmail = 'sendmail'\r
+> > -<\r
+> > +\r
+> > +You can also configure what probram is used to view attachments:\r
+> > +\r
+> > + let g:notmuch_view_attachment = 'xdg-open'\r
+> > \r
+> > vim:tw=78:ts=8:noet:ft=help:\r
+> > diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
+> > index cad9517..1466e50 100644\r
+> > --- a/vim/notmuch.vim\r
+> > +++ b/vim/notmuch.vim\r
+> > @@ -35,6 +35,7 @@ let g:notmuch_show_maps = {\r
+> > \ 't': 'show_tag("")',\r
+> > \ 'o': 'show_open_msg()',\r
+> > \ 'e': 'show_extract_msg()',\r
+> > + \ '<Enter>': 'show_view_attachment()',\r
+> > \ 's': 'show_save_msg()',\r
+> > \ 'p': 'show_save_patches()',\r
+> > \ 'r': 'show_reply()',\r
+> > @@ -58,6 +59,8 @@ let s:notmuch_date_format_default = '%d.%m.%y'\r
+> > let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'\r
+> > let s:notmuch_reader_default = 'mutt -f %s'\r
+> > let s:notmuch_sendmail_default = 'sendmail'\r
+> > +let s:notmuch_view_attachment_default = 'xdg-open'\r
+> > +let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'\r
+> > let s:notmuch_folders_count_threads_default = 0\r
+> > let s:notmuch_compose_start_insert_default = 1\r
+> > \r
+> > @@ -152,13 +155,72 @@ function! s:show_info()\r
+> > ruby vim_puts get_message.inspect\r
+> > endfunction\r
+> > \r
+> > +function! s:show_view_attachment()\r
+> > + let line = getline(".")\r
+> > +ruby << EOF\r
+> > + m = get_message\r
+> > + line = VIM::evaluate('line')\r
+> > +\r
+> > + match = line.match(/^Part (\d*):/)\r
+> > + if match and match.length == 2\r
+> > + # Set up the tmpdir\r
+> > + tmpdir = VIM::evaluate('g:notmuch_attachment_tmpdir')\r
+> > + tmpdir = File.expand_path(tmpdir)\r
+> > + Dir.mkdir(tmpdir) unless Dir.exists?(tmpdir)\r
+> > +\r
+> > + p = m.mail.parts[match[1].to_i - 1]\r
+> > + if p == nil\r
+> > + # Not a multipart message, use the message itself.\r
+> > + p = m.mail\r
+> > + end\r
+> > + if p.filename and p.filename.length > 0\r
+> > + filename = p.filename\r
+> > + else\r
+> > + suffix = ''\r
+> > + if p.mime_type == 'text/html'\r
+> > + suffix = '.html'\r
+> > + end\r
+> > + filename = "part-#{match[1]}#{suffix}"\r
+> > + end\r
+> > +\r
+> > + # Sanitize just in case..\r
+> > + filename.gsub!(/[^0-9A-Za-z.\-]/, '_')\r
+> > +\r
+> > + fullpath = File.expand_path("#{tmpdir}/#{filename}")\r
+> > + vim_puts "Viewing attachment #{fullpath}"\r
+> > + File.open(fullpath, 'w') do |f|\r
+> > + f.write p.body.decoded\r
+> > + cmd = VIM::evaluate('g:notmuch_view_attachment')\r
+> > + system(cmd, fullpath)\r
+> > + end\r
+> > + else\r
+> > + vim_puts "No attachment on this line."\r
+> > + end\r
+> > +EOF\r
+> > +endfunction\r
+> > +\r
+> > function! s:show_extract_msg()\r
+> > + let line = getline(".")\r
+> > ruby << EOF\r
+> > m = get_message\r
+> > - m.mail.attachments.each do |a|\r
+> > + line = VIM::evaluate('line')\r
+> > +\r
+> > + # If the user is on a line that has an 'Part'\r
+> > + # line, we just extract the one attachment.\r
+> > + match = line.match(/^Part (\d*):/)\r
+> > + if match and match.length == 2\r
+> > + a = m.mail.parts[match[1].to_i - 1]\r
+> > File.open(a.filename, 'w') do |f|\r
+> > f.write a.body.decoded\r
+> > - print "Extracted '#{a.filename}'"\r
+> > + vim_puts "Extracted #{a.filename}"\r
+> > + end\r
+> > + else\r
+> > + # Extract them all..\r
+> > + m.mail.attachments.each do |a|\r
+> > + File.open(a.filename, 'w') do |f|\r
+> > + f.write a.body.decoded\r
+> > + vim_puts "Extracted #{a.filename}"\r
+> > + end\r
+> > end\r
+> > end\r
+> > EOF\r
+> > @@ -331,6 +393,16 @@ ruby << EOF\r
+> > b << "To: %s" % msg['to']\r
+> > b << "Cc: %s" % msg['cc']\r
+> > b << "Date: %s" % msg['date']\r
+> > + cnt = 0\r
+> > + m.parts.each do |p|\r
+> > + cnt += 1\r
+> > + b << "Part %d: %s (%s)" % [cnt, p.mime_type, p.filename]\r
+> > + end\r
+> > + # Add a special case for text/html messages. Here we show the\r
+> > + # only 'part' so that we can view it in a web browser if we want.\r
+> > + if m.parts.length == 0 and part.mime_type == 'text/html'\r
+> > + b << "Part 1: text/html"\r
+> > + end\r
+> > nm_m.body_start = b.count\r
+> > b << "--- %s ---" % part.mime_type\r
+> > part.convert.each_line do |l|\r
+> > @@ -425,6 +497,14 @@ function! s:set_defaults()\r
+> > endif\r
+> > endif\r
+> > \r
+> > + if !exists('g:notmuch_attachment_tmpdir')\r
+> > + let g:notmuch_attachment_tmpdir = s:notmuch_attachment_tmpdir_default\r
+> > + endif\r
+> > +\r
+> > + if !exists('g:notmuch_view_attachment')\r
+> > + let g:notmuch_view_attachment = s:notmuch_view_attachment_default\r
+> > + endif\r
+> > +\r
+> > if !exists('g:notmuch_folders_count_threads')\r
+> > if exists('g:notmuch_rb_count_threads')\r
+> > let g:notmuch_count_threads = g:notmuch_rb_count_threads\r
+> > -- \r
+> > 1.9.3\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+\r