From: Ryan Harper <rharper@shake.ath.cx>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/2] vim plugin: Implement show_view_all_mime_parts
Date: Fri, 16 Sep 2011 21:27:49 -0500 [thread overview]
Message-ID: <1316226470-30001-2-git-send-email-rharper@shake.ath.cx> (raw)
In-Reply-To: <1316226470-30001-1-git-send-email-rharper@shake.ath.cx>
Implement mime attachment viewing in the vim plugin via
notmuch show --format=text parsing for attachment segments.
Extract the part ID, filename, and content-type.
Storing this in a dictionary for use later when implementing
attachment saving.
Signed-off-by: Ryan Harper <rharper@shake.ath.cx>
---
vim/plugin/notmuch.vim | 50 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 21985c7..cbc5b51 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -556,7 +556,55 @@ function! s:NM_show_reply()
endfunction
function! s:NM_show_view_all_mime_parts()
- echo 'not implemented'
+ let info = b:nm_raw_info
+ let words = b:nm_search_words
+ let cmd = ['show', '--format=text']
+ let mid = <SID>NM_show_message_id()
+ call add(cmd, <SID>NM_show_message_id())
+ call add(cmd, 'AND')
+ call extend(cmd, <SID>NM_get_search_words())
+ let data = <SID>NM_run(cmd)
+ let lines = split(data, "\n")
+ let attachments = []
+ let bufflines = []
+
+ for line in lines
+ if match(line, g:notmuch_show_attachment_begin_regexp) != -1
+ let m = matchlist(line, 'ID: \(\d\+\), Filename: \(.*\), Content-type: \(\S\+\)')
+ if len(m)
+ " create a attachment dict (id, filename, type, str)
+ " id - message id
+ " filename - filename from MIME attachment
+ " type - Content-type
+ " str - displayable string for the buffer
+ let att = {}
+ let att['id'] = m[1]
+ let att['filename']=m[2]
+ let att['type']=m[3]
+ let att['mid']=mid
+ let id = att['id']
+ let fn = att['filename']
+ let ty = att['type']
+ let att['str']=printf('%d %-60s[%s]', id, fn, ty)
+ call add(attachments, att)
+ call add(bufflines, att['str'])
+ endif
+ endif
+
+ endfor
+ if len(attachments) == 0
+ echo 'No attachments'
+ endif
+
+ let prev_bufnr = bufnr('%')
+ setlocal bufhidden=hide
+ call <SID>NM_newBuffer('', 'show', bufflines)
+ setlocal bufhidden=delete
+ let b:attachments = attachments
+ let b:nm_prev_bufnr = prev_bufnr
+ let b:nm_raw_info = info
+ let b:nm_search_words = words
+ call <SID>NM_set_map('n', g:notmuch_show_maps)
endfunction
function! s:NM_show_view_raw_message()
--
1.7.6
next prev parent reply other threads:[~2011-09-17 2:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-17 2:27 [PATCH 0/2] vim plugin: implement viewing/saving attachments Ryan Harper
2011-09-17 2:27 ` Ryan Harper [this message]
2011-09-17 2:27 ` [PATCH 2/2] vim plugin: Implement attachment saving Ryan Harper
2012-03-03 3:12 ` Charlie Allom
2011-09-19 0:18 ` [PATCH 0/2] vim plugin: implement viewing/saving attachments Blake Sweeney
2011-09-19 18:15 ` Ryan Harper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1316226470-30001-2-git-send-email-rharper@shake.ath.cx \
--to=rharper@shake.ath.cx \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).