Skip to content

What does adding ',%\&chdir '.escape(root, ',') to errroformat actually do? #180

Answered by tpope
iamFIREcracker asked this question in Q&A
Discussion options

You must be logged in to vote

That's a deliberately invalid pattern; it will never match anything. Instead, Projectionist handles it itself in QuickFixCmdPre and QuickFixCmdPost by extracting the value and using it to temporarily :cd:

function! s:qf_pre() abort
let dir = substitute(matchstr(','.&l:errorformat, ',\%(%\\&\)\=\%(ch\)\=dir[ =]\zs\%(\\.\|[^,]\)*'), '\\,' ,',', 'g')
let cwd = getcwd()
if !empty(dir) && dir !=# cwd
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
execute cd fnameescape(dir)
let s:qf_post = cd . ' ' . fnameescape(cwd)
endif
endfunction
augroup p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tpope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants