This is a clarification of my previous question..
My question is: How do I do a non-blocking read in the slime REPL?
I tried (and (listen) (read-line)) and (read-char-no-hang) but keep getting the message: ; pipelined request... (swank:listener-eval "<input>") in the minibuffer.
E.g. CL-USER> (progn (sleep 3) (and (listen) (read-line))) 2 2 CL-USER> NIL
I typed the first 2, the minibuffer flashed the message ; pipelined request... (swank:listener-eval "2 ) then returned the 2, CL-USER>, and NIL.
In constrast, typing (read-line) without the (listen) works:
CL-USER> (read-line) 2 "2" NIL
Similar things happen when I try (read-char-no-hang) in place of (and (listen) (read-line)). Both of these work (function as a non-blocking read) in a REPL run from the shell (no emacs, no slime.)
It seems that any new input in the slime REPL during a running command is buffered as a new command instead of as input to the currently running command.
I tried a blocking read-line after the non-blocking read-line and typed: 1<newline>2<newline>3<newline>4<newline> and got: CL-USER> (progn (sleep 10) (and (listen) (read-line)) (print (list (read-line)))) 1 2 3 4 3 CL-USER> 4 CL-USER> 2 CL-USER> 1 CL-USER> 5
("5") ("5") CL-USER>
I typed the last 5 after the sleep period. It seems that the 1, 2, 3, and 4 were processed at toplevel while the last 5 was used as input to unblock the previous read-line.
Is it even possible to do a non-blocking read in the slime REPL, or is this one of the things I have to give up if I want to use slime?
Thanks, Dan
* Daniel Patru [2005-11-04 19:39+0100] writes:
It seems that any new input in the slime REPL during a running command is buffered as a new command instead of as input to the currently running command.
As I said in the other message: text is only added to the input buffer if the REPL is in read-mode. The only way to switch the to read-mode is to (possibly indirectly) call READ-CHAR. READ-CHAR will get a chunk of text, append it to the input buffer, and disable read-mode afterwards.
Is it even possible to do a non-blocking read in the slime REPL, or is this one of the things I have to give up if I want to use slime?
I think that's correct, i.e. it's not possible. At least not with our current approach.
Helmut.