aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorBart Trojanowski <bart@jukie.net>2009-11-20 11:13:49 -0500
committerBart Trojanowski <bart@jukie.net>2009-11-25 00:48:51 -0500
commitde85b4752d51567ded73e9bbed75d0b8f5bfea71 (patch)
treedac59a4974b5139bece00ad0eb731f833f4d04e6 /vim
parent882621927483635d37eed70eef007f1ef97662d0 (diff)
added support for archive command
Diffstat (limited to 'vim')
-rw-r--r--vim/README1
-rw-r--r--vim/plugin/notmuch.vim39
2 files changed, 24 insertions, 16 deletions
diff --git a/vim/README b/vim/README
index ba6eb5f..dffc88a 100644
--- a/vim/README
+++ b/vim/README
@@ -18,6 +18,7 @@ Buffer types:
Keybindings:
<Enter> - 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 d661c56..ecf7b9d 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 <SID>NM_search_remove_tags('inbox')
+ call <SID>NM_add_remove_tags('-', ['inbox'])
+ setlocal modifiable
+ s/(\([^)]*\)\<inbox\>\([^)]*\))$/(\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 = <SID>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 <SID>NM_run(['tag'] + tags + ['--', id])
- call <SID>NM_search_refresh_view()
+ call <SID>NM_add_remove_tags(prefix, split(text, ' '))
+ else
+ call <SID>NM_add_remove_tags(prefix, a:intags)
+ endif
+ call <SID>NM_search_refresh_view()
+endfunction
+
+function! s:NM_add_remove_tags(prefix, tags)
+ let id = <SID>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 <SID>NM_run(['tag'] + a:tags + ['--', id])
endfunction
" --- implement show screen {{{1