From: Nicolas Lesser <blitzrakete@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] vim: Ignore instead of erroring out when trying to perform an action on a non-existent thread.
Date: Fri, 22 Mar 2019 17:05:36 +0100 [thread overview]
Message-ID: <20190322160536.11100-1-blitzrakete@gmail.com> (raw)
---
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
reply other threads:[~2019-03-22 16:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190322160536.11100-1-blitzrakete@gmail.com \
--to=blitzrakete@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).