X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=ecf7b9defe94859f581528a078407383b0c64043;hp=d661c5658b6b5f4ebde85d289ae16ed925b556d5;hb=de85b4752d51567ded73e9bbed75d0b8f5bfea71;hpb=882621927483635d37eed70eef007f1ef97662d0 diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index d661c565..ecf7b9de 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -136,7 +136,10 @@ function! s:NM_search_edit() endfunction function! s:NM_search_archive_thread() - call NM_search_remove_tags('inbox') + call NM_add_remove_tags('-', ['inbox']) + setlocal modifiable + s/(\([^)]*\)\\([^)]*\))$/(\1\2)/ + setlocal nomodifiable norm j endfunction @@ -190,23 +193,27 @@ function! s:NM_search_find_thread_id() endfunction function! s:NM_search_add_remove_tags(prompt, prefix, intags) - let id = NM_search_find_thread_id() - if id != '' - if type(a:intags) != type([]) || len(a:intags) == 0 - " TODO: input() can support completion - let text = input(a:prompt) - if !strlen(text) - return - endif - let tags = split(text, ' ') - else - let tags = a:intags + if type(a:intags) != type([]) || len(a:intags) == 0 + " TODO: input() can support completion + let text = input(a:prompt) + if !strlen(text) + return endif - call map(tags, 'a:prefix . v:val') - " TODO: handle errors - call NM_run(['tag'] + tags + ['--', id]) - call NM_search_refresh_view() + call NM_add_remove_tags(prefix, split(text, ' ')) + else + call NM_add_remove_tags(prefix, a:intags) + endif + call NM_search_refresh_view() +endfunction + +function! s:NM_add_remove_tags(prefix, tags) + let id = NM_search_find_thread_id() + if id == '' + echoe 'Eeek! I couldn''t find the thead id!' endif + call map(a:tags, 'a:prefix . v:val') + " TODO: handle errors + call NM_run(['tag'] + a:tags + ['--', id]) endfunction " --- implement show screen {{{1