Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 92AEE429E26 for ; Fri, 16 Sep 2011 19:28:16 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 94XC+X46AAIP for ; Fri, 16 Sep 2011 19:28:15 -0700 (PDT) Received: from mail-gw0-f43.google.com (mail-gw0-f43.google.com [74.125.83.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id C0D7C429E27 for ; Fri, 16 Sep 2011 19:28:13 -0700 (PDT) Received: by gwm11 with SMTP id 11so9581531gwm.2 for ; Fri, 16 Sep 2011 19:28:13 -0700 (PDT) Received: by 10.236.77.133 with SMTP id d5mr380794yhe.75.1316226493151; Fri, 16 Sep 2011 19:28:13 -0700 (PDT) Received: from localhost.localdomain (r74-193-78-30.pfvlcmta01.grtntx.tl.dh.suddenlink.net [74.193.78.30]) by mx.google.com with ESMTPS id u13sm27862929anf.14.2011.09.16.19.28.11 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Sep 2011 19:28:12 -0700 (PDT) From: Ryan Harper 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 Message-Id: <1316226470-30001-2-git-send-email-rharper@shake.ath.cx> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1316226470-30001-1-git-send-email-rharper@shake.ath.cx> References: <1316226470-30001-1-git-send-email-rharper@shake.ath.cx> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Sep 2011 02:28:17 -0000 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 --- 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 = NM_show_message_id() + call add(cmd, NM_show_message_id()) + call add(cmd, 'AND') + call extend(cmd, NM_get_search_words()) + let data = 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 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 NM_set_map('n', g:notmuch_show_maps) endfunction function! s:NM_show_view_raw_message() -- 1.7.6