Currently if you navigate through an entire thread using <space> it will automatically have it's 'unread' and 'inbox' tags removed. For many userss archiving is limited to threads that are old and unlikely to be referenced again rather than threads that you've simply read or glanced through recently, particularly users like me with poor long-term memory. This patch adds g:notmuch_advance_add_tags and g:notmuch_advance_remove_tags settings to customize this behavior while also adding the option to have tags added to threads that have been read in their entirety. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- vim/plugin/notmuch.vim | 47 ++++++++++++++++++++++++++++++++++++----------- 1 files changed, 36 insertions(+), 11 deletions(-) diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index 21985c7..5bcd262 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -103,6 +103,14 @@ let s:notmuch_compose_headers_defaults = [ \ 'Subject' \ ] +" defaults for g:notmuch_advance_remove_tags +" override with: let g:notmuch_advance_remove_tags = [ ... ] +let s:notmuch_advance_remove_tags = [ 'unread', 'inbox' ] + +" defaults for g:notmuch_advance_add_tags +" override with: let g:notmuch_advance_add_tags = [ ... ] +let s:notmuch_advance_add_tags = [ ] + " --- keyboard mapping definitions {{{1 " --- --- bindings for folders mode {{{2 @@ -160,7 +168,7 @@ let g:notmuch_show_maps = { \ 'v': ':call <SID>NM_show_view_all_mime_parts()<CR>', \ '+': ':call <SID>NM_show_add_tag()<CR>', \ '-': ':call <SID>NM_show_remove_tag()<CR>', - \ '<Space>': ':call <SID>NM_show_advance_marking_read_and_archiving()<CR>', + \ '<Space>': ':call <SID>NM_show_advance_and_tag()<CR>', \ '\|': ':call <SID>NM_show_pipe_message()<CR>', \ \ '<S-Tab>': ':call <SID>NM_show_previous_fold()<CR>', @@ -573,10 +581,11 @@ endfunction " if entire message is not visible scroll down 1/2 page or less to get to the bottom of message " otherwise go to next message -" any message that is viewed entirely has inbox and unread tags removed -function! s:NM_show_advance_marking_read_and_archiving() - let advance_tags = ['unread', 'inbox'] - +" any message that is viewed entirely has g:notmuch_advance_add_tags added and +" g:notmuch_advance_remove_tags removed +function! s:NM_show_advance_and_tag() + let remove_tags = copy(g:notmuch_advance_remove_tags) + let add_tags = copy(g:notmuch_advance_add_tags) let vis_top = line('w0') let vis_bot = line('w$') @@ -585,6 +594,11 @@ function! s:NM_show_advance_marking_read_and_archiving() throw "No top visible message." endif + let remove_tags_formatted = copy(remove_tags) + call map(remove_tags_formatted, '"-" . v:val') + let add_tags_formatted = copy(add_tags) + call map(add_tags_formatted, '"+" . v:val') + " if the top message is the last message, just expunge the entire thread and move on if msg_top['end'] == line('$') let ids = [] @@ -593,11 +607,14 @@ function! s:NM_show_advance_marking_read_and_archiving() call add(ids, msg['id']) endif endfor - let filter = <SID>NM_combine_tags('tag:', advance_tags, 'OR', '()') + let filter = <SID>NM_combine_tags('tag:', remove_tags, 'OR', '()') \ + ['AND'] \ + <SID>NM_combine_tags('', ids, 'OR', '()') - call map(advance_tags, '"-" . v:val') - call <SID>NM_tag(filter, advance_tags) + call <SID>NM_tag(filter, remove_tags_formatted) + let filter = <SID>NM_combine_tags('not tag:', add_tags, 'OR', '()') + \ + ['AND'] + \ + <SID>NM_combine_tags('', ids, 'OR', '()') + call <SID>NM_tag(filter, add_tags_formatted) call <SID>NM_show_next(1, 1) return endif @@ -614,10 +631,12 @@ function! s:NM_show_advance_marking_read_and_archiving() if has_key(msg_top,'match') && msg_top['match'] != '0' redraw " do this last to hide the latency - let filter = <SID>NM_combine_tags('tag:', advance_tags, 'OR', '()') + let filter = <SID>NM_combine_tags('tag:', remove_tags, 'OR', '()') + \ + ['AND', msg_top['id']] + call <SID>NM_tag(filter, remove_tags_formatted) + let filter = <SID>NM_combine_tags('not tag:', add_tags, 'OR', '()') \ + ['AND', msg_top['id']] - call map(advance_tags, '"-" . v:val') - call <SID>NM_tag(filter, advance_tags) + call <SID>NM_tag(filter, add_tags_formatted) endif return endif @@ -1375,6 +1394,12 @@ endif if !exists('g:notmuch_compose_headers') let g:notmuch_compose_headers = s:notmuch_compose_headers_defaults endif +if !exists('g:notmuch_advance_remove_tags') + let g:notmuch_advance_remove_tags = s:notmuch_advance_remove_tags +endif +if !exists('g:notmuch_advance_add_tags') + let g:notmuch_advance_add_tags = s:notmuch_advance_add_tags +endif " --- assign keymaps {{{1 -- 1.7.4.1