--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 18317431FDB\r
+ for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 02:53:21 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 56ZtnpdRtCiN for <notmuch@notmuchmail.org>;\r
+ Fri, 24 Oct 2014 02:53:13 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 50A16431FD8\r
+ for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 02:53:13 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 15A9E10008C;\r
+ Fri, 24 Oct 2014 12:52:51 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Ian Main <imain@stemwinder.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] VIM: Add URI handling\r
+In-Reply-To: <1414102794-12094-1-git-send-email-imain@stemwinder.org>\r
+References: <1412281423-22441-1-git-send-email-imain@stemwinder.org>\r
+ <1414102794-12094-1-git-send-email-imain@stemwinder.org>\r
+User-Agent: Notmuch/0.18.1+130~ga61922f (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Fri, 24 Oct 2014 12:52:51 +0300\r
+Message-ID: <m28uk5eqvg.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Fri, 24 Oct 2014 09:53:21 -0000\r
+\r
+On Fri, Oct 24 2014, Ian Main <imain@stemwinder.org> wrote:\r
+\r
+> Add URI handling to the vim client. You can now press 'enter' by default and\r
+> the client will parse the current line and find any 'Part's or URIs available\r
+> for opening. If there are more than one it opens the one under the cursor or\r
+> else it opens the only one available. It also supports mailto: URI's and will\r
+> compose a new message when activated.\r
+\r
+The lines are way too long in this commit message. 72-chars except in cases\r
+where there is no word breaks in the text.\r
+\r
+id:1414101891-10714-1-git-send-email-imain@stemwinder.org has also one \r
+75-character line (and talks about 'This patch ...' which could be changed\r
+too (but is tolerated if not)).\r
+\r
+Tomi\r
+\r
+>\r
+> By default xdg-open is used for everything but mailto: which generally\r
+> does the right thing afaict.\r
+>\r
+> Note that this is now dependant on the attachment patch in order to make\r
+> the nice 'enter' behavior work for both.\r
+>\r
+> Ian\r
+> ---\r
+> vim/notmuch.txt | 3 ++-\r
+> vim/notmuch.vim | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++------\r
+> 2 files changed, 70 insertions(+), 9 deletions(-)\r
+>\r
+> diff --git a/vim/notmuch.txt b/vim/notmuch.txt\r
+> index 838a904..5d84fde 100644\r
+> --- a/vim/notmuch.txt\r
+> +++ b/vim/notmuch.txt\r
+> @@ -74,7 +74,8 @@ I Mark as read (-unread)\r
+> t Tag (prompted)\r
+> e Extract attachment on the current 'Attachment' line or all\r
+> attachments if the cursor is elsewhere.\r
+> -v View attachment on the current 'Attachment' line.\r
+> +<enter> View email part on the current 'Part' line, or open URI under cursor\r
+> + or on line.\r
+> s Search\r
+> p Save patches\r
+> r Reply\r
+> diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
+> index 1466e50..2f76f55 100644\r
+> --- a/vim/notmuch.vim\r
+> +++ b/vim/notmuch.vim\r
+> @@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {\r
+> \ '<Enter>': 'folders_show_search()',\r
+> \ 's': 'folders_search_prompt()',\r
+> \ '=': 'folders_refresh()',\r
+> - \ 'c': 'compose()',\r
+> + \ 'c': 'compose("")',\r
+> \ }\r
+> \r
+> let g:notmuch_search_maps = {\r
+> @@ -25,7 +25,7 @@ let g:notmuch_search_maps = {\r
+> \ 's': 'search_search_prompt()',\r
+> \ '=': 'search_refresh()',\r
+> \ '?': 'search_info()',\r
+> - \ 'c': 'compose()',\r
+> + \ 'c': 'compose("")',\r
+> \ }\r
+> \r
+> let g:notmuch_show_maps = {\r
+> @@ -35,13 +35,13 @@ let g:notmuch_show_maps = {\r
+> \ 't': 'show_tag("")',\r
+> \ 'o': 'show_open_msg()',\r
+> \ 'e': 'show_extract_msg()',\r
+> - \ '<Enter>': 'show_view_attachment()',\r
+> + \ '<Enter>': 'show_view_magic()',\r
+> \ 's': 'show_save_msg()',\r
+> \ 'p': 'show_save_patches()',\r
+> \ 'r': 'show_reply()',\r
+> \ '?': 'show_info()',\r
+> \ '<Tab>': 'show_next_msg()',\r
+> - \ 'c': 'compose()',\r
+> + \ 'c': 'compose("")',\r
+> \ }\r
+> \r
+> let g:notmuch_compose_maps = {\r
+> @@ -63,6 +63,7 @@ let s:notmuch_view_attachment_default = 'xdg-open'\r
+> let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'\r
+> let s:notmuch_folders_count_threads_default = 0\r
+> let s:notmuch_compose_start_insert_default = 1\r
+> +let s:notmuch_open_uri_default = 'xdg-open'\r
+> \r
+> function! s:new_file_buffer(type, fname)\r
+> exec printf('edit %s', a:fname)\r
+> @@ -141,8 +142,8 @@ function! s:show_reply()\r
+> end\r
+> endfunction\r
+> \r
+> -function! s:compose()\r
+> - ruby open_compose\r
+> +function! s:compose(to_email)\r
+> + ruby open_compose(VIM::evaluate('a:to_email'))\r
+> let b:compose_done = 0\r
+> call s:set_map(g:notmuch_compose_maps)\r
+> autocmd BufDelete <buffer> call s:on_compose_delete()\r
+> @@ -155,6 +156,22 @@ function! s:show_info()\r
+> ruby vim_puts get_message.inspect\r
+> endfunction\r
+> \r
+> +function! s:show_view_magic()\r
+> + let line = getline(".")\r
+> +\r
+> +ruby << EOF\r
+> + line = VIM::evaluate('line')\r
+> +\r
+> + # Easiest to check for 'Part' types first..\r
+> + match = line.match(/^Part (\d*):/)\r
+> + if match and match.length == 2\r
+> + VIM::command('call s:show_view_attachment()')\r
+> + else\r
+> + VIM::command('call s:show_open_uri()')\r
+> + end\r
+> +EOF\r
+> +endfunction\r
+> +\r
+> function! s:show_view_attachment()\r
+> let line = getline(".")\r
+> ruby << EOF\r
+> @@ -226,6 +243,45 @@ ruby << EOF\r
+> EOF\r
+> endfunction\r
+> \r
+> +function! s:show_open_uri()\r
+> + let line = getline(".")\r
+> + let pos = getpos(".")\r
+> + let col = pos[2]\r
+> +ruby << EOF\r
+> + m = get_message\r
+> + line = VIM::evaluate('line')\r
+> + col = VIM::evaluate('col') - 1\r
+> + uris = URI.extract(line)\r
+> + wanted_uri = nil\r
+> + if uris.length == 1\r
+> + wanted_uri = uris[0]\r
+> + else\r
+> + uris.each do |uri|\r
+> + # Check to see the URI is at the present cursor location\r
+> + idx = line.index(uri)\r
+> + if col >= idx and col <= idx + uri.length\r
+> + wanted_uri = uri\r
+> + break\r
+> + end\r
+> + end\r
+> + end\r
+> +\r
+> + if wanted_uri\r
+> + uri = URI.parse(wanted_uri)\r
+> + if uri.class == URI::MailTo\r
+> + vim_puts("Composing new email to #{uri.to}.")\r
+> + VIM::command("call s:compose('#{uri.to}')")\r
+> + else\r
+> + vim_puts("Opening #{uri.to_s}.")\r
+> + cmd = VIM::evaluate('g:notmuch_open_uri')\r
+> + system(cmd, uri.to_s)\r
+> + end\r
+> + else\r
+> + vim_puts('URI not found.')\r
+> + end\r
+> +EOF\r
+> +endfunction\r
+> +\r
+> function! s:show_open_msg()\r
+> ruby << EOF\r
+> m = get_message\r
+> @@ -481,6 +537,10 @@ function! s:set_defaults()\r
+> endif\r
+> endif\r
+> \r
+> + if !exists('g:notmuch_open_uri')\r
+> + let g:notmuch_open_uri = s:notmuch_open_uri_default\r
+> + endif\r
+> +\r
+> if !exists('g:notmuch_reader')\r
+> if exists('g:notmuch_rb_reader')\r
+> let g:notmuch_reader = g:notmuch_rb_reader\r
+> @@ -693,11 +753,11 @@ ruby << EOF\r
+> open_compose_helper(lines, cur)\r
+> end\r
+> \r
+> - def open_compose()\r
+> + def open_compose(to_email)\r
+> lines = []\r
+> \r
+> lines << "From: #{$email}"\r
+> - lines << "To: "\r
+> + lines << "To: #{to_email}"\r
+> cur = lines.count\r
+> \r
+> lines << "Cc: "\r
+> -- \r
+> 1.9.3\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r