From 68c1c07e202f4073167d786459a527193c7fc238 Mon Sep 17 00:00:00 2001 From: Franz Fellner Date: Mon, 22 Dec 2014 17:28:30 +0100 Subject: [PATCH] Prompt for confirmation in [search,folders]_tag_all This should prevent accidental tagging, like hitting "A" while the cursor is on the inbox in folder. fixes #7 --- plugin/notmuch.vim | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/plugin/notmuch.vim b/plugin/notmuch.vim index 66ff826..710ce3c 100644 --- a/plugin/notmuch.vim +++ b/plugin/notmuch.vim @@ -245,13 +245,16 @@ function! s:search_tag(intags) endfunction function! s:search_tag_all(intags) - if empty(a:intags) - let tags = input('tags: ') - else - let tags = a:intags + let choice = confirm('Do you really want to tag all messages in this search?', "&yes\n&no", 1) + if choice == 1 + if empty(a:intags) + let tags = input('tags: ') + else + let tags = a:intags + endif + ruby do_tag($cur_search, VIM::evaluate('l:tags')) + echo 'Tagged all search results with '.a:intags endif - ruby do_tag($cur_search, VIM::evaluate('l:tags')) - echo 'Tagged all search results with '.a:intags endfunction function! s:folders_search_prompt() @@ -357,13 +360,16 @@ EOF endfunction function! s:folders_tag_all(tags) + let choice = confirm('Do you really want to tag all messages in this folder?', "&yes\n&no", 1) + if choice == 1 ruby << EOF - n = $curbuf.line_number - s = $searches[n - 1] - t = VIM::evaluate('a:tags') - do_tag(s, t) + n = $curbuf.line_number + s = $searches[n - 1] + t = VIM::evaluate('a:tags') + do_tag(s, t) EOF - call s:folders_refresh() + call s:folders_refresh() + endif endfunction function! s:folders()