--- /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 216F2431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 20 Oct 2014 11:53:41 -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 UyJG36pqWdGg for <notmuch@notmuchmail.org>;\r
+ Mon, 20 Oct 2014 11:53:37 -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 8182D431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 20 Oct 2014 11:53:37 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id BD66D10008C;\r
+ Mon, 20 Oct 2014 21:53:14 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Ian Main <imain@stemwinder.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] VIM: Add URI handling\r
+In-Reply-To: <1412281423-22441-1-git-send-email-imain@stemwinder.org>\r
+References: <1412281423-22441-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: Mon, 20 Oct 2014 21:53:14 +0300\r
+Message-ID: <m2y4sar2sl.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: Mon, 20 Oct 2014 18:53:41 -0000\r
+\r
+On Thu, Oct 02 2014, Ian Main <imain@stemwinder.org> wrote:\r
+\r
+> This patch adds URI handling to the vim client. You can now press\r
+> 'u' by default and the client will parse the current line and find\r
+> any URIs available. If there are more than one it opens the one\r
+> under the cursor or else it opens the only one available. It also\r
+> supports mailto: URI's and will compose a new message when activated.\r
+>\r
+> By default xdg-open is used for everything but mailto: which generally\r
+> does the right thing afaict.\r
+\r
+This patch LGTM.\r
+\r
+>\r
+> Ian\r
+\r
+Tomi\r
+\r
+> ---\r
+> vim/notmuch.txt | 1 +\r
+> vim/notmuch.vim | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------\r
+> 2 files changed, 53 insertions(+), 7 deletions(-)\r
+>\r
+> diff --git a/vim/notmuch.txt b/vim/notmuch.txt\r
+> index 4374102..d336406 100644\r
+> --- a/vim/notmuch.txt\r
+> +++ b/vim/notmuch.txt\r
+> @@ -72,6 +72,7 @@ q Quit view\r
+> A Archive (-inbox -unread)\r
+> I Mark as read (-unread)\r
+> t Tag (prompted)\r
+> +u Open URI\r
+> s Search\r
+> p Save patches\r
+> r Reply\r
+> diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
+> index 331e930..de82bb9 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
+> @@ -37,10 +37,11 @@ let g:notmuch_show_maps = {\r
+> \ 'e': 'show_extract_msg()',\r
+> \ 's': 'show_save_msg()',\r
+> \ 'p': 'show_save_patches()',\r
+> + \ 'u': 'show_open_uri()',\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
+> @@ -59,6 +60,7 @@ let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'\r
+> let s:notmuch_reader_default = 'mutt -f %s'\r
+> let s:notmuch_sendmail_default = 'sendmail'\r
+> let s:notmuch_folders_count_threads_default = 0\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
+> @@ -135,8 +137,8 @@ function! s:show_reply()\r
+> startinsert!\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
+> @@ -159,6 +161,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
+> @@ -404,6 +445,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
+> @@ -611,11 +656,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