* Daniel Patru [2005-11-04 03:27+0100] writes:
Anyway to make this work? (I'm trying to do some processing in between user input.)
As Pascal Bourguignon said, you should flush the output buffer.
But you also need to be careful with LISTEN. Actually reading from *standard-input* in SLIME is a bit weird. LISTEN (in SLIME) returns true if there is any buffered input, e.g. if you call READ-CHAR the Emacs REPL buffer switches to "read-mode" and the next time you press return the entire line gets buffered.
Also note that the REPL buffer is usually not in "read-mode" and that pressing return (usually) doesn't write anything to the input buffer. Keep an eye on the modeline, there is an indicator [read] if the REPL is in read-mode.
Some other issues are:
- buffered input is discarded before evaluation requests i.e. about every time when SLIME prints a prompt. (This means that LISTEN returns false most of the time.)
- if you want to send an "end-of-transmission" (like C-d in a terminal) you have to press C-u RET.
Your example works a bit better if you write it like this:
(defun prompt () (do ((line nil (read))) ((eq line 'q)) (when line (print line)) (print '>) (finish-output) (sleep 1)))
Helmut.