unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] VIM: Add URI handling
@ 2014-10-02 20:23 Ian Main
  2014-10-10  9:44 ` Franz Fellner
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Ian Main @ 2014-10-02 20:23 UTC (permalink / raw)
  To: notmuch

This patch adds URI handling to the vim client.  You can now press
'u' by default and the client will parse the current line and find
any URIs available.  If there are more than one it opens the one
under the cursor or else it opens the only one available.  It also
supports mailto: URI's and will compose a new message when activated.

By default xdg-open is used for everything but mailto: which generally
does the right thing afaict.

    Ian
---
 vim/notmuch.txt |  1 +
 vim/notmuch.vim | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/vim/notmuch.txt b/vim/notmuch.txt
index 4374102..d336406 100644
--- a/vim/notmuch.txt
+++ b/vim/notmuch.txt
@@ -72,6 +72,7 @@ q	Quit view
 A	Archive (-inbox -unread)
 I	Mark as read (-unread)
 t	Tag (prompted)
+u	Open URI
 s	Search
 p	Save patches
 r	Reply
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..de82bb9 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
 	\ '<Enter>':	'folders_show_search()',
 	\ 's':		'folders_search_prompt()',
 	\ '=':		'folders_refresh()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_search_maps = {
@@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
 	\ 's':		'search_search_prompt()',
 	\ '=':		'search_refresh()',
 	\ '?':		'search_info()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_show_maps = {
@@ -37,10 +37,11 @@ let g:notmuch_show_maps = {
 	\ 'e':		'show_extract_msg()',
 	\ 's':		'show_save_msg()',
 	\ 'p':		'show_save_patches()',
+	\ 'u':		'show_open_uri()',
 	\ 'r':		'show_reply()',
 	\ '?':		'show_info()',
 	\ '<Tab>':	'show_next_msg()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_compose_maps = {
@@ -59,6 +60,7 @@ let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
 let s:notmuch_reader_default = 'mutt -f %s'
 let s:notmuch_sendmail_default = 'sendmail'
 let s:notmuch_folders_count_threads_default = 0
+let s:notmuch_open_uri_default = 'xdg-open'
 
 function! s:new_file_buffer(type, fname)
 	exec printf('edit %s', a:fname)
@@ -135,8 +137,8 @@ function! s:show_reply()
 	startinsert!
 endfunction
 
-function! s:compose()
-	ruby open_compose
+function! s:compose(to_email)
+	ruby open_compose(VIM::evaluate('a:to_email'))
 	let b:compose_done = 0
 	call s:set_map(g:notmuch_compose_maps)
 	autocmd BufDelete <buffer> call s:on_compose_delete()
@@ -159,6 +161,45 @@ ruby << EOF
 EOF
 endfunction
 
+function! s:show_open_uri()
+	let line = getline(".")
+	let pos = getpos(".")
+	let col = pos[2]
+ruby << EOF
+	m = get_message
+	line = VIM::evaluate('line')
+	col = VIM::evaluate('col') - 1
+	uris = URI.extract(line)
+	wanted_uri = nil
+	if uris.length == 1
+		wanted_uri = uris[0]
+	else
+		uris.each do |uri|
+			# Check to see the URI is at the present cursor location
+			idx = line.index(uri)
+			if col >= idx and col <= idx + uri.length
+				wanted_uri = uri
+				break
+			end
+		end
+	end
+
+	if wanted_uri
+		uri = URI.parse(wanted_uri)
+		if uri.class == URI::MailTo
+			vim_puts("Composing new email to #{uri.to}.")
+			VIM::command("call s:compose('#{uri.to}')")
+		else
+			vim_puts("Opening #{uri.to_s}.")
+			cmd = VIM::evaluate('g:notmuch_open_uri')
+			system(cmd, uri.to_s)
+		end
+	else
+		vim_puts('URI not found.')
+	end
+EOF
+endfunction
+
 function! s:show_open_msg()
 ruby << EOF
 	m = get_message
@@ -404,6 +445,10 @@ function! s:set_defaults()
 		endif
 	endif
 
+	if !exists('g:notmuch_open_uri')
+		let g:notmuch_open_uri = s:notmuch_open_uri_default
+	endif
+
 	if !exists('g:notmuch_reader')
 		if exists('g:notmuch_rb_reader')
 			let g:notmuch_reader = g:notmuch_rb_reader
@@ -611,11 +656,11 @@ ruby << EOF
 		open_compose_helper(lines, cur)
 	end
 
-	def open_compose()
+	def open_compose(to_email)
 		lines = []
 
 		lines << "From: #{$email}"
-		lines << "To: "
+		lines << "To: #{to_email}"
 		cur = lines.count
 
 		lines << "Cc: "
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-02 20:23 [PATCH] VIM: Add URI handling Ian Main
@ 2014-10-10  9:44 ` Franz Fellner
  2014-10-10 18:18   ` Ian Main
  2014-10-20 18:53 ` Tomi Ollila
  2014-10-23 22:19 ` [PATCH v2] " Ian Main
  2 siblings, 1 reply; 16+ messages in thread
From: Franz Fellner @ 2014-10-10  9:44 UTC (permalink / raw)
  To: notmuch

Works nice. Tested with an https and a mailto URI.
But it would be awesome if you could add message id handling, So one
could easily navigate to linked messages. I only found emacs client
implement this feature. What I read in the docs about ruby URI module
it should be fairly easy to add a custom scheme for id.

On Thu,  2 Oct 2014 13:23:43 -0700, Ian Main <imain@stemwinder.org> wrote:
> This patch adds URI handling to the vim client.  You can now press
> 'u' by default and the client will parse the current line and find
> any URIs available.  If there are more than one it opens the one
> under the cursor or else it opens the only one available.  It also
> supports mailto: URI's and will compose a new message when activated.
> 
> By default xdg-open is used for everything but mailto: which generally
> does the right thing afaict.
> 
>     Ian
> ---
>  vim/notmuch.txt |  1 +
>  vim/notmuch.vim | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
>  2 files changed, 53 insertions(+), 7 deletions(-)
> 
> diff --git a/vim/notmuch.txt b/vim/notmuch.txt
> index 4374102..d336406 100644
> --- a/vim/notmuch.txt
> +++ b/vim/notmuch.txt
> @@ -72,6 +72,7 @@ q	Quit view
>  A	Archive (-inbox -unread)
>  I	Mark as read (-unread)
>  t	Tag (prompted)
> +u	Open URI
>  s	Search
>  p	Save patches
>  r	Reply
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 331e930..de82bb9 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
>  	\ '<Enter>':	'folders_show_search()',
>  	\ 's':		'folders_search_prompt()',
>  	\ '=':		'folders_refresh()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_search_maps = {
> @@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
>  	\ 's':		'search_search_prompt()',
>  	\ '=':		'search_refresh()',
>  	\ '?':		'search_info()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_show_maps = {
> @@ -37,10 +37,11 @@ let g:notmuch_show_maps = {
>  	\ 'e':		'show_extract_msg()',
>  	\ 's':		'show_save_msg()',
>  	\ 'p':		'show_save_patches()',
> +	\ 'u':		'show_open_uri()',
>  	\ 'r':		'show_reply()',
>  	\ '?':		'show_info()',
>  	\ '<Tab>':	'show_next_msg()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_compose_maps = {
> @@ -59,6 +60,7 @@ let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
>  let s:notmuch_reader_default = 'mutt -f %s'
>  let s:notmuch_sendmail_default = 'sendmail'
>  let s:notmuch_folders_count_threads_default = 0
> +let s:notmuch_open_uri_default = 'xdg-open'
>  
>  function! s:new_file_buffer(type, fname)
>  	exec printf('edit %s', a:fname)
> @@ -135,8 +137,8 @@ function! s:show_reply()
>  	startinsert!
>  endfunction
>  
> -function! s:compose()
> -	ruby open_compose
> +function! s:compose(to_email)
> +	ruby open_compose(VIM::evaluate('a:to_email'))
>  	let b:compose_done = 0
>  	call s:set_map(g:notmuch_compose_maps)
>  	autocmd BufDelete <buffer> call s:on_compose_delete()
> @@ -159,6 +161,45 @@ ruby << EOF
>  EOF
>  endfunction
>  
> +function! s:show_open_uri()
> +	let line = getline(".")
> +	let pos = getpos(".")
> +	let col = pos[2]
> +ruby << EOF
> +	m = get_message
> +	line = VIM::evaluate('line')
> +	col = VIM::evaluate('col') - 1
> +	uris = URI.extract(line)
> +	wanted_uri = nil
> +	if uris.length == 1
> +		wanted_uri = uris[0]
> +	else
> +		uris.each do |uri|
> +			# Check to see the URI is at the present cursor location
> +			idx = line.index(uri)
> +			if col >= idx and col <= idx + uri.length
> +				wanted_uri = uri
> +				break
> +			end
> +		end
> +	end
> +
> +	if wanted_uri
> +		uri = URI.parse(wanted_uri)
> +		if uri.class == URI::MailTo
> +			vim_puts("Composing new email to #{uri.to}.")
> +			VIM::command("call s:compose('#{uri.to}')")
> +		else
> +			vim_puts("Opening #{uri.to_s}.")
> +			cmd = VIM::evaluate('g:notmuch_open_uri')
> +			system(cmd, uri.to_s)
> +		end
> +	else
> +		vim_puts('URI not found.')
> +	end
> +EOF
> +endfunction
> +
>  function! s:show_open_msg()
>  ruby << EOF
>  	m = get_message
> @@ -404,6 +445,10 @@ function! s:set_defaults()
>  		endif
>  	endif
>  
> +	if !exists('g:notmuch_open_uri')
> +		let g:notmuch_open_uri = s:notmuch_open_uri_default
> +	endif
> +
>  	if !exists('g:notmuch_reader')
>  		if exists('g:notmuch_rb_reader')
>  			let g:notmuch_reader = g:notmuch_rb_reader
> @@ -611,11 +656,11 @@ ruby << EOF
>  		open_compose_helper(lines, cur)
>  	end
>  
> -	def open_compose()
> +	def open_compose(to_email)
>  		lines = []
>  
>  		lines << "From: #{$email}"
> -		lines << "To: "
> +		lines << "To: #{to_email}"
>  		cur = lines.count
>  
>  		lines << "Cc: "
> -- 
> 1.9.3
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-10  9:44 ` Franz Fellner
@ 2014-10-10 18:18   ` Ian Main
  2014-10-11 12:29     ` Franz Fellner
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Main @ 2014-10-10 18:18 UTC (permalink / raw)
  To: Franz Fellner; +Cc: notmuch

Franz Fellner wrote:
> Works nice. Tested with an https and a mailto URI.
> But it would be awesome if you could add message id handling, So one
> could easily navigate to linked messages. I only found emacs client
> implement this feature. What I read in the docs about ruby URI module
> it should be fairly easy to add a custom scheme for id.

I'm afraid I'm not sure what you mean by message id handling?  It's
probably something simple but .. :)

    Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-10 18:18   ` Ian Main
@ 2014-10-11 12:29     ` Franz Fellner
  2014-10-15 19:33       ` Ian Main
  0 siblings, 1 reply; 16+ messages in thread
From: Franz Fellner @ 2014-10-11 12:29 UTC (permalink / raw)
  To: Ian Main; +Cc: notmuch

Here is a working implementation.
Please review carefully as I only can simulate ruby and vimscript
knowledge from what I see in notmuch.vim sourcefile and quick
googling.

Regards
Franz


diff --git a/plugin/notmuch.vim b/plugin/notmuch.vim
index 567f75c..ef9fefa 100644
--- a/plugin/notmuch.vim
+++ b/plugin/notmuch.vim
@@ -269,6 +269,14 @@ ruby << EOF
 		if uri.class == URI::MailTo
 			vim_puts("Composing new email to #{uri.to}.")
 			VIM::command("call s:compose('#{uri.to}')")
+		elsif uri.class == URI::MsgID
+			msg = $curbuf.message(uri.opaque)
+			if !msg
+				vim_puts("Message not found in NotMuch database: #{uri.to_s}")
+			else
+				vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")
+				VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")
+			end
 		else
 			vim_puts("Opening #{uri.to_s}.")
 			cmd = VIM::evaluate('g:notmuch_open_uri')
@@ -429,11 +437,12 @@ endfunction
 
 "" main
 
-function! s:show(thread_id)
+function! s:show(thread_id, msg_id)
 	call s:new_buffer('show')
 	setlocal modifiable
 ruby << EOF
 	thread_id = VIM::evaluate('a:thread_id')
+	msg_id = VIM::evaluate('a:msg_id')
 	$cur_thread = thread_id
 	$messages.clear
 	$curbuf.render do |b|
@@ -465,6 +474,9 @@ ruby << EOF
 			end
 			b << ""
 			nm_m.end = b.count
+			if msg_id and nm_m.message_id == msg_id
+				VIM::command("normal #{nm_m.start}zt")
+			end
 		end
 		b.delete(b.count)
 	end
@@ -487,7 +499,7 @@ ruby << EOF
 	when 1; $cur_filter = nil
 	when 2; $cur_filter = $cur_search
 	end
-	VIM::command("call s:show('#{id}')")
+	VIM::command("call s:show('#{id}', '')")
 EOF
 endfunction
 
@@ -917,6 +929,10 @@ ruby << EOF
 			q
 		end
 
+		def message(id)
+			@db.find_message(id)
+		end
+
 		def close
 			@queries.delete_if { |q| ! q.destroy! }
 			@db.close
@@ -937,12 +953,20 @@ ruby << EOF
 		end
 	end
 
+	module URI
+		class MsgID < Generic
+		end
+
+		@@schemes['ID'] = MsgID
+	end
+
 	class Message
 		attr_accessor :start, :body_start, :end
-		attr_reader :message_id, :filename, :mail
+		attr_reader :message_id, :thread_id, :filename, :mail
 
 		def initialize(msg, mail)
 			@message_id = msg.message_id
+			@thread_id = msg.thread_id
 			@filename = msg.filename
 			@mail = mail
 			@start = 0

On Fri, 10 Oct 2014 11:18:31 -0700, Ian Main <imain@stemwinder.org> wrote:
> Franz Fellner wrote:
> > Works nice. Tested with an https and a mailto URI.
> > But it would be awesome if you could add message id handling, So one
> > could easily navigate to linked messages. I only found emacs client
> > implement this feature. What I read in the docs about ruby URI module
> > it should be fairly easy to add a custom scheme for id.
> 
> I'm afraid I'm not sure what you mean by message id handling?  It's
> probably something simple but .. :)
> 
>     Ian

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-11 12:29     ` Franz Fellner
@ 2014-10-15 19:33       ` Ian Main
  2014-10-17 16:14         ` Franz Fellner
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Main @ 2014-10-15 19:33 UTC (permalink / raw)
  To: Franz Fellner; +Cc: notmuch

Franz Fellner wrote:
> Here is a working implementation.
> Please review carefully as I only can simulate ruby and vimscript
> knowledge from what I see in notmuch.vim sourcefile and quick
> googling.

Yes, this works nicely.  Thanks!

I do notice however that this is against the github plugin repo (I think)?

I think It'd be nice to have this against the main repo and in its own
thread.  I can repost it for you if you like as I added it to mine, or you
can do it if you prefer.

    Ian
 
> Regards
> Franz
> 
> 
> diff --git a/plugin/notmuch.vim b/plugin/notmuch.vim
> index 567f75c..ef9fefa 100644
> --- a/plugin/notmuch.vim
> +++ b/plugin/notmuch.vim
> @@ -269,6 +269,14 @@ ruby << EOF
>  		if uri.class == URI::MailTo
>  			vim_puts("Composing new email to #{uri.to}.")
>  			VIM::command("call s:compose('#{uri.to}')")
> +		elsif uri.class == URI::MsgID
> +			msg = $curbuf.message(uri.opaque)
> +			if !msg
> +				vim_puts("Message not found in NotMuch database: #{uri.to_s}")
> +			else
> +				vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")
> +				VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")
> +			end
>  		else
>  			vim_puts("Opening #{uri.to_s}.")
>  			cmd = VIM::evaluate('g:notmuch_open_uri')
> @@ -429,11 +437,12 @@ endfunction
>  
>  "" main
>  
> -function! s:show(thread_id)
> +function! s:show(thread_id, msg_id)
>  	call s:new_buffer('show')
>  	setlocal modifiable
>  ruby << EOF
>  	thread_id = VIM::evaluate('a:thread_id')
> +	msg_id = VIM::evaluate('a:msg_id')
>  	$cur_thread = thread_id
>  	$messages.clear
>  	$curbuf.render do |b|
> @@ -465,6 +474,9 @@ ruby << EOF
>  			end
>  			b << ""
>  			nm_m.end = b.count
> +			if msg_id and nm_m.message_id == msg_id
> +				VIM::command("normal #{nm_m.start}zt")
> +			end
>  		end
>  		b.delete(b.count)
>  	end
> @@ -487,7 +499,7 @@ ruby << EOF
>  	when 1; $cur_filter = nil
>  	when 2; $cur_filter = $cur_search
>  	end
> -	VIM::command("call s:show('#{id}')")
> +	VIM::command("call s:show('#{id}', '')")
>  EOF
>  endfunction
>  
> @@ -917,6 +929,10 @@ ruby << EOF
>  			q
>  		end
>  
> +		def message(id)
> +			@db.find_message(id)
> +		end
> +
>  		def close
>  			@queries.delete_if { |q| ! q.destroy! }
>  			@db.close
> @@ -937,12 +953,20 @@ ruby << EOF
>  		end
>  	end
>  
> +	module URI
> +		class MsgID < Generic
> +		end
> +
> +		@@schemes['ID'] = MsgID
> +	end
> +
>  	class Message
>  		attr_accessor :start, :body_start, :end
> -		attr_reader :message_id, :filename, :mail
> +		attr_reader :message_id, :thread_id, :filename, :mail
>  
>  		def initialize(msg, mail)
>  			@message_id = msg.message_id
> +			@thread_id = msg.thread_id
>  			@filename = msg.filename
>  			@mail = mail
>  			@start = 0
> 
> On Fri, 10 Oct 2014 11:18:31 -0700, Ian Main <imain@stemwinder.org> wrote:
> > Franz Fellner wrote:
> > > Works nice. Tested with an https and a mailto URI.
> > > But it would be awesome if you could add message id handling, So one
> > > could easily navigate to linked messages. I only found emacs client
> > > implement this feature. What I read in the docs about ruby URI module
> > > it should be fairly easy to add a custom scheme for id.
> > 
> > I'm afraid I'm not sure what you mean by message id handling?  It's
> > probably something simple but .. :)
> > 
> >     Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-15 19:33       ` Ian Main
@ 2014-10-17 16:14         ` Franz Fellner
  2014-10-20 17:45           ` Ian Main
  2014-10-20 19:05           ` Tomi Ollila
  0 siblings, 2 replies; 16+ messages in thread
From: Franz Fellner @ 2014-10-17 16:14 UTC (permalink / raw)
  To: Ian Main; +Cc: notmuch

On Wed, 15 Oct 2014 12:33:55 -0700, Ian Main <imain@stemwinder.org> wrote:
> Franz Fellner wrote:
> > Here is a working implementation.
> > Please review carefully as I only can simulate ruby and vimscript
> > knowledge from what I see in notmuch.vim sourcefile and quick
> > googling.
> 
> Yes, this works nicely.  Thanks!
> 
> I do notice however that this is against the github plugin repo (I think)?
Yes, that's right.
I forked the notmuch repo on github and incorporated your patches.
Already made a mistake while applying one of your patches...
https://github.com/ff2000/notmuch
(Hope everythin is fine now)
 
commit cb757e9e438341a7bc6d2cfec4de7bdcc85946ea
Author: Franz Fellner <alpine.art.de@gmail.com>
Date:   Fri Oct 17 11:19:41 2014 +0200

    VIM: Add MsgID to supported URIs

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 6287cf6..30e1876 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -268,6 +268,14 @@ ruby << EOF
 		if uri.class == URI::MailTo
 			vim_puts("Composing new email to #{uri.to}.")
 			VIM::command("call s:compose('#{uri.to}')")
+		elsif uri.class == URI::MsgID
+			msg = $curbuf.message(uri.opaque)
+			if !msg
+				vim_puts("Message not found in NotMuch database: #{uri.to_s}")
+			else
+				vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")
+				VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")
+			end
 		else
 			vim_puts("Opening #{uri.to_s}.")
 			cmd = VIM::evaluate('g:notmuch_open_uri')
@@ -428,11 +436,12 @@ endfunction
 
 "" main
 
-function! s:show(thread_id)
+function! s:show(thread_id, msg_id)
 	call s:new_buffer('show')
 	setlocal modifiable
 ruby << EOF
 	thread_id = VIM::evaluate('a:thread_id')
+	msg_id = VIM::evaluate('a:msg_id')
 	$cur_thread = thread_id
 	$messages.clear
 	$curbuf.render do |b|
@@ -464,6 +473,9 @@ ruby << EOF
 			end
 			b << ""
 			nm_m.end = b.count
+			if !msg_id.empty? and nm_m.message_id == msg_id
+				VIM::command("normal #{nm_m.start}zt")
+			end
 		end
 		b.delete(b.count)
 	end
@@ -486,7 +498,7 @@ ruby << EOF
 	when 1; $cur_filter = nil
 	when 2; $cur_filter = $cur_search
 	end
-	VIM::command("call s:show('#{id}')")
+	VIM::command("call s:show('#{id}', '')")
 EOF
 endfunction
 
@@ -910,6 +922,10 @@ ruby << EOF
 			q
 		end
 
+		def message(id)
+			@db.find_message(id)
+		end
+
 		def close
 			@queries.delete_if { |q| ! q.destroy! }
 			@db.close
@@ -930,6 +946,13 @@ ruby << EOF
 		end
 	end
 
+	module URI
+		class MsgID < Generic
+		end
+
+		@@schemes['ID'] = MsgID
+	end
+
 	class Message
 		attr_accessor :start, :body_start, :end
 		attr_reader :message_id, :filename, :mail

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-17 16:14         ` Franz Fellner
@ 2014-10-20 17:45           ` Ian Main
  2014-10-20 19:05           ` Tomi Ollila
  1 sibling, 0 replies; 16+ messages in thread
From: Ian Main @ 2014-10-20 17:45 UTC (permalink / raw)
  To: Franz Fellner; +Cc: notmuch

Franz Fellner wrote:
> On Wed, 15 Oct 2014 12:33:55 -0700, Ian Main <imain@stemwinder.org> wrote:
> > Franz Fellner wrote:
> > > Here is a working implementation.
> > > Please review carefully as I only can simulate ruby and vimscript
> > > knowledge from what I see in notmuch.vim sourcefile and quick
> > > googling.
> > 
> > Yes, this works nicely.  Thanks!
> > 
> > I do notice however that this is against the github plugin repo (I think)?
> Yes, that's right.
> I forked the notmuch repo on github and incorporated your patches.
> Already made a mistake while applying one of your patches...
> https://github.com/ff2000/notmuch
> (Hope everythin is fine now)
>  
> commit cb757e9e438341a7bc6d2cfec4de7bdcc85946ea
> Author: Franz Fellner <alpine.art.de@gmail.com>
> Date:   Fri Oct 17 11:19:41 2014 +0200
> 
>     VIM: Add MsgID to supported URIs
> 
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 6287cf6..30e1876 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -268,6 +268,14 @@ ruby << EOF
>  		if uri.class == URI::MailTo
>  			vim_puts("Composing new email to #{uri.to}.")
>  			VIM::command("call s:compose('#{uri.to}')")
> +		elsif uri.class == URI::MsgID
> +			msg = $curbuf.message(uri.opaque)
> +			if !msg
> +				vim_puts("Message not found in NotMuch database: #{uri.to_s}")
> +			else
> +				vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")
> +				VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")
> +			end
>  		else
>  			vim_puts("Opening #{uri.to_s}.")
>  			cmd = VIM::evaluate('g:notmuch_open_uri')
> @@ -428,11 +436,12 @@ endfunction
>  
>  "" main
>  
> -function! s:show(thread_id)
> +function! s:show(thread_id, msg_id)
>  	call s:new_buffer('show')
>  	setlocal modifiable
>  ruby << EOF
>  	thread_id = VIM::evaluate('a:thread_id')
> +	msg_id = VIM::evaluate('a:msg_id')
>  	$cur_thread = thread_id
>  	$messages.clear
>  	$curbuf.render do |b|
> @@ -464,6 +473,9 @@ ruby << EOF
>  			end
>  			b << ""
>  			nm_m.end = b.count
> +			if !msg_id.empty? and nm_m.message_id == msg_id
> +				VIM::command("normal #{nm_m.start}zt")
> +			end
>  		end
>  		b.delete(b.count)
>  	end
> @@ -486,7 +498,7 @@ ruby << EOF
>  	when 1; $cur_filter = nil
>  	when 2; $cur_filter = $cur_search
>  	end
> -	VIM::command("call s:show('#{id}')")
> +	VIM::command("call s:show('#{id}', '')")
>  EOF
>  endfunction
>  
> @@ -910,6 +922,10 @@ ruby << EOF
>  			q
>  		end
>  
> +		def message(id)
> +			@db.find_message(id)
> +		end
> +
>  		def close
>  			@queries.delete_if { |q| ! q.destroy! }
>  			@db.close
> @@ -930,6 +946,13 @@ ruby << EOF
>  		end
>  	end
>  
> +	module URI
> +		class MsgID < Generic
> +		end
> +
> +		@@schemes['ID'] = MsgID
> +	end
> +
>  	class Message
>  		attr_accessor :start, :body_start, :end
>  		attr_reader :message_id, :filename, :mail

LGTM!  Nice addition.

    Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-02 20:23 [PATCH] VIM: Add URI handling Ian Main
  2014-10-10  9:44 ` Franz Fellner
@ 2014-10-20 18:53 ` Tomi Ollila
  2014-10-23 22:19 ` [PATCH v2] " Ian Main
  2 siblings, 0 replies; 16+ messages in thread
From: Tomi Ollila @ 2014-10-20 18:53 UTC (permalink / raw)
  To: Ian Main, notmuch

On Thu, Oct 02 2014, Ian Main <imain@stemwinder.org> wrote:

> This patch adds URI handling to the vim client.  You can now press
> 'u' by default and the client will parse the current line and find
> any URIs available.  If there are more than one it opens the one
> under the cursor or else it opens the only one available.  It also
> supports mailto: URI's and will compose a new message when activated.
>
> By default xdg-open is used for everything but mailto: which generally
> does the right thing afaict.

This patch LGTM.

>
>     Ian

Tomi

> ---
>  vim/notmuch.txt |  1 +
>  vim/notmuch.vim | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
>  2 files changed, 53 insertions(+), 7 deletions(-)
>
> diff --git a/vim/notmuch.txt b/vim/notmuch.txt
> index 4374102..d336406 100644
> --- a/vim/notmuch.txt
> +++ b/vim/notmuch.txt
> @@ -72,6 +72,7 @@ q	Quit view
>  A	Archive (-inbox -unread)
>  I	Mark as read (-unread)
>  t	Tag (prompted)
> +u	Open URI
>  s	Search
>  p	Save patches
>  r	Reply
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 331e930..de82bb9 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
>  	\ '<Enter>':	'folders_show_search()',
>  	\ 's':		'folders_search_prompt()',
>  	\ '=':		'folders_refresh()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_search_maps = {
> @@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
>  	\ 's':		'search_search_prompt()',
>  	\ '=':		'search_refresh()',
>  	\ '?':		'search_info()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_show_maps = {
> @@ -37,10 +37,11 @@ let g:notmuch_show_maps = {
>  	\ 'e':		'show_extract_msg()',
>  	\ 's':		'show_save_msg()',
>  	\ 'p':		'show_save_patches()',
> +	\ 'u':		'show_open_uri()',
>  	\ 'r':		'show_reply()',
>  	\ '?':		'show_info()',
>  	\ '<Tab>':	'show_next_msg()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_compose_maps = {
> @@ -59,6 +60,7 @@ let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
>  let s:notmuch_reader_default = 'mutt -f %s'
>  let s:notmuch_sendmail_default = 'sendmail'
>  let s:notmuch_folders_count_threads_default = 0
> +let s:notmuch_open_uri_default = 'xdg-open'
>  
>  function! s:new_file_buffer(type, fname)
>  	exec printf('edit %s', a:fname)
> @@ -135,8 +137,8 @@ function! s:show_reply()
>  	startinsert!
>  endfunction
>  
> -function! s:compose()
> -	ruby open_compose
> +function! s:compose(to_email)
> +	ruby open_compose(VIM::evaluate('a:to_email'))
>  	let b:compose_done = 0
>  	call s:set_map(g:notmuch_compose_maps)
>  	autocmd BufDelete <buffer> call s:on_compose_delete()
> @@ -159,6 +161,45 @@ ruby << EOF
>  EOF
>  endfunction
>  
> +function! s:show_open_uri()
> +	let line = getline(".")
> +	let pos = getpos(".")
> +	let col = pos[2]
> +ruby << EOF
> +	m = get_message
> +	line = VIM::evaluate('line')
> +	col = VIM::evaluate('col') - 1
> +	uris = URI.extract(line)
> +	wanted_uri = nil
> +	if uris.length == 1
> +		wanted_uri = uris[0]
> +	else
> +		uris.each do |uri|
> +			# Check to see the URI is at the present cursor location
> +			idx = line.index(uri)
> +			if col >= idx and col <= idx + uri.length
> +				wanted_uri = uri
> +				break
> +			end
> +		end
> +	end
> +
> +	if wanted_uri
> +		uri = URI.parse(wanted_uri)
> +		if uri.class == URI::MailTo
> +			vim_puts("Composing new email to #{uri.to}.")
> +			VIM::command("call s:compose('#{uri.to}')")
> +		else
> +			vim_puts("Opening #{uri.to_s}.")
> +			cmd = VIM::evaluate('g:notmuch_open_uri')
> +			system(cmd, uri.to_s)
> +		end
> +	else
> +		vim_puts('URI not found.')
> +	end
> +EOF
> +endfunction
> +
>  function! s:show_open_msg()
>  ruby << EOF
>  	m = get_message
> @@ -404,6 +445,10 @@ function! s:set_defaults()
>  		endif
>  	endif
>  
> +	if !exists('g:notmuch_open_uri')
> +		let g:notmuch_open_uri = s:notmuch_open_uri_default
> +	endif
> +
>  	if !exists('g:notmuch_reader')
>  		if exists('g:notmuch_rb_reader')
>  			let g:notmuch_reader = g:notmuch_rb_reader
> @@ -611,11 +656,11 @@ ruby << EOF
>  		open_compose_helper(lines, cur)
>  	end
>  
> -	def open_compose()
> +	def open_compose(to_email)
>  		lines = []
>  
>  		lines << "From: #{$email}"
> -		lines << "To: "
> +		lines << "To: #{to_email}"
>  		cur = lines.count
>  
>  		lines << "Cc: "
> -- 
> 1.9.3
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-17 16:14         ` Franz Fellner
  2014-10-20 17:45           ` Ian Main
@ 2014-10-20 19:05           ` Tomi Ollila
  2014-10-20 19:38             ` Franz Fellner
  1 sibling, 1 reply; 16+ messages in thread
From: Tomi Ollila @ 2014-10-20 19:05 UTC (permalink / raw)
  To: Franz Fellner; +Cc: notmuch

On Fri, Oct 17 2014, Franz Fellner <alpine.art.de@gmail.com> wrote:

> On Wed, 15 Oct 2014 12:33:55 -0700, Ian Main <imain@stemwinder.org> wrote:
>> Franz Fellner wrote:
>> > Here is a working implementation.
>> > Please review carefully as I only can simulate ruby and vimscript
>> > knowledge from what I see in notmuch.vim sourcefile and quick
>> > googling.
>> 
>> Yes, this works nicely.  Thanks!
>> 
>> I do notice however that this is against the github plugin repo (I think)?
> Yes, that's right.
> I forked the notmuch repo on github and incorporated your patches.
> Already made a mistake while applying one of your patches...
> https://github.com/ff2000/notmuch
> (Hope everythin is fine now)
>  
> commit cb757e9e438341a7bc6d2cfec4de7bdcc85946ea
> Author: Franz Fellner <alpine.art.de@gmail.com>
> Date:   Fri Oct 17 11:19:41 2014 +0200
>
>     VIM: Add MsgID to supported URIs

Code-wise this patch looks good -- although I am not entirely sure what id
does -- I expect it to handle id:... links...

This email applies with git am (on top of Ian's) but the commit message has
quite a few lines of cruft -- I'd like to see a commit message what
explains what this change do ( the term 'MsgID' seems to be some vim client
internal (subclass in URI class ?) which IMO should be better commented in
this commit message.


Tomi

>
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 6287cf6..30e1876 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -268,6 +268,14 @@ ruby << EOF
>  		if uri.class == URI::MailTo
>  			vim_puts("Composing new email to #{uri.to}.")
>  			VIM::command("call s:compose('#{uri.to}')")
> +		elsif uri.class == URI::MsgID
> +			msg = $curbuf.message(uri.opaque)
> +			if !msg
> +				vim_puts("Message not found in NotMuch database: #{uri.to_s}")
> +			else
> +				vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")
> +				VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")
> +			end
>  		else
>  			vim_puts("Opening #{uri.to_s}.")
>  			cmd = VIM::evaluate('g:notmuch_open_uri')
> @@ -428,11 +436,12 @@ endfunction
>  
>  "" main
>  
> -function! s:show(thread_id)
> +function! s:show(thread_id, msg_id)
>  	call s:new_buffer('show')
>  	setlocal modifiable
>  ruby << EOF
>  	thread_id = VIM::evaluate('a:thread_id')
> +	msg_id = VIM::evaluate('a:msg_id')
>  	$cur_thread = thread_id
>  	$messages.clear
>  	$curbuf.render do |b|
> @@ -464,6 +473,9 @@ ruby << EOF
>  			end
>  			b << ""
>  			nm_m.end = b.count
> +			if !msg_id.empty? and nm_m.message_id == msg_id
> +				VIM::command("normal #{nm_m.start}zt")
> +			end
>  		end
>  		b.delete(b.count)
>  	end
> @@ -486,7 +498,7 @@ ruby << EOF
>  	when 1; $cur_filter = nil
>  	when 2; $cur_filter = $cur_search
>  	end
> -	VIM::command("call s:show('#{id}')")
> +	VIM::command("call s:show('#{id}', '')")
>  EOF
>  endfunction
>  
> @@ -910,6 +922,10 @@ ruby << EOF
>  			q
>  		end
>  
> +		def message(id)
> +			@db.find_message(id)
> +		end
> +
>  		def close
>  			@queries.delete_if { |q| ! q.destroy! }
>  			@db.close
> @@ -930,6 +946,13 @@ ruby << EOF
>  		end
>  	end
>  
> +	module URI
> +		class MsgID < Generic
> +		end
> +
> +		@@schemes['ID'] = MsgID
> +	end
> +
>  	class Message
>  		attr_accessor :start, :body_start, :end
>  		attr_reader :message_id, :filename, :mail
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-20 19:05           ` Tomi Ollila
@ 2014-10-20 19:38             ` Franz Fellner
  2014-10-21 14:25               ` Tomi Ollila
  0 siblings, 1 reply; 16+ messages in thread
From: Franz Fellner @ 2014-10-20 19:38 UTC (permalink / raw)
  To: Tomi Ollila, Tomi Ollila; +Cc: notmuch

Tomi Ollila wrote:
> On Fri, Oct 17 2014, Franz Fellner <alpine.art.de@gmail.com> wrote:
> 
> > On Wed, 15 Oct 2014 12:33:55 -0700, Ian Main <imain@stemwinder.org> wrote:
> >> Franz Fellner wrote:
> >> > Here is a working implementation.
> >> > Please review carefully as I only can simulate ruby and vimscript
> >> > knowledge from what I see in notmuch.vim sourcefile and quick
> >> > googling.
> >> 
> >> Yes, this works nicely.  Thanks!
> >> 
> >> I do notice however that this is against the github plugin repo (I think)?
> > Yes, that's right.
> > I forked the notmuch repo on github and incorporated your patches.
> > Already made a mistake while applying one of your patches...
> > https://github.com/ff2000/notmuch
> > (Hope everythin is fine now)
> >  
> > commit cb757e9e438341a7bc6d2cfec4de7bdcc85946ea
> > Author: Franz Fellner <alpine.art.de@gmail.com>
> > Date:   Fri Oct 17 11:19:41 2014 +0200
> >
> >     VIM: Add MsgID to supported URIs
> 
> Code-wise this patch looks good -- although I am not entirely sure what id
> does -- I expect it to handle id:... links...
Yes, that's what it should do.

> This email applies with git am (on top of Ian's) but the commit message has
> quite a few lines of cruft -- I'd like to see a commit message what
> explains what this change do ( the term 'MsgID' seems to be some vim client
> internal (subclass in URI class ?) which IMO should be better commented in
> this commit message.
MsgID was just a short name for message-id, and I am used to CamelCase...

VIM: Add support to open messages specified by their message-id in notmuch-show.

Does that make more sense?

> Tomi
> 
> >
> > diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> > index 6287cf6..30e1876 100644
> > --- a/vim/notmuch.vim
> > +++ b/vim/notmuch.vim
> > @@ -268,6 +268,14 @@ ruby << EOF
> >  		if uri.class == URI::MailTo
> >  			vim_puts("Composing new email to #{uri.to}.")
> >  			VIM::command("call s:compose('#{uri.to}')")
> > +		elsif uri.class == URI::MsgID
> > +			msg = $curbuf.message(uri.opaque)
> > +			if !msg
> > +				vim_puts("Message not found in NotMuch database: #{uri.to_s}")
> > +			else
> > +				vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")
> > +				VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")
> > +			end
> >  		else
> >  			vim_puts("Opening #{uri.to_s}.")
> >  			cmd = VIM::evaluate('g:notmuch_open_uri')
> > @@ -428,11 +436,12 @@ endfunction
> >  
> >  "" main
> >  
> > -function! s:show(thread_id)
> > +function! s:show(thread_id, msg_id)
> >  	call s:new_buffer('show')
> >  	setlocal modifiable
> >  ruby << EOF
> >  	thread_id = VIM::evaluate('a:thread_id')
> > +	msg_id = VIM::evaluate('a:msg_id')
> >  	$cur_thread = thread_id
> >  	$messages.clear
> >  	$curbuf.render do |b|
> > @@ -464,6 +473,9 @@ ruby << EOF
> >  			end
> >  			b << ""
> >  			nm_m.end = b.count
> > +			if !msg_id.empty? and nm_m.message_id == msg_id
> > +				VIM::command("normal #{nm_m.start}zt")
> > +			end
> >  		end
> >  		b.delete(b.count)
> >  	end
> > @@ -486,7 +498,7 @@ ruby << EOF
> >  	when 1; $cur_filter = nil
> >  	when 2; $cur_filter = $cur_search
> >  	end
> > -	VIM::command("call s:show('#{id}')")
> > +	VIM::command("call s:show('#{id}', '')")
> >  EOF
> >  endfunction
> >  
> > @@ -910,6 +922,10 @@ ruby << EOF
> >  			q
> >  		end
> >  
> > +		def message(id)
> > +			@db.find_message(id)
> > +		end
> > +
> >  		def close
> >  			@queries.delete_if { |q| ! q.destroy! }
> >  			@db.close
> > @@ -930,6 +946,13 @@ ruby << EOF
> >  		end
> >  	end
> >  
> > +	module URI
> > +		class MsgID < Generic
> > +		end
> > +
> > +		@@schemes['ID'] = MsgID
> > +	end
> > +
> >  	class Message
> >  		attr_accessor :start, :body_start, :end
> >  		attr_reader :message_id, :filename, :mail
> > _______________________________________________
> > notmuch mailing list
> > notmuch@notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] VIM: Add URI handling
  2014-10-20 19:38             ` Franz Fellner
@ 2014-10-21 14:25               ` Tomi Ollila
  0 siblings, 0 replies; 16+ messages in thread
From: Tomi Ollila @ 2014-10-21 14:25 UTC (permalink / raw)
  To: Franz Fellner; +Cc: notmuch

On Mon, Oct 20 2014, Franz Fellner <alpine.art.de@gmail.com> wrote:

>> this commit message.
> MsgID was just a short name for message-id, and I am used to CamelCase...
>
> VIM: Add support to open messages specified by their message-id in notmuch-show.

Perhaps something like: vim: add support to open id: links(*)

(as subject) and then the text could describe shortly how this feature
works and how it is used.

See "Write meaningful commit messages" in http://notmuchmail.org/contributing/

(*) or 'references' or 'urls' -- which you think is the best in vim client
context. 


Tomi

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2] VIM: Add URI handling
  2014-10-02 20:23 [PATCH] VIM: Add URI handling Ian Main
  2014-10-10  9:44 ` Franz Fellner
  2014-10-20 18:53 ` Tomi Ollila
@ 2014-10-23 22:19 ` Ian Main
  2014-10-24  9:52   ` Tomi Ollila
  2014-10-24 16:11   ` [PATCH v3] " Ian Main
  2 siblings, 2 replies; 16+ messages in thread
From: Ian Main @ 2014-10-23 22:19 UTC (permalink / raw)
  To: notmuch

Add URI handling to the vim client.  You can now press 'enter' by default and
the client will parse the current line and find any 'Part's or URIs available
for opening.  If there are more than one it opens the one under the cursor or
else it opens the only one available.  It also supports mailto: URI's and will
compose a new message when activated.

By default xdg-open is used for everything but mailto: which generally
does the right thing afaict.

Note that this is now dependant on the attachment patch in order to make
the nice 'enter' behavior work for both.

    Ian
---
 vim/notmuch.txt |  3 ++-
 vim/notmuch.vim | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 70 insertions(+), 9 deletions(-)

diff --git a/vim/notmuch.txt b/vim/notmuch.txt
index 838a904..5d84fde 100644
--- a/vim/notmuch.txt
+++ b/vim/notmuch.txt
@@ -74,7 +74,8 @@ I	Mark as read (-unread)
 t	Tag (prompted)
 e       Extract attachment on the current 'Attachment' line or all
 	attachments if the cursor is elsewhere.
-v       View attachment on the current 'Attachment' line.
+<enter> View email part on the current 'Part' line, or open URI under cursor
+        or on line.
 s	Search
 p	Save patches
 r	Reply
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 1466e50..2f76f55 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
 	\ '<Enter>':	'folders_show_search()',
 	\ 's':		'folders_search_prompt()',
 	\ '=':		'folders_refresh()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_search_maps = {
@@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
 	\ 's':		'search_search_prompt()',
 	\ '=':		'search_refresh()',
 	\ '?':		'search_info()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_show_maps = {
@@ -35,13 +35,13 @@ let g:notmuch_show_maps = {
 	\ 't':		'show_tag("")',
 	\ 'o':		'show_open_msg()',
 	\ 'e':		'show_extract_msg()',
-	\ '<Enter>':	'show_view_attachment()',
+	\ '<Enter>':	'show_view_magic()',
 	\ 's':		'show_save_msg()',
 	\ 'p':		'show_save_patches()',
 	\ 'r':		'show_reply()',
 	\ '?':		'show_info()',
 	\ '<Tab>':	'show_next_msg()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_compose_maps = {
@@ -63,6 +63,7 @@ let s:notmuch_view_attachment_default = 'xdg-open'
 let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'
 let s:notmuch_folders_count_threads_default = 0
 let s:notmuch_compose_start_insert_default = 1
+let s:notmuch_open_uri_default = 'xdg-open'
 
 function! s:new_file_buffer(type, fname)
 	exec printf('edit %s', a:fname)
@@ -141,8 +142,8 @@ function! s:show_reply()
 	end
 endfunction
 
-function! s:compose()
-	ruby open_compose
+function! s:compose(to_email)
+	ruby open_compose(VIM::evaluate('a:to_email'))
 	let b:compose_done = 0
 	call s:set_map(g:notmuch_compose_maps)
 	autocmd BufDelete <buffer> call s:on_compose_delete()
@@ -155,6 +156,22 @@ function! s:show_info()
 	ruby vim_puts get_message.inspect
 endfunction
 
+function! s:show_view_magic()
+	let line = getline(".")
+
+ruby << EOF
+	line = VIM::evaluate('line')
+
+	# Easiest to check for 'Part' types first..
+	match = line.match(/^Part (\d*):/)
+	if match and match.length == 2
+		VIM::command('call s:show_view_attachment()')
+	else
+		VIM::command('call s:show_open_uri()')
+	end
+EOF
+endfunction
+
 function! s:show_view_attachment()
 	let line = getline(".")
 ruby << EOF
@@ -226,6 +243,45 @@ ruby << EOF
 EOF
 endfunction
 
+function! s:show_open_uri()
+	let line = getline(".")
+	let pos = getpos(".")
+	let col = pos[2]
+ruby << EOF
+	m = get_message
+	line = VIM::evaluate('line')
+	col = VIM::evaluate('col') - 1
+	uris = URI.extract(line)
+	wanted_uri = nil
+	if uris.length == 1
+		wanted_uri = uris[0]
+	else
+		uris.each do |uri|
+			# Check to see the URI is at the present cursor location
+			idx = line.index(uri)
+			if col >= idx and col <= idx + uri.length
+				wanted_uri = uri
+				break
+			end
+		end
+	end
+
+	if wanted_uri
+		uri = URI.parse(wanted_uri)
+		if uri.class == URI::MailTo
+			vim_puts("Composing new email to #{uri.to}.")
+			VIM::command("call s:compose('#{uri.to}')")
+		else
+			vim_puts("Opening #{uri.to_s}.")
+			cmd = VIM::evaluate('g:notmuch_open_uri')
+			system(cmd, uri.to_s)
+		end
+	else
+		vim_puts('URI not found.')
+	end
+EOF
+endfunction
+
 function! s:show_open_msg()
 ruby << EOF
 	m = get_message
@@ -481,6 +537,10 @@ function! s:set_defaults()
 		endif
 	endif
 
+	if !exists('g:notmuch_open_uri')
+		let g:notmuch_open_uri = s:notmuch_open_uri_default
+	endif
+
 	if !exists('g:notmuch_reader')
 		if exists('g:notmuch_rb_reader')
 			let g:notmuch_reader = g:notmuch_rb_reader
@@ -693,11 +753,11 @@ ruby << EOF
 		open_compose_helper(lines, cur)
 	end
 
-	def open_compose()
+	def open_compose(to_email)
 		lines = []
 
 		lines << "From: #{$email}"
-		lines << "To: "
+		lines << "To: #{to_email}"
 		cur = lines.count
 
 		lines << "Cc: "
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] VIM: Add URI handling
  2014-10-23 22:19 ` [PATCH v2] " Ian Main
@ 2014-10-24  9:52   ` Tomi Ollila
  2014-10-24 16:11   ` [PATCH v3] " Ian Main
  1 sibling, 0 replies; 16+ messages in thread
From: Tomi Ollila @ 2014-10-24  9:52 UTC (permalink / raw)
  To: Ian Main, notmuch

On Fri, Oct 24 2014, Ian Main <imain@stemwinder.org> wrote:

> Add URI handling to the vim client.  You can now press 'enter' by default and
> the client will parse the current line and find any 'Part's or URIs available
> for opening.  If there are more than one it opens the one under the cursor or
> else it opens the only one available.  It also supports mailto: URI's and will
> compose a new message when activated.

The lines are way too long in this commit message. 72-chars except in cases
where there is no word breaks in the text.

id:1414101891-10714-1-git-send-email-imain@stemwinder.org has also one 
75-character line (and talks about 'This patch ...' which could be changed
too (but is tolerated if not)).

Tomi

>
> By default xdg-open is used for everything but mailto: which generally
> does the right thing afaict.
>
> Note that this is now dependant on the attachment patch in order to make
> the nice 'enter' behavior work for both.
>
>     Ian
> ---
>  vim/notmuch.txt |  3 ++-
>  vim/notmuch.vim | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++------
>  2 files changed, 70 insertions(+), 9 deletions(-)
>
> diff --git a/vim/notmuch.txt b/vim/notmuch.txt
> index 838a904..5d84fde 100644
> --- a/vim/notmuch.txt
> +++ b/vim/notmuch.txt
> @@ -74,7 +74,8 @@ I	Mark as read (-unread)
>  t	Tag (prompted)
>  e       Extract attachment on the current 'Attachment' line or all
>  	attachments if the cursor is elsewhere.
> -v       View attachment on the current 'Attachment' line.
> +<enter> View email part on the current 'Part' line, or open URI under cursor
> +        or on line.
>  s	Search
>  p	Save patches
>  r	Reply
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 1466e50..2f76f55 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
>  	\ '<Enter>':	'folders_show_search()',
>  	\ 's':		'folders_search_prompt()',
>  	\ '=':		'folders_refresh()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_search_maps = {
> @@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
>  	\ 's':		'search_search_prompt()',
>  	\ '=':		'search_refresh()',
>  	\ '?':		'search_info()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_show_maps = {
> @@ -35,13 +35,13 @@ let g:notmuch_show_maps = {
>  	\ 't':		'show_tag("")',
>  	\ 'o':		'show_open_msg()',
>  	\ 'e':		'show_extract_msg()',
> -	\ '<Enter>':	'show_view_attachment()',
> +	\ '<Enter>':	'show_view_magic()',
>  	\ 's':		'show_save_msg()',
>  	\ 'p':		'show_save_patches()',
>  	\ 'r':		'show_reply()',
>  	\ '?':		'show_info()',
>  	\ '<Tab>':	'show_next_msg()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_compose_maps = {
> @@ -63,6 +63,7 @@ let s:notmuch_view_attachment_default = 'xdg-open'
>  let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'
>  let s:notmuch_folders_count_threads_default = 0
>  let s:notmuch_compose_start_insert_default = 1
> +let s:notmuch_open_uri_default = 'xdg-open'
>  
>  function! s:new_file_buffer(type, fname)
>  	exec printf('edit %s', a:fname)
> @@ -141,8 +142,8 @@ function! s:show_reply()
>  	end
>  endfunction
>  
> -function! s:compose()
> -	ruby open_compose
> +function! s:compose(to_email)
> +	ruby open_compose(VIM::evaluate('a:to_email'))
>  	let b:compose_done = 0
>  	call s:set_map(g:notmuch_compose_maps)
>  	autocmd BufDelete <buffer> call s:on_compose_delete()
> @@ -155,6 +156,22 @@ function! s:show_info()
>  	ruby vim_puts get_message.inspect
>  endfunction
>  
> +function! s:show_view_magic()
> +	let line = getline(".")
> +
> +ruby << EOF
> +	line = VIM::evaluate('line')
> +
> +	# Easiest to check for 'Part' types first..
> +	match = line.match(/^Part (\d*):/)
> +	if match and match.length == 2
> +		VIM::command('call s:show_view_attachment()')
> +	else
> +		VIM::command('call s:show_open_uri()')
> +	end
> +EOF
> +endfunction
> +
>  function! s:show_view_attachment()
>  	let line = getline(".")
>  ruby << EOF
> @@ -226,6 +243,45 @@ ruby << EOF
>  EOF
>  endfunction
>  
> +function! s:show_open_uri()
> +	let line = getline(".")
> +	let pos = getpos(".")
> +	let col = pos[2]
> +ruby << EOF
> +	m = get_message
> +	line = VIM::evaluate('line')
> +	col = VIM::evaluate('col') - 1
> +	uris = URI.extract(line)
> +	wanted_uri = nil
> +	if uris.length == 1
> +		wanted_uri = uris[0]
> +	else
> +		uris.each do |uri|
> +			# Check to see the URI is at the present cursor location
> +			idx = line.index(uri)
> +			if col >= idx and col <= idx + uri.length
> +				wanted_uri = uri
> +				break
> +			end
> +		end
> +	end
> +
> +	if wanted_uri
> +		uri = URI.parse(wanted_uri)
> +		if uri.class == URI::MailTo
> +			vim_puts("Composing new email to #{uri.to}.")
> +			VIM::command("call s:compose('#{uri.to}')")
> +		else
> +			vim_puts("Opening #{uri.to_s}.")
> +			cmd = VIM::evaluate('g:notmuch_open_uri')
> +			system(cmd, uri.to_s)
> +		end
> +	else
> +		vim_puts('URI not found.')
> +	end
> +EOF
> +endfunction
> +
>  function! s:show_open_msg()
>  ruby << EOF
>  	m = get_message
> @@ -481,6 +537,10 @@ function! s:set_defaults()
>  		endif
>  	endif
>  
> +	if !exists('g:notmuch_open_uri')
> +		let g:notmuch_open_uri = s:notmuch_open_uri_default
> +	endif
> +
>  	if !exists('g:notmuch_reader')
>  		if exists('g:notmuch_rb_reader')
>  			let g:notmuch_reader = g:notmuch_rb_reader
> @@ -693,11 +753,11 @@ ruby << EOF
>  		open_compose_helper(lines, cur)
>  	end
>  
> -	def open_compose()
> +	def open_compose(to_email)
>  		lines = []
>  
>  		lines << "From: #{$email}"
> -		lines << "To: "
> +		lines << "To: #{to_email}"
>  		cur = lines.count
>  
>  		lines << "Cc: "
> -- 
> 1.9.3
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v3] VIM: Add URI handling
  2014-10-23 22:19 ` [PATCH v2] " Ian Main
  2014-10-24  9:52   ` Tomi Ollila
@ 2014-10-24 16:11   ` Ian Main
  2014-10-24 16:30     ` Tomi Ollila
  1 sibling, 1 reply; 16+ messages in thread
From: Ian Main @ 2014-10-24 16:11 UTC (permalink / raw)
  To: notmuch

This patch adds URI handling to the vim client.  You can now press
'enter' by default and the client will parse the current line and find
any 'Part's or URIs available for opening.  If there are more than one
it opens the one under the cursor or else it opens the only one
available.  It also supports mailto: URI's and will compose a new
message when activated.

By default xdg-open is used for everything but mailto: which generally
does the right thing afaict.

Note that this is now dependant on the attachment patch in order to
make the nice 'enter' behavior work for both.

    Ian
---

Fix commit message formatting.

 vim/notmuch.txt |  3 ++-
 vim/notmuch.vim | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 70 insertions(+), 9 deletions(-)

diff --git a/vim/notmuch.txt b/vim/notmuch.txt
index 838a904..5d84fde 100644
--- a/vim/notmuch.txt
+++ b/vim/notmuch.txt
@@ -74,7 +74,8 @@ I	Mark as read (-unread)
 t	Tag (prompted)
 e       Extract attachment on the current 'Attachment' line or all
 	attachments if the cursor is elsewhere.
-v       View attachment on the current 'Attachment' line.
+<enter> View email part on the current 'Part' line, or open URI under cursor
+        or on line.
 s	Search
 p	Save patches
 r	Reply
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 1466e50..2f76f55 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
 	\ '<Enter>':	'folders_show_search()',
 	\ 's':		'folders_search_prompt()',
 	\ '=':		'folders_refresh()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_search_maps = {
@@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
 	\ 's':		'search_search_prompt()',
 	\ '=':		'search_refresh()',
 	\ '?':		'search_info()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_show_maps = {
@@ -35,13 +35,13 @@ let g:notmuch_show_maps = {
 	\ 't':		'show_tag("")',
 	\ 'o':		'show_open_msg()',
 	\ 'e':		'show_extract_msg()',
-	\ '<Enter>':	'show_view_attachment()',
+	\ '<Enter>':	'show_view_magic()',
 	\ 's':		'show_save_msg()',
 	\ 'p':		'show_save_patches()',
 	\ 'r':		'show_reply()',
 	\ '?':		'show_info()',
 	\ '<Tab>':	'show_next_msg()',
-	\ 'c':		'compose()',
+	\ 'c':		'compose("")',
 	\ }
 
 let g:notmuch_compose_maps = {
@@ -63,6 +63,7 @@ let s:notmuch_view_attachment_default = 'xdg-open'
 let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'
 let s:notmuch_folders_count_threads_default = 0
 let s:notmuch_compose_start_insert_default = 1
+let s:notmuch_open_uri_default = 'xdg-open'
 
 function! s:new_file_buffer(type, fname)
 	exec printf('edit %s', a:fname)
@@ -141,8 +142,8 @@ function! s:show_reply()
 	end
 endfunction
 
-function! s:compose()
-	ruby open_compose
+function! s:compose(to_email)
+	ruby open_compose(VIM::evaluate('a:to_email'))
 	let b:compose_done = 0
 	call s:set_map(g:notmuch_compose_maps)
 	autocmd BufDelete <buffer> call s:on_compose_delete()
@@ -155,6 +156,22 @@ function! s:show_info()
 	ruby vim_puts get_message.inspect
 endfunction
 
+function! s:show_view_magic()
+	let line = getline(".")
+
+ruby << EOF
+	line = VIM::evaluate('line')
+
+	# Easiest to check for 'Part' types first..
+	match = line.match(/^Part (\d*):/)
+	if match and match.length == 2
+		VIM::command('call s:show_view_attachment()')
+	else
+		VIM::command('call s:show_open_uri()')
+	end
+EOF
+endfunction
+
 function! s:show_view_attachment()
 	let line = getline(".")
 ruby << EOF
@@ -226,6 +243,45 @@ ruby << EOF
 EOF
 endfunction
 
+function! s:show_open_uri()
+	let line = getline(".")
+	let pos = getpos(".")
+	let col = pos[2]
+ruby << EOF
+	m = get_message
+	line = VIM::evaluate('line')
+	col = VIM::evaluate('col') - 1
+	uris = URI.extract(line)
+	wanted_uri = nil
+	if uris.length == 1
+		wanted_uri = uris[0]
+	else
+		uris.each do |uri|
+			# Check to see the URI is at the present cursor location
+			idx = line.index(uri)
+			if col >= idx and col <= idx + uri.length
+				wanted_uri = uri
+				break
+			end
+		end
+	end
+
+	if wanted_uri
+		uri = URI.parse(wanted_uri)
+		if uri.class == URI::MailTo
+			vim_puts("Composing new email to #{uri.to}.")
+			VIM::command("call s:compose('#{uri.to}')")
+		else
+			vim_puts("Opening #{uri.to_s}.")
+			cmd = VIM::evaluate('g:notmuch_open_uri')
+			system(cmd, uri.to_s)
+		end
+	else
+		vim_puts('URI not found.')
+	end
+EOF
+endfunction
+
 function! s:show_open_msg()
 ruby << EOF
 	m = get_message
@@ -481,6 +537,10 @@ function! s:set_defaults()
 		endif
 	endif
 
+	if !exists('g:notmuch_open_uri')
+		let g:notmuch_open_uri = s:notmuch_open_uri_default
+	endif
+
 	if !exists('g:notmuch_reader')
 		if exists('g:notmuch_rb_reader')
 			let g:notmuch_reader = g:notmuch_rb_reader
@@ -693,11 +753,11 @@ ruby << EOF
 		open_compose_helper(lines, cur)
 	end
 
-	def open_compose()
+	def open_compose(to_email)
 		lines = []
 
 		lines << "From: #{$email}"
-		lines << "To: "
+		lines << "To: #{to_email}"
 		cur = lines.count
 
 		lines << "Cc: "
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] VIM: Add URI handling
  2014-10-24 16:11   ` [PATCH v3] " Ian Main
@ 2014-10-24 16:30     ` Tomi Ollila
  2014-10-24 17:03       ` Ian Main
  0 siblings, 1 reply; 16+ messages in thread
From: Tomi Ollila @ 2014-10-24 16:30 UTC (permalink / raw)
  To: Ian Main, notmuch

On Fri, Oct 24 2014, Ian Main <imain@stemwinder.org> wrote:

This patch does not apply on top of notmuchmail master 
(commit 38240d106139da8).

> This patch adds URI handling to the vim client.  You can now press

Although insignificant, I'll start commenting on all sent patches
(that I look into) which talk like 'This patch adds' -- sure it is patch
when email is sent, but in repository it is not so -- so the commit message
should not mention it (but I do not require changing it).

Anyway, I suspect this change will become applicable after some other
change is committed first -- and IMO this could stay as non-stale patch
provided that SomeOne(TM) informs what is the message that contains
changes (or series those) that is required for this message to apply.

BTW: does the content of this change differ much from v1 at
id:1412281423-22441-1-git-send-email-imain@stemwinder.org
or should I re-check (carefully!) that the changes are still OK.


Tomi


> 'enter' by default and the client will parse the current line and find
> any 'Part's or URIs available for opening.  If there are more than one
> it opens the one under the cursor or else it opens the only one
> available.  It also supports mailto: URI's and will compose a new
> message when activated.
>
> By default xdg-open is used for everything but mailto: which generally
> does the right thing afaict.
>
> Note that this is now dependant on the attachment patch in order to
> make the nice 'enter' behavior work for both.
>
>     Ian
> ---
>
> Fix commit message formatting.
>
>  vim/notmuch.txt |  3 ++-
>  vim/notmuch.vim | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++------
>  2 files changed, 70 insertions(+), 9 deletions(-)
>
> diff --git a/vim/notmuch.txt b/vim/notmuch.txt
> index 838a904..5d84fde 100644
> --- a/vim/notmuch.txt
> +++ b/vim/notmuch.txt
> @@ -74,7 +74,8 @@ I	Mark as read (-unread)
>  t	Tag (prompted)
>  e       Extract attachment on the current 'Attachment' line or all
>  	attachments if the cursor is elsewhere.
> -v       View attachment on the current 'Attachment' line.
> +<enter> View email part on the current 'Part' line, or open URI under cursor
> +        or on line.
>  s	Search
>  p	Save patches
>  r	Reply
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 1466e50..2f76f55 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -12,7 +12,7 @@ let g:notmuch_folders_maps = {
>  	\ '<Enter>':	'folders_show_search()',
>  	\ 's':		'folders_search_prompt()',
>  	\ '=':		'folders_refresh()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_search_maps = {
> @@ -25,7 +25,7 @@ let g:notmuch_search_maps = {
>  	\ 's':		'search_search_prompt()',
>  	\ '=':		'search_refresh()',
>  	\ '?':		'search_info()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_show_maps = {
> @@ -35,13 +35,13 @@ let g:notmuch_show_maps = {
>  	\ 't':		'show_tag("")',
>  	\ 'o':		'show_open_msg()',
>  	\ 'e':		'show_extract_msg()',
> -	\ '<Enter>':	'show_view_attachment()',
> +	\ '<Enter>':	'show_view_magic()',
>  	\ 's':		'show_save_msg()',
>  	\ 'p':		'show_save_patches()',
>  	\ 'r':		'show_reply()',
>  	\ '?':		'show_info()',
>  	\ '<Tab>':	'show_next_msg()',
> -	\ 'c':		'compose()',
> +	\ 'c':		'compose("")',
>  	\ }
>  
>  let g:notmuch_compose_maps = {
> @@ -63,6 +63,7 @@ let s:notmuch_view_attachment_default = 'xdg-open'
>  let s:notmuch_attachment_tmpdir_default = '~/.notmuch/tmp'
>  let s:notmuch_folders_count_threads_default = 0
>  let s:notmuch_compose_start_insert_default = 1
> +let s:notmuch_open_uri_default = 'xdg-open'
>  
>  function! s:new_file_buffer(type, fname)
>  	exec printf('edit %s', a:fname)
> @@ -141,8 +142,8 @@ function! s:show_reply()
>  	end
>  endfunction
>  
> -function! s:compose()
> -	ruby open_compose
> +function! s:compose(to_email)
> +	ruby open_compose(VIM::evaluate('a:to_email'))
>  	let b:compose_done = 0
>  	call s:set_map(g:notmuch_compose_maps)
>  	autocmd BufDelete <buffer> call s:on_compose_delete()
> @@ -155,6 +156,22 @@ function! s:show_info()
>  	ruby vim_puts get_message.inspect
>  endfunction
>  
> +function! s:show_view_magic()
> +	let line = getline(".")
> +
> +ruby << EOF
> +	line = VIM::evaluate('line')
> +
> +	# Easiest to check for 'Part' types first..
> +	match = line.match(/^Part (\d*):/)
> +	if match and match.length == 2
> +		VIM::command('call s:show_view_attachment()')
> +	else
> +		VIM::command('call s:show_open_uri()')
> +	end
> +EOF
> +endfunction
> +
>  function! s:show_view_attachment()
>  	let line = getline(".")
>  ruby << EOF
> @@ -226,6 +243,45 @@ ruby << EOF
>  EOF
>  endfunction
>  
> +function! s:show_open_uri()
> +	let line = getline(".")
> +	let pos = getpos(".")
> +	let col = pos[2]
> +ruby << EOF
> +	m = get_message
> +	line = VIM::evaluate('line')
> +	col = VIM::evaluate('col') - 1
> +	uris = URI.extract(line)
> +	wanted_uri = nil
> +	if uris.length == 1
> +		wanted_uri = uris[0]
> +	else
> +		uris.each do |uri|
> +			# Check to see the URI is at the present cursor location
> +			idx = line.index(uri)
> +			if col >= idx and col <= idx + uri.length
> +				wanted_uri = uri
> +				break
> +			end
> +		end
> +	end
> +
> +	if wanted_uri
> +		uri = URI.parse(wanted_uri)
> +		if uri.class == URI::MailTo
> +			vim_puts("Composing new email to #{uri.to}.")
> +			VIM::command("call s:compose('#{uri.to}')")
> +		else
> +			vim_puts("Opening #{uri.to_s}.")
> +			cmd = VIM::evaluate('g:notmuch_open_uri')
> +			system(cmd, uri.to_s)
> +		end
> +	else
> +		vim_puts('URI not found.')
> +	end
> +EOF
> +endfunction
> +
>  function! s:show_open_msg()
>  ruby << EOF
>  	m = get_message
> @@ -481,6 +537,10 @@ function! s:set_defaults()
>  		endif
>  	endif
>  
> +	if !exists('g:notmuch_open_uri')
> +		let g:notmuch_open_uri = s:notmuch_open_uri_default
> +	endif
> +
>  	if !exists('g:notmuch_reader')
>  		if exists('g:notmuch_rb_reader')
>  			let g:notmuch_reader = g:notmuch_rb_reader
> @@ -693,11 +753,11 @@ ruby << EOF
>  		open_compose_helper(lines, cur)
>  	end
>  
> -	def open_compose()
> +	def open_compose(to_email)
>  		lines = []
>  
>  		lines << "From: #{$email}"
> -		lines << "To: "
> +		lines << "To: #{to_email}"
>  		cur = lines.count
>  
>  		lines << "Cc: "
> -- 
> 1.9.3
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] VIM: Add URI handling
  2014-10-24 16:30     ` Tomi Ollila
@ 2014-10-24 17:03       ` Ian Main
  0 siblings, 0 replies; 16+ messages in thread
From: Ian Main @ 2014-10-24 17:03 UTC (permalink / raw)
  To: Tomi Ollila, Tomi Ollila, notmuch

Tomi Ollila wrote:
> On Fri, Oct 24 2014, Ian Main <imain@stemwinder.org> wrote:
> 
> This patch does not apply on top of notmuchmail master 
> (commit 38240d106139da8).
> 
> > This patch adds URI handling to the vim client.  You can now press
> 
> Although insignificant, I'll start commenting on all sent patches
> (that I look into) which talk like 'This patch adds' -- sure it is patch
> when email is sent, but in repository it is not so -- so the commit message
> should not mention it (but I do not require changing it).
> 
> Anyway, I suspect this change will become applicable after some other
> change is committed first -- and IMO this could stay as non-stale patch
> provided that SomeOne(TM) informs what is the message that contains
> changes (or series those) that is required for this message to apply.
> 
> BTW: does the content of this change differ much from v1 at
> id:1412281423-22441-1-git-send-email-imain@stemwinder.org
> or should I re-check (carefully!) that the changes are still OK.
> 
> 
> Tomi
> 

This one is almost identical minus the hotkey usage.  The attachment support
patch has changed a fair bit in that it now looks at all parts of multipart
messages, giving you the opportunity to view the original text/html message
in a web browser.

I sent them out as a series in a new thread so that it would be easier to
follow.  I have them all applied locally and there were some conflicts to
resolve.  They are simple, usually around the defaults settings for the
configuration but it's still a pain.  I'm still tempted to send out all
of the outstanding patches as a big series.  All the patches posted though
should apply to master so I may just have to rebase now and again.

    Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-10-24 17:04 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-02 20:23 [PATCH] VIM: Add URI handling Ian Main
2014-10-10  9:44 ` Franz Fellner
2014-10-10 18:18   ` Ian Main
2014-10-11 12:29     ` Franz Fellner
2014-10-15 19:33       ` Ian Main
2014-10-17 16:14         ` Franz Fellner
2014-10-20 17:45           ` Ian Main
2014-10-20 19:05           ` Tomi Ollila
2014-10-20 19:38             ` Franz Fellner
2014-10-21 14:25               ` Tomi Ollila
2014-10-20 18:53 ` Tomi Ollila
2014-10-23 22:19 ` [PATCH v2] " Ian Main
2014-10-24  9:52   ` Tomi Ollila
2014-10-24 16:11   ` [PATCH v3] " Ian Main
2014-10-24 16:30     ` Tomi Ollila
2014-10-24 17:03       ` Ian Main

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).