Mercurial > vim
comparison runtime/pack/dist/opt/cfilter/plugin/cfilter.vim @ 14637:0ecb909e3249
Update runtime files.
commit https://github.com/vim/vim/commit/fc65cabb15d0236bce001ad78e12a40511caf941
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 28 22:58:02 2018 +0200
Update runtime files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 28 Aug 2018 23:00:08 +0200 |
parents | 2b9c586918f8 |
children | 912224cab37f |
comparison
equal
deleted
inserted
replaced
14636:91eef21ff090 | 14637:0ecb909e3249 |
---|---|
1 " cfilter.vim: Plugin to filter entries from a quickfix/location list | 1 " cfilter.vim: Plugin to filter entries from a quickfix/location list |
2 " Last Change: May 12, 2018 | 2 " Last Change: Aug 23, 2018 |
3 " Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com) | 3 " Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com) |
4 " Version: 1.0 | 4 " Version: 1.1 |
5 " | 5 " |
6 " Commands to filter the quickfix list: | 6 " Commands to filter the quickfix list: |
7 " :Cfilter[!] {pat} | 7 " :Cfilter[!] /{pat}/ |
8 " Create a new quickfix list from entries matching {pat} in the current | 8 " Create a new quickfix list from entries matching {pat} in the current |
9 " quickfix list. Both the file name and the text of the entries are | 9 " quickfix list. Both the file name and the text of the entries are |
10 " matched against {pat}. If ! is supplied, then entries not matching | 10 " matched against {pat}. If ! is supplied, then entries not matching |
11 " {pat} are used. | 11 " {pat} are used. The pattern can be optionally enclosed using one of |
12 " :Lfilter[!] {pat} | 12 " the following characters: ', ", /. If the pattern is empty, then the |
13 " last used search pattern is used. | |
14 " :Lfilter[!] /{pat}/ | |
13 " Same as :Cfilter but operates on the current location list. | 15 " Same as :Cfilter but operates on the current location list. |
14 " | 16 " |
15 if exists("loaded_cfilter") | 17 if exists("loaded_cfilter") |
16 finish | 18 finish |
17 endif | 19 endif |
18 let loaded_cfilter = 1 | 20 let loaded_cfilter = 1 |
19 | 21 |
20 func s:Qf_filter(qf, pat, bang) | 22 func s:Qf_filter(qf, searchpat, bang) |
21 if a:qf | 23 if a:qf |
22 let Xgetlist = function('getqflist') | 24 let Xgetlist = function('getqflist') |
23 let Xsetlist = function('setqflist') | 25 let Xsetlist = function('setqflist') |
24 let cmd = ':Cfilter' . a:bang | 26 let cmd = ':Cfilter' . a:bang |
25 else | 27 else |
26 let Xgetlist = function('getloclist', [0]) | 28 let Xgetlist = function('getloclist', [0]) |
27 let Xsetlist = function('setloclist', [0]) | 29 let Xsetlist = function('setloclist', [0]) |
28 let cmd = ':Lfilter' . a:bang | 30 let cmd = ':Lfilter' . a:bang |
29 endif | 31 endif |
30 | 32 |
33 let firstchar = a:searchpat[0] | |
34 let lastchar = a:searchpat[-1:] | |
35 if firstchar == lastchar && | |
36 \ (firstchar == '/' || firstchar == '"' || firstchar == "'") | |
37 let pat = a:searchpat[1:-2] | |
38 if pat == '' | |
39 " Use the last search pattern | |
40 let pat = @/ | |
41 endif | |
42 else | |
43 let pat = a:searchpat | |
44 endif | |
45 | |
46 if pat == '' | |
47 return | |
48 endif | |
49 | |
31 if a:bang == '!' | 50 if a:bang == '!' |
32 let cond = 'v:val.text !~# a:pat && bufname(v:val.bufnr) !~# a:pat' | 51 let cond = 'v:val.text !~# pat && bufname(v:val.bufnr) !~# pat' |
33 else | 52 else |
34 let cond = 'v:val.text =~# a:pat || bufname(v:val.bufnr) =~# a:pat' | 53 let cond = 'v:val.text =~# pat || bufname(v:val.bufnr) =~# pat' |
35 endif | 54 endif |
36 | 55 |
37 let items = filter(Xgetlist(), cond) | 56 let items = filter(Xgetlist(), cond) |
38 let title = cmd . ' ' . a:pat | 57 let title = cmd . ' /' . pat . '/' |
39 call Xsetlist([], ' ', {'title' : title, 'items' : items}) | 58 call Xsetlist([], ' ', {'title' : title, 'items' : items}) |
40 endfunc | 59 endfunc |
41 | 60 |
42 com! -nargs=+ -bang Cfilter call s:Qf_filter(1, <q-args>, <q-bang>) | 61 com! -nargs=+ -bang Cfilter call s:Qf_filter(1, <q-args>, <q-bang>) |
43 com! -nargs=+ -bang Lfilter call s:Qf_filter(0, <q-args>, <q-bang>) | 62 com! -nargs=+ -bang Lfilter call s:Qf_filter(0, <q-args>, <q-bang>) |