Re: [PATCH v3] emacs: postpone/resume support
[notmuch-archives.git] / fb / dbf19106b535451e384af2f8e1f325f14498f4
1 Return-Path: <tomi.ollila@iki.fi>\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 10868431FBD\r
6         for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 09:31:01 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 fh2Hzo6E3TQA for <notmuch@notmuchmail.org>;\r
16         Fri, 24 Oct 2014 09:30:53 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 7F2AD431FC9\r
19         for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 09:30:53 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id C08E910008C;\r
22         Fri, 24 Oct 2014 19:30:29 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Ian Main <imain@stemwinder.org>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH v3] VIM: Add URI handling\r
26 In-Reply-To: <1414167094-31566-1-git-send-email-imain@stemwinder.org>\r
27 References: <1414102794-12094-1-git-send-email-imain@stemwinder.org>\r
28         <1414167094-31566-1-git-send-email-imain@stemwinder.org>\r
29 User-Agent: Notmuch/0.18.1+130~ga61922f (http://notmuchmail.org) Emacs/24.3.1\r
30         (x86_64-unknown-linux-gnu)\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
32         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
33         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
34 Date: Fri, 24 Oct 2014 19:30:29 +0300\r
35 Message-ID: <m2oat177mi.fsf@guru.guru-group.fi>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Fri, 24 Oct 2014 16:31:01 -0000\r
51 \r
52 On Fri, Oct 24 2014, Ian Main <imain@stemwinder.org> wrote:\r
53 \r
54 This patch does not apply on top of notmuchmail master \r
55 (commit 38240d106139da8).\r
56 \r
57 > This patch adds URI handling to the vim client.  You can now press\r
58 \r
59 Although insignificant, I'll start commenting on all sent patches\r
60 (that I look into) which talk like 'This patch adds' -- sure it is patch\r
61 when email is sent, but in repository it is not so -- so the commit message\r
62 should not mention it (but I do not require changing it).\r
63 \r
64 Anyway, I suspect this change will become applicable after some other\r
65 change is committed first -- and IMO this could stay as non-stale patch\r
66 provided that SomeOne(TM) informs what is the message that contains\r
67 changes (or series those) that is required for this message to apply.\r
68 \r
69 BTW: does the content of this change differ much from v1 at\r
70 id:1412281423-22441-1-git-send-email-imain@stemwinder.org\r
71 or should I re-check (carefully!) that the changes are still OK.\r
72 \r
73 \r
74 Tomi\r
75 \r
76 \r
77 > 'enter' by default and the client will parse the current line and find\r
78 > any 'Part's or URIs available for opening.  If there are more than one\r
79 > it opens the one under the cursor or else it opens the only one\r
80 > available.  It also supports mailto: URI's and will compose a new\r
81 > message when activated.\r
82 >\r
83 > By default xdg-open is used for everything but mailto: which generally\r
84 > does the right thing afaict.\r
85 >\r
86 > Note that this is now dependant on the attachment patch in order to\r
87 > make the nice 'enter' behavior work for both.\r
88 >\r
89 >     Ian\r
90 > ---\r
91 >\r
92 > Fix commit message formatting.\r
93 >\r
94 >  vim/notmuch.txt |  3 ++-\r
95 >  vim/notmuch.vim | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++------\r
96 >  2 files changed, 70 insertions(+), 9 deletions(-)\r
97 >\r
98 > diff --git a/vim/notmuch.txt b/vim/notmuch.txt\r
99 > index 838a904..5d84fde 100644\r
100 > --- a/vim/notmuch.txt\r
101 > +++ b/vim/notmuch.txt\r
102 > @@ -74,7 +74,8 @@ I   Mark as read (-unread)\r
103 >  t    Tag (prompted)\r
104 >  e       Extract attachment on the current 'Attachment' line or all\r
105 >       attachments if the cursor is elsewhere.\r
106 > -v       View attachment on the current 'Attachment' line.\r
107 > +<enter> View email part on the current 'Part' line, or open URI under cursor\r
108 > +        or on line.\r
109 >  s    Search\r
110 >  p    Save patches\r
111 >  r    Reply\r
112 > diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
113 > index 1466e50..2f76f55 100644\r
114 > --- a/vim/notmuch.vim\r
115 > +++ b/vim/notmuch.vim\r
116 > @@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {\r
117 >       \ '<Enter>':    'folders_show_search()',\r
118 >       \ 's':          'folders_search_prompt()',\r
119 >       \ '=':          'folders_refresh()',\r
120 > -     \ 'c':          'compose()',\r
121 > +     \ 'c':          'compose("")',\r
122 >       \ }\r
123 >  \r
124 >  let g:notmuch_search_maps = {\r
125 > @@ -25,7 +25,7 @@ let g:notmuch_search_maps = {\r
126 >       \ 's':          'search_search_prompt()',\r
127 >       \ '=':          'search_refresh()',\r
128 >       \ '?':          'search_info()',\r
129 > -     \ 'c':          'compose()',\r
130 > +     \ 'c':          'compose("")',\r
131 >       \ }\r
132 >  \r
133 >  let g:notmuch_show_maps = {\r
134 > @@ -35,13 +35,13 @@ let g:notmuch_show_maps = {\r
135 >       \ 't':          'show_tag("")',\r
136 >       \ 'o':          'show_open_msg()',\r
137 >       \ 'e':          'show_extract_msg()',\r
138 > -     \ '<Enter>':    'show_view_attachment()',\r
139 > +     \ '<Enter>':    'show_view_magic()',\r
140 >       \ 's':          'show_save_msg()',\r
141 >       \ 'p':          'show_save_patches()',\r
142 >       \ 'r':          'show_reply()',\r
143 >       \ '?':          'show_info()',\r
144 >       \ '<Tab>':      'show_next_msg()',\r
145 > -     \ 'c':          'compose()',\r
146 > +     \ 'c':          'compose("")',\r
147 >       \ }\r
148 >  \r
149 >  let g:notmuch_compose_maps = {\r
150 > @@ -63,6 +63,7 @@ let s:notmuch_view_attachment_default = 'xdg-open'\r
151 >  let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'\r
152 >  let s:notmuch_folders_count_threads_default = 0\r
153 >  let s:notmuch_compose_start_insert_default = 1\r
154 > +let s:notmuch_open_uri_default = 'xdg-open'\r
155 >  \r
156 >  function! s:new_file_buffer(type, fname)\r
157 >       exec printf('edit %s', a:fname)\r
158 > @@ -141,8 +142,8 @@ function! s:show_reply()\r
159 >       end\r
160 >  endfunction\r
161 >  \r
162 > -function! s:compose()\r
163 > -     ruby open_compose\r
164 > +function! s:compose(to_email)\r
165 > +     ruby open_compose(VIM::evaluate('a:to_email'))\r
166 >       let b:compose_done = 0\r
167 >       call s:set_map(g:notmuch_compose_maps)\r
168 >       autocmd BufDelete <buffer> call s:on_compose_delete()\r
169 > @@ -155,6 +156,22 @@ function! s:show_info()\r
170 >       ruby vim_puts get_message.inspect\r
171 >  endfunction\r
172 >  \r
173 > +function! s:show_view_magic()\r
174 > +     let line = getline(".")\r
175 > +\r
176 > +ruby << EOF\r
177 > +     line = VIM::evaluate('line')\r
178 > +\r
179 > +     # Easiest to check for 'Part' types first..\r
180 > +     match = line.match(/^Part (\d*):/)\r
181 > +     if match and match.length == 2\r
182 > +             VIM::command('call s:show_view_attachment()')\r
183 > +     else\r
184 > +             VIM::command('call s:show_open_uri()')\r
185 > +     end\r
186 > +EOF\r
187 > +endfunction\r
188 > +\r
189 >  function! s:show_view_attachment()\r
190 >       let line = getline(".")\r
191 >  ruby << EOF\r
192 > @@ -226,6 +243,45 @@ ruby << EOF\r
193 >  EOF\r
194 >  endfunction\r
195 >  \r
196 > +function! s:show_open_uri()\r
197 > +     let line = getline(".")\r
198 > +     let pos = getpos(".")\r
199 > +     let col = pos[2]\r
200 > +ruby << EOF\r
201 > +     m = get_message\r
202 > +     line = VIM::evaluate('line')\r
203 > +     col = VIM::evaluate('col') - 1\r
204 > +     uris = URI.extract(line)\r
205 > +     wanted_uri = nil\r
206 > +     if uris.length == 1\r
207 > +             wanted_uri = uris[0]\r
208 > +     else\r
209 > +             uris.each do |uri|\r
210 > +                     # Check to see the URI is at the present cursor location\r
211 > +                     idx = line.index(uri)\r
212 > +                     if col >= idx and col <= idx + uri.length\r
213 > +                             wanted_uri = uri\r
214 > +                             break\r
215 > +                     end\r
216 > +             end\r
217 > +     end\r
218 > +\r
219 > +     if wanted_uri\r
220 > +             uri = URI.parse(wanted_uri)\r
221 > +             if uri.class == URI::MailTo\r
222 > +                     vim_puts("Composing new email to #{uri.to}.")\r
223 > +                     VIM::command("call s:compose('#{uri.to}')")\r
224 > +             else\r
225 > +                     vim_puts("Opening #{uri.to_s}.")\r
226 > +                     cmd = VIM::evaluate('g:notmuch_open_uri')\r
227 > +                     system(cmd, uri.to_s)\r
228 > +             end\r
229 > +     else\r
230 > +             vim_puts('URI not found.')\r
231 > +     end\r
232 > +EOF\r
233 > +endfunction\r
234 > +\r
235 >  function! s:show_open_msg()\r
236 >  ruby << EOF\r
237 >       m = get_message\r
238 > @@ -481,6 +537,10 @@ function! s:set_defaults()\r
239 >               endif\r
240 >       endif\r
241 >  \r
242 > +     if !exists('g:notmuch_open_uri')\r
243 > +             let g:notmuch_open_uri = s:notmuch_open_uri_default\r
244 > +     endif\r
245 > +\r
246 >       if !exists('g:notmuch_reader')\r
247 >               if exists('g:notmuch_rb_reader')\r
248 >                       let g:notmuch_reader = g:notmuch_rb_reader\r
249 > @@ -693,11 +753,11 @@ ruby << EOF\r
250 >               open_compose_helper(lines, cur)\r
251 >       end\r
252 >  \r
253 > -     def open_compose()\r
254 > +     def open_compose(to_email)\r
255 >               lines = []\r
256 >  \r
257 >               lines << "From: #{$email}"\r
258 > -             lines << "To: "\r
259 > +             lines << "To: #{to_email}"\r
260 >               cur = lines.count\r
261 >  \r
262 >               lines << "Cc: "\r
263 > -- \r
264 > 1.9.3\r
265 >\r
266 > _______________________________________________\r
267 > notmuch mailing list\r
268 > notmuch@notmuchmail.org\r
269 > http://notmuchmail.org/mailman/listinfo/notmuch\r