Lcd wrote:
> On 26 April 2016, Bram Moolenaar <[email protected]> wrote:
> >
> > James McCoy wrote:
> >
> > > On Mon, Apr 25, 2016 at 11:06:43PM +0200, Bram Moolenaar wrote:
> > > >
> > > > Andrew Stewart wrote:
> > > >
> > > > > 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.
> > > >
> > > > This works. But the script should use "out_cb":
> > > >
> > > > func! OutHandler(channel, msg)
> > > > echomsg a:msg
> > > > endfunc
> > > > let cmd = 'diff -u /tmp/a /tmp/b'
> > > > let job = job_start(cmd, {'out_cb': 'OutHandler'})
> > > >
> > > > The echo statements overwrite each other, "DETACH" is the last one. Use
> > > > ":messages" to see what happened before this.
> > >
> > > Why is Vim injecting "DETACH" into the output? The netbeans code uses
> > > is because that's part of the established protocol, but why is that
> > > being imposed on every other user of channels?
> >
> > Yeah, I was also wondering if we need it.
>
> Some way to test for EOF would be more useful, IMO. Not quite the
> same thing as a close callback.
You can now use ch_status() for that. If it returns "open" or
"buffered" there may be more to read. When "closed" then it's done.
I have added this example in the help:
func! CloseHandler(channel)
while ch_status(a:channel) == 'buffered'
echomsg ch_read(a:channel)
endwhile
endfunc
let job = job_start(command, {'close_cb': 'CloseHandler'})
--
TIM: Too late.
ARTHUR: What?
TIM: There he is!
[They all turn, and see a large white RABBIT lollop a few yards out of the
cave. Accompanied by terrifying chord and jarring metallic monster noise.]
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.