--- /dev/null
+Return-Path: <imain@stemwinder.org>\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 EC08F431FBC\r
+ for <notmuch@notmuchmail.org>; Thu, 2 Oct 2014 13:23:56 -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\r
+ tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 QBC4wxPKbWQP for <notmuch@notmuchmail.org>;\r
+ Thu, 2 Oct 2014 13:23:49 -0700 (PDT)\r
+Received: from cmta9.telus.net (cmta9.telus.net [209.171.16.82])\r
+ by olra.theworths.org (Postfix) with ESMTP id B6311431FB6\r
+ for <notmuch@notmuchmail.org>; Thu, 2 Oct 2014 13:23:49 -0700 (PDT)\r
+Received: from ovo.mains.priv ([207.102.88.62]) by cmta9.telus.net with TELUS\r
+ id yLPo1o00R1LiWEf01LPoop; Thu, 02 Oct 2014 14:23:49 -0600\r
+X-Authority-Analysis: v=2.0 cv=KNmE+i5o c=1 sm=2\r
+ a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8\r
+ a=QFmAR4G64Eb_gXI2RCcA:9 a=MjTX9qxYB3U_cAoe:21 a=YysiEKMxJFnvkd6R:21\r
+ a=EcQDfIwDZEqJA1f7rVUV8Q==:117\r
+X-Telus-Outbound-IP: 207.102.88.62\r
+From: Ian Main <imain@stemwinder.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] VIM: Add URI handling\r
+Date: Thu, 2 Oct 2014 13:23:43 -0700\r
+Message-Id: <1412281423-22441-1-git-send-email-imain@stemwinder.org>\r
+X-Mailer: git-send-email 1.9.3\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: Thu, 02 Oct 2014 20:23:57 -0000\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
+ Ian\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