diff options
author | Bart Trojanowski <bart@jukie.net> | 2009-11-22 17:17:20 -0500 |
---|---|---|
committer | Bart Trojanowski <bart@jukie.net> | 2009-11-25 00:48:54 -0500 |
commit | e9ca8e5037a4292443eb1cac8540757f118b83f4 (patch) | |
tree | 87fba0c519dbf3bb2db313b2860c537b3fad4e96 /vim/plugin | |
parent | 384037285fa268cc75eedb0dc81e1781f4d45806 (diff) |
vim: cleanup tag filtering
Given an existing search expression and a regular filter, the resulting
search will be:
EXISTING AND ( NEW )
With a tag filter each of the tags given will be prefixed with tag: and
separated by AND.
Diffstat (limited to 'vim/plugin')
-rw-r--r-- | vim/plugin/notmuch.vim | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index e9370990..7ba35f37 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -271,14 +271,14 @@ function! s:NM_search_archive_thread() endfunction function! s:NM_search_filter() - call <SID>NM_search_filter_helper('Filter: ', '') + call <SID>NM_search_filter_helper('Filter: ', '', '') endfunction function! s:NM_search_filter_by_tag() - call <SID>NM_search_filter_helper('Filter Tag(s): ', 'tag:') + call <SID>NM_search_filter_helper('Filter Tag(s): ', 'tag:', 'and') endfunction -function! s:NM_search_filter_helper(prompt, prefix) +function! s:NM_search_filter_helper(prompt, prefix, joiner) " TODO: input() can support completion let text = input(a:prompt) if !strlen(text) @@ -286,8 +286,17 @@ function! s:NM_search_filter_helper(prompt, prefix) endif let tags = split(text) - map(tags, 'and a:prefix . v:val') - let tags = b:nm_search_words + tags + if strlen(a:prefix) + call map(tags, 'a:prefix . v:val') + endif + if strlen(a:joiner) + let idx = len(tags) - 1 + while idx > 0 + call insert(tags, a:joiner, idx) + let idx = idx - 1 + endwhile + endif + let tags = b:nm_search_words + ['and', '''('] + tags + [')'''] let prev_bufnr = bufnr('%') setlocal bufhidden=hide |