mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 07:11:41 +01:00
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.
This commit is contained in:
parent
384037285f
commit
e9ca8e5037
1 changed files with 14 additions and 5 deletions
|
@ -271,14 +271,14 @@ function! s:NM_search_archive_thread()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:NM_search_filter()
|
function! s:NM_search_filter()
|
||||||
call <SID>NM_search_filter_helper('Filter: ', '')
|
call <SID>NM_search_filter_helper('Filter: ', '', '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:NM_search_filter_by_tag()
|
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
|
endfunction
|
||||||
|
|
||||||
function! s:NM_search_filter_helper(prompt, prefix)
|
function! s:NM_search_filter_helper(prompt, prefix, joiner)
|
||||||
" TODO: input() can support completion
|
" TODO: input() can support completion
|
||||||
let text = input(a:prompt)
|
let text = input(a:prompt)
|
||||||
if !strlen(text)
|
if !strlen(text)
|
||||||
|
@ -286,8 +286,17 @@ function! s:NM_search_filter_helper(prompt, prefix)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let tags = split(text)
|
let tags = split(text)
|
||||||
map(tags, 'and a:prefix . v:val')
|
if strlen(a:prefix)
|
||||||
let tags = b:nm_search_words + tags
|
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('%')
|
let prev_bufnr = bufnr('%')
|
||||||
setlocal bufhidden=hide
|
setlocal bufhidden=hide
|
||||||
|
|
Loading…
Reference in a new issue