Hello!
I have been trying to run a job asynchronously and capture the output, but
despite reading the docs many times I can't get it to work.
Ideally I want all the diff output in one go, rather than line by line, so I
first tried using only an on_exit callback:
let cmd = 'diff A B'
let job = job_start(cmd, {'exit_cb': 'MyExitHandler'})
And then:
function! MyExitHandler(job, exit_status)
let data = ch_read(a:job)
echom data
endfunction
I would expect the handler to be called just about immediately but nothing
happens. After 30s of waiting I get bored and move the cursor (if I'm in
normal mode) / press <Escape> (if I'm in insert mode), at which point "E906:
not an open channel" is echoed.
>From this I deduce that the handler isn't called when the job exits, but
>instead some time later as and when vim checks up on the job.
So I tried using an on_stdout callback as well:
let job = job_start(cmd, {'on_stdout': 'MyOutHandler', 'exit_cb':
'MyExitHandler'})
And also:
function! MyOutHandler(channel, message)
echom a:message
endfunction
This handler gets called just about immediately, as expected, but a:message is
always 'DETACH', not the diff output. And then a few seconds later the exit
handler echoes its E906 error.
Please could somebody tell me what I'm doing wrong?
I'm using Vim v7.4.1770.
Many thanks in advance,
Andrew Stewart
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.