[PATCH] vim: Ignore instead of erroring out when trying to perform an action on a non-existent thread.

Nicolas Lesser blitzrakete at gmail.com
Fri Mar 22 09:05:36 PDT 2019


---
 vim/notmuch.vim | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index ad8b7c80..299405f4 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -237,7 +237,11 @@ function! s:search_tag(intags)
 	else
 		let tags = a:intags
 	endif
-	ruby do_tag(get_thread_id, VIM::evaluate('l:tags'))
+ruby << EOF
+	if (id = get_thread_id)
+	  do_tag(id, VIM::evaluate('l:tags'))
+	end
+EOF
 	norm j
 endfunction
 
@@ -354,13 +358,14 @@ endfunction
 function! s:search_show_thread(mode)
 ruby << EOF
 	mode = VIM::evaluate('a:mode')
-	id = get_thread_id
-	case mode
-	when 0;
-	when 1; $cur_filter = nil
-	when 2; $cur_filter = $cur_search
+	if (id = get_thread_id)
+		case mode
+		when 0;
+		when 1; $cur_filter = nil
+		when 2; $cur_filter = $cur_search
+		end
+		VIM::command("call s:show('#{id}')")
 	end
-	VIM::command("call s:show('#{id}')")
 EOF
 endfunction
 
@@ -519,6 +524,7 @@ ruby << EOF
 	end
 
 	def get_thread_id
+		return nil if $threads.empty?
 		n = $curbuf.line_number - 1
 		return "thread:%s" % $threads[n]
 	end
-- 
2.21.0



More information about the notmuch mailing list