I'm writing small liniting plugin and I want to show errors in the quickfix as soon as errorfile changes.
fu! OpenErrors(job_id, data, event)
let l:winid = win_getid()
let l:output = split(a:data[0])
echom l:output[0] . l:output[2]
let l:view = winsaveview()
exe 'silent! cfile! ' . escape(l:output[0] . l:output[2], '%#/')
call winrestview(l:view)
if len(getqflist()) > 0
copen
else
cclose
endif
call win_gotoid(l:winid)
endfu
The problems with this code is that it the cursor jumps to quickfix window and it's annoying when errorfile changes fast.

makeis running and feeds its result back thoughjob_start()callbacks. On each line fed back, I usecaddexprwhich doesn't trigger to qf-window to open. You can check it by yourself with:cclose+:caddexpr expand('%').":1: Error: test". This means that when I run:Make+:cclose, I can do my:COpenany time I want. – Luc Hermitte Aug 08 '17 at 14:06:caddexpr. You'll want to do it with:cwindowI guess, or some other trick (see my code) that keep the cursor where it was. – Luc Hermitte Aug 08 '17 at 14:06trick to keep cursor where it was? I hope it's not justwinsaveviewand jumping back to previous window. – user1685095 Aug 08 '17 at 20:03gotoid()and it's reverse operation. Plus the:close+:cwin+winnr()-test to know whether an error as been detected -- may be we could checkfilter(getqflist(), 'v:val.type=="E"')now (parts of the code are decade old)? I haven't check whether it would be faster/simpler/equivalent or not. – Luc Hermitte Aug 08 '17 at 20:12