1 Return-Path: <alpine.art.de@gmail.com>
\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 9AB4F431FBF
\r
6 for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 02:44:58 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 7-SUdMkrZ39w for <notmuch@notmuchmail.org>;
\r
17 Fri, 10 Oct 2014 02:44:51 -0700 (PDT)
\r
18 Received: from mail-la0-f44.google.com (mail-la0-f44.google.com
\r
19 [209.85.215.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 1C72E431FBC
\r
22 for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 02:44:50 -0700 (PDT)
\r
23 Received: by mail-la0-f44.google.com with SMTP id hs14so2835564lab.31
\r
24 for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 02:44:49 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=date:message-id:from:to:subject:in-reply-to:references:mime-version
\r
27 :content-type:content-disposition:content-transfer-encoding;
\r
28 bh=GDCdTPNQvzDxSo1TqZG1AmVGDq30JuUJ+4zfpXPSIn8=;
\r
29 b=YeSO3XIlGc4UHcR0/iqu0rBC1KM1IzqNii3RnkNk8XSoSFhLxYVQm5HKdbqSMwi+dH
\r
30 dQB3XJVSB0Ui/0ptnpnaAWnyKhNssK+6x1/hO0Yx02yEbtvw1p3IYezTdPB1wZpwxchr
\r
31 fbYoKgVbOpHAg0BPiloTQsF299BwusXOKVHGfjUrLh5a6a77HDJG429bJN7Fek92GgFt
\r
32 r65cI2Cs+YlH5UbtcvtUdQXpuYBfy/m4I3hVt/a95SCWGFmiNFxswQ/TCJnyCqrbJjfu
\r
33 lH+CBRP9Q5yZPcMaqTgZ0ENi2tpRqODDMvoNcjZlq4SpSzac7ZIpXil/X3GyDwaqDbGq
\r
35 X-Received: by 10.112.201.72 with SMTP id jy8mr3420236lbc.78.1412934289222;
\r
36 Fri, 10 Oct 2014 02:44:49 -0700 (PDT)
\r
37 Received: from localhost (p5B00C9E6.dip0.t-ipconnect.de. [91.0.201.230])
\r
38 by mx.google.com with ESMTPSA id p5sm1684154lag.1.2014.10.10.02.44.47
\r
39 for <notmuch@notmuchmail.org>
\r
40 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
41 Fri, 10 Oct 2014 02:44:48 -0700 (PDT)
\r
42 Date: Fri, 10 Oct 2014 11:44:57 +0200
\r
43 Message-ID: <20141010114457.GG28601@TP_L520.localdomain>
\r
44 From: Franz Fellner <alpine.art.de@gmail.com>
\r
45 To: notmuch@notmuchmail.org
\r
46 Subject: Re: [PATCH] VIM: Add URI handling
\r
47 In-Reply-To: <1412281423-22441-1-git-send-email-imain@stemwinder.org>
\r
48 References: <1412281423-22441-1-git-send-email-imain@stemwinder.org>
\r
50 Content-Type: text/plain; charset=utf-8
\r
51 Content-Disposition: inline
\r
52 Content-Transfer-Encoding: 8bit
\r
53 X-BeenThere: notmuch@notmuchmail.org
\r
54 X-Mailman-Version: 2.1.13
\r
56 List-Id: "Use and development of the notmuch mail system."
\r
57 <notmuch.notmuchmail.org>
\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
61 List-Post: <mailto:notmuch@notmuchmail.org>
\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
65 X-List-Received-Date: Fri, 10 Oct 2014 09:44:58 -0000
\r
67 Works nice. Tested with an https and a mailto URI.
\r
68 But it would be awesome if you could add message id handling, So one
\r
69 could easily navigate to linked messages. I only found emacs client
\r
70 implement this feature. What I read in the docs about ruby URI module
\r
71 it should be fairly easy to add a custom scheme for id.
\r
73 On Thu, 2 Oct 2014 13:23:43 -0700, Ian Main <imain@stemwinder.org> wrote:
\r
74 > This patch adds URI handling to the vim client. You can now press
\r
75 > 'u' by default and the client will parse the current line and find
\r
76 > any URIs available. If there are more than one it opens the one
\r
77 > under the cursor or else it opens the only one available. It also
\r
78 > supports mailto: URI's and will compose a new message when activated.
\r
80 > By default xdg-open is used for everything but mailto: which generally
\r
81 > does the right thing afaict.
\r
85 > vim/notmuch.txt | 1 +
\r
86 > vim/notmuch.vim | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
\r
87 > 2 files changed, 53 insertions(+), 7 deletions(-)
\r
89 > diff --git a/vim/notmuch.txt b/vim/notmuch.txt
\r
90 > index 4374102..d336406 100644
\r
91 > --- a/vim/notmuch.txt
\r
92 > +++ b/vim/notmuch.txt
\r
93 > @@ -72,6 +72,7 @@ q Quit view
\r
94 > A Archive (-inbox -unread)
\r
95 > I Mark as read (-unread)
\r
101 > diff --git a/vim/notmuch.vim b/vim/notmuch.vim
\r
102 > index 331e930..de82bb9 100644
\r
103 > --- a/vim/notmuch.vim
\r
104 > +++ b/vim/notmuch.vim
\r
105 > @@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
\r
106 > \ '<Enter>': 'folders_show_search()',
\r
107 > \ 's': 'folders_search_prompt()',
\r
108 > \ '=': 'folders_refresh()',
\r
109 > - \ 'c': 'compose()',
\r
110 > + \ 'c': 'compose("")',
\r
113 > let g:notmuch_search_maps = {
\r
114 > @@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
\r
115 > \ 's': 'search_search_prompt()',
\r
116 > \ '=': 'search_refresh()',
\r
117 > \ '?': 'search_info()',
\r
118 > - \ 'c': 'compose()',
\r
119 > + \ 'c': 'compose("")',
\r
122 > let g:notmuch_show_maps = {
\r
123 > @@ -37,10 +37,11 @@ let g:notmuch_show_maps = {
\r
124 > \ 'e': 'show_extract_msg()',
\r
125 > \ 's': 'show_save_msg()',
\r
126 > \ 'p': 'show_save_patches()',
\r
127 > + \ 'u': 'show_open_uri()',
\r
128 > \ 'r': 'show_reply()',
\r
129 > \ '?': 'show_info()',
\r
130 > \ '<Tab>': 'show_next_msg()',
\r
131 > - \ 'c': 'compose()',
\r
132 > + \ 'c': 'compose("")',
\r
135 > let g:notmuch_compose_maps = {
\r
136 > @@ -59,6 +60,7 @@ let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
\r
137 > let s:notmuch_reader_default = 'mutt -f %s'
\r
138 > let s:notmuch_sendmail_default = 'sendmail'
\r
139 > let s:notmuch_folders_count_threads_default = 0
\r
140 > +let s:notmuch_open_uri_default = 'xdg-open'
\r
142 > function! s:new_file_buffer(type, fname)
\r
143 > exec printf('edit %s', a:fname)
\r
144 > @@ -135,8 +137,8 @@ function! s:show_reply()
\r
148 > -function! s:compose()
\r
149 > - ruby open_compose
\r
150 > +function! s:compose(to_email)
\r
151 > + ruby open_compose(VIM::evaluate('a:to_email'))
\r
152 > let b:compose_done = 0
\r
153 > call s:set_map(g:notmuch_compose_maps)
\r
154 > autocmd BufDelete <buffer> call s:on_compose_delete()
\r
155 > @@ -159,6 +161,45 @@ ruby << EOF
\r
159 > +function! s:show_open_uri()
\r
160 > + let line = getline(".")
\r
161 > + let pos = getpos(".")
\r
162 > + let col = pos[2]
\r
164 > + m = get_message
\r
165 > + line = VIM::evaluate('line')
\r
166 > + col = VIM::evaluate('col') - 1
\r
167 > + uris = URI.extract(line)
\r
168 > + wanted_uri = nil
\r
169 > + if uris.length == 1
\r
170 > + wanted_uri = uris[0]
\r
172 > + uris.each do |uri|
\r
173 > + # Check to see the URI is at the present cursor location
\r
174 > + idx = line.index(uri)
\r
175 > + if col >= idx and col <= idx + uri.length
\r
176 > + wanted_uri = uri
\r
183 > + uri = URI.parse(wanted_uri)
\r
184 > + if uri.class == URI::MailTo
\r
185 > + vim_puts("Composing new email to #{uri.to}.")
\r
186 > + VIM::command("call s:compose('#{uri.to}')")
\r
188 > + vim_puts("Opening #{uri.to_s}.")
\r
189 > + cmd = VIM::evaluate('g:notmuch_open_uri')
\r
190 > + system(cmd, uri.to_s)
\r
193 > + vim_puts('URI not found.')
\r
198 > function! s:show_open_msg()
\r
201 > @@ -404,6 +445,10 @@ function! s:set_defaults()
\r
205 > + if !exists('g:notmuch_open_uri')
\r
206 > + let g:notmuch_open_uri = s:notmuch_open_uri_default
\r
209 > if !exists('g:notmuch_reader')
\r
210 > if exists('g:notmuch_rb_reader')
\r
211 > let g:notmuch_reader = g:notmuch_rb_reader
\r
212 > @@ -611,11 +656,11 @@ ruby << EOF
\r
213 > open_compose_helper(lines, cur)
\r
216 > - def open_compose()
\r
217 > + def open_compose(to_email)
\r
220 > lines << "From: #{$email}"
\r
221 > - lines << "To: "
\r
222 > + lines << "To: #{to_email}"
\r
223 > cur = lines.count
\r
229 > _______________________________________________
\r
230 > notmuch mailing list
\r
231 > notmuch@notmuchmail.org
\r
232 > http://notmuchmail.org/mailman/listinfo/notmuch
\r