Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 41 / 0244dbd71fe87edc1dfa2e3cc5aa62703ae276
1 Return-Path: <rharper@shake.ath.cx>\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 07292429E32\r
6         for <notmuch@notmuchmail.org>; Fri, 16 Sep 2011 19:28:20 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 vMLxywY6VlFi for <notmuch@notmuchmail.org>;\r
16         Fri, 16 Sep 2011 19:28:18 -0700 (PDT)\r
17 Received: from mail-gy0-f181.google.com (mail-gy0-f181.google.com\r
18         [209.85.160.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 57029429E30\r
21         for <notmuch@notmuchmail.org>; Fri, 16 Sep 2011 19:28:17 -0700 (PDT)\r
22 Received: by gyd10 with SMTP id 10so4341553gyd.26\r
23         for <notmuch@notmuchmail.org>; Fri, 16 Sep 2011 19:28:16 -0700 (PDT)\r
24 Received: by 10.100.165.5 with SMTP id n5mr74664ane.45.1316226496554;\r
25         Fri, 16 Sep 2011 19:28:16 -0700 (PDT)\r
26 Received: from localhost.localdomain\r
27         (r74-193-78-30.pfvlcmta01.grtntx.tl.dh.suddenlink.net [74.193.78.30])\r
28         by mx.google.com with ESMTPS id u13sm27862929anf.14.2011.09.16.19.28.15\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Fri, 16 Sep 2011 19:28:15 -0700 (PDT)\r
31 From: Ryan Harper <rharper@shake.ath.cx>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH 2/2] vim plugin: Implement attachment saving\r
34 Date: Fri, 16 Sep 2011 21:27:50 -0500\r
35 Message-Id: <1316226470-30001-3-git-send-email-rharper@shake.ath.cx>\r
36 X-Mailer: git-send-email 1.7.1\r
37 In-Reply-To: <1316226470-30001-1-git-send-email-rharper@shake.ath.cx>\r
38 References: <1316226470-30001-1-git-send-email-rharper@shake.ath.cx>\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Sat, 17 Sep 2011 02:28:20 -0000\r
52 \r
53 Using the dictionary of attachments in a message we can implement\r
54 saving the attachment.  Select the current attachment under the cursor\r
55 request a new name, but default to the extracted name.\r
56 \r
57 Currently saves to the current working directory.\r
58 \r
59 Signed-off-by: Ryan Harper <rharper@shake.ath.cx>\r
60 ---\r
61  vim/plugin/notmuch.vim |   50 ++++++++++++++++++++++++++++++++++++++++++++++++\r
62  1 files changed, 50 insertions(+), 0 deletions(-)\r
63 \r
64 diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim\r
65 index cbc5b51..efa6fca 100644\r
66 --- a/vim/plugin/notmuch.vim\r
67 +++ b/vim/plugin/notmuch.vim\r
68 @@ -158,6 +158,7 @@ let g:notmuch_show_maps = {\r
69          \ 'd':          ':call <SID>NM_show_delete_message()<CR>',\r
70          \ 'N':          ':call <SID>NM_show_mark_read_then_next_open_message()<CR>',\r
71          \ 'v':          ':call <SID>NM_show_view_all_mime_parts()<CR>',\r
72 +        \ 'S':          ':call <SID>NM_show_save_mime_parts()<CR>',\r
73          \ '+':          ':call <SID>NM_show_add_tag()<CR>',\r
74          \ '-':          ':call <SID>NM_show_remove_tag()<CR>',\r
75          \ '<Space>':    ':call <SID>NM_show_advance_marking_read_and_archiving()<CR>',\r
76 @@ -607,6 +608,55 @@ function! s:NM_show_view_all_mime_parts()\r
77          call <SID>NM_set_map('n', g:notmuch_show_maps)\r
78  endfunction\r
79  \r
80 +function! s:NM_show_save_mime_part()\r
81 +        let attachments = b:attachments\r
82 +        let info = b:nm_raw_info\r
83 +        let words = b:nm_search_words\r
84 +        let lnum = line('.')\r
85 +        let curline = getline(lnum)\r
86 +        let curatt = {}\r
87 +\r
88 +        " need to extract the id from the current line to\r
89 +        " use to find which attachment from the list we're\r
90 +        " attempting to save\r
91 +        let m = matchlist(curline, '\(\d\+\)')\r
92 +        if len(m)\r
93 +                let id = m[1]\r
94 +                for a in attachments\r
95 +                        if a['id'] == id\r
96 +                                let curatt = a\r
97 +                                break\r
98 +                        endif\r
99 +                endfor\r
100 +        endif\r
101 +\r
102 +\r
103 +        let fn = curatt['filename']\r
104 +        let prompt = printf('Save: %s', fn)\r
105 +        let outfile = input(prompt)\r
106 +        if strlen(outfile)\r
107 +                echo outfile\r
108 +        else\r
109 +                let outfile = fn\r
110 +        endif\r
111 +\r
112 +        "build save command:\r
113 +        " notmuch show --part=<part num> <msg_id> AND <search terms> >$filename < /dev/null\r
114 +        let cmd = ["show"]\r
115 +        call add(cmd, printf("--part=%s", curatt['id']))\r
116 +        call add(cmd, curatt['mid'])\r
117 +        call add(cmd, 'AND')\r
118 +        call extend(cmd, <SID>NM_get_search_words())\r
119 +        call add(cmd, printf('>%s', outfile))\r
120 +\r
121 +        "invoke notmuch via shell\r
122 +        let nmcmd = g:notmuch_cmd . ' ' . join(cmd) . '< /dev/null'\r
123 +        let out = system(nmcmd)\r
124 +        let err = v:shell_error\r
125 +        " TODO: error handling\r
126 +\r
127 +endfunction\r
128 +\r
129  function! s:NM_show_view_raw_message()\r
130          echo 'not implemented'\r
131  endfunction\r
132 -- \r
133 1.7.6\r
134 \r