view runtime/pack/dist/opt/cfilter/plugin/cfilter.vim @ 25155:a37cf57980f9 v8.2.3114

patch 8.2.3114: Amiga-like systems: build error using stat() Commit: https://github.com/vim/vim/commit/599a6e5b3629d943a795cd69e4d3d19886f86405 Author: =?UTF-8?q?Ola=20S=C3=B6der?= <rolfkopman@gmail.com> Date: Tue Jul 6 20:15:46 2021 +0200 patch 8.2.3114: Amiga-like systems: build error using stat() Problem: Amiga-like systems: build error using stat(). Solution: Only build swapfile_process_running() on systems where it is actually used. (Ola S?der, closes #8519)
author Bram Moolenaar <Bram@vim.org>
date Tue, 06 Jul 2021 20:30:03 +0200
parents 0ecb909e3249
children 912224cab37f
line wrap: on
line source

" cfilter.vim: Plugin to filter entries from a quickfix/location list
" Last Change: Aug 23, 2018
" Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
" Version: 1.1
"
" Commands to filter the quickfix list:
"   :Cfilter[!] /{pat}/
"       Create a new quickfix list from entries matching {pat} in the current
"       quickfix list. Both the file name and the text of the entries are
"       matched against {pat}. If ! is supplied, then entries not matching
"       {pat} are used. The pattern can be optionally enclosed using one of
"       the following characters: ', ", /. If the pattern is empty, then the
"       last used search pattern is used.
"   :Lfilter[!] /{pat}/
"       Same as :Cfilter but operates on the current location list.
"
if exists("loaded_cfilter")
    finish
endif
let loaded_cfilter = 1

func s:Qf_filter(qf, searchpat, bang)
    if a:qf
	let Xgetlist = function('getqflist')
	let Xsetlist = function('setqflist')
	let cmd = ':Cfilter' . a:bang
    else
	let Xgetlist = function('getloclist', [0])
	let Xsetlist = function('setloclist', [0])
	let cmd = ':Lfilter' . a:bang
    endif

    let firstchar = a:searchpat[0]
    let lastchar = a:searchpat[-1:]
    if firstchar == lastchar &&
		\ (firstchar == '/' || firstchar == '"' || firstchar == "'")
	let pat = a:searchpat[1:-2]
	if pat == ''
	    " Use the last search pattern
	    let pat = @/
	endif
    else
	let pat = a:searchpat
    endif

    if pat == ''
	return
    endif

    if a:bang == '!'
	let cond = 'v:val.text !~# pat && bufname(v:val.bufnr) !~# pat'
    else
	let cond = 'v:val.text =~# pat || bufname(v:val.bufnr) =~# pat'
    endif

    let items = filter(Xgetlist(), cond)
    let title = cmd . ' /' . pat . '/'
    call Xsetlist([], ' ', {'title' : title, 'items' : items})
endfunc

com! -nargs=+ -bang Cfilter call s:Qf_filter(1, <q-args>, <q-bang>)
com! -nargs=+ -bang Lfilter call s:Qf_filter(0, <q-args>, <q-bang>)