From de85b4752d51567ded73e9bbed75d0b8f5bfea71 Mon Sep 17 00:00:00 2001 From: Bart Trojanowski Date: Fri, 20 Nov 2009 11:13:49 -0500 Subject: [PATCH] added support for archive command --- vim/README | 1 + vim/plugin/notmuch.vim | 39 +++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/vim/README b/vim/README index ba6eb5fe..dffc88a4 100644 --- a/vim/README +++ b/vim/README @@ -18,6 +18,7 @@ Buffer types: Keybindings: - show the selected message + a - archive message (remove inbox tag) s - enter search criteria S - alter search criteria + - add tag(s) to selected message 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 -- 2.26.2