[PATCH 1/2] vim plugin: Implement show_view_all_mime_parts
authorRyan Harper <rharper@shake.ath.cx>
Sat, 17 Sep 2011 02:27:49 +0000 (21:27 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:27 +0000 (09:39 -0800)
d9/0db79788943353c101a589c0fc7920fd00806b [new file with mode: 0644]

diff --git a/d9/0db79788943353c101a589c0fc7920fd00806b b/d9/0db79788943353c101a589c0fc7920fd00806b
new file mode 100644 (file)
index 0000000..37bb49b
--- /dev/null
@@ -0,0 +1,128 @@
+Return-Path: <rharper@shake.ath.cx>\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 92AEE429E26\r
+       for <notmuch@notmuchmail.org>; Fri, 16 Sep 2011 19:28:16 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 94XC+X46AAIP for <notmuch@notmuchmail.org>;\r
+       Fri, 16 Sep 2011 19:28:15 -0700 (PDT)\r
+Received: from mail-gw0-f43.google.com (mail-gw0-f43.google.com\r
+ [74.125.83.43])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ C0D7C429E27   for <notmuch@notmuchmail.org>; Fri, 16 Sep 2011 19:28:13 -0700\r
+ (PDT)\r
+Received: by gwm11 with SMTP id 11so9581531gwm.2\r
+       for <notmuch@notmuchmail.org>; Fri, 16 Sep 2011 19:28:13 -0700 (PDT)\r
+Received: by 10.236.77.133 with SMTP id d5mr380794yhe.75.1316226493151;\r
+       Fri, 16 Sep 2011 19:28:13 -0700 (PDT)\r
+Received: from localhost.localdomain\r
+       (r74-193-78-30.pfvlcmta01.grtntx.tl.dh.suddenlink.net [74.193.78.30])\r
+       by mx.google.com with ESMTPS id u13sm27862929anf.14.2011.09.16.19.28.11\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 16 Sep 2011 19:28:12 -0700 (PDT)\r
+From: Ryan Harper <rharper@shake.ath.cx>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] vim plugin: Implement show_view_all_mime_parts\r
+Date: Fri, 16 Sep 2011 21:27:49 -0500\r
+Message-Id: <1316226470-30001-2-git-send-email-rharper@shake.ath.cx>\r
+X-Mailer: git-send-email 1.7.1\r
+In-Reply-To: <1316226470-30001-1-git-send-email-rharper@shake.ath.cx>\r
+References: <1316226470-30001-1-git-send-email-rharper@shake.ath.cx>\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: Sat, 17 Sep 2011 02:28:17 -0000\r
+\r
+Implement mime attachment viewing in the vim plugin via\r
+notmuch show --format=text parsing for attachment segments.\r
+Extract the part ID, filename, and content-type.\r
+\r
+Storing this in a dictionary for use later when implementing\r
+attachment saving.\r
+\r
+Signed-off-by: Ryan Harper <rharper@shake.ath.cx>\r
+---\r
+ vim/plugin/notmuch.vim |   50 +++++++++++++++++++++++++++++++++++++++++++++++-\r
+ 1 files changed, 49 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim\r
+index 21985c7..cbc5b51 100644\r
+--- a/vim/plugin/notmuch.vim\r
++++ b/vim/plugin/notmuch.vim\r
+@@ -556,7 +556,55 @@ function! s:NM_show_reply()\r
+ endfunction\r
\r
+ function! s:NM_show_view_all_mime_parts()\r
+-        echo 'not implemented'\r
++        let info = b:nm_raw_info\r
++        let words = b:nm_search_words\r
++        let cmd = ['show', '--format=text']\r
++        let mid = <SID>NM_show_message_id()\r
++        call add(cmd, <SID>NM_show_message_id())\r
++        call add(cmd, 'AND')\r
++        call extend(cmd, <SID>NM_get_search_words())\r
++        let data = <SID>NM_run(cmd)\r
++        let lines = split(data, "\n")\r
++        let attachments = []\r
++        let bufflines = []\r
++\r
++        for line in lines\r
++                if match(line, g:notmuch_show_attachment_begin_regexp) != -1\r
++                        let m = matchlist(line, 'ID: \(\d\+\), Filename: \(.*\), Content-type: \(\S\+\)')\r
++                        if len(m)\r
++                                " create a attachment dict (id, filename, type, str)\r
++                                " id - message id\r
++                                " filename - filename from MIME attachment\r
++                                " type - Content-type \r
++                                " str - displayable string for the buffer\r
++                                let att = {}\r
++                                let att['id'] = m[1]\r
++                                let att['filename']=m[2]\r
++                                let att['type']=m[3]\r
++                                let att['mid']=mid\r
++                                let id = att['id']\r
++                                let fn = att['filename']\r
++                                let ty = att['type']\r
++                                let att['str']=printf('%d %-60s[%s]', id, fn, ty)\r
++                                call add(attachments, att)\r
++                                call add(bufflines, att['str'])\r
++                        endif\r
++                endif\r
++\r
++        endfor\r
++        if len(attachments) == 0\r
++                echo 'No attachments'\r
++        endif\r
++\r
++        let prev_bufnr = bufnr('%')\r
++        setlocal bufhidden=hide\r
++        call <SID>NM_newBuffer('', 'show', bufflines)\r
++        setlocal bufhidden=delete\r
++        let b:attachments = attachments\r
++        let b:nm_prev_bufnr = prev_bufnr\r
++        let b:nm_raw_info = info\r
++        let b:nm_search_words = words\r
++        call <SID>NM_set_map('n', g:notmuch_show_maps)\r
+ endfunction\r
\r
+ function! s:NM_show_view_raw_message()\r
+-- \r
+1.7.6\r
+\r