Clearly there's some machinery in SLIME for creating streams that are actually connected to sockets that communicate with emacs. My question is there an easy way to, on the Common Lisp side, open a stream such that a new buffer is created in emacs and all data sent to the stream will end up in that buffer? I.e. I'm hoping to be able to do something like this:
(format (make-slime-stream) "hello, world!~%")
and have "hello, world!" appear in a new emacs buffer. (Actually what I'm really hoping to do is redirect the log of AllegroServe to a slime buffer so it's easy to get at without it cluttering up either the SLIME REPL or *inferior-lisp*.
-Peter
Peter Seibel peter@javamonkey.com writes:
Clearly there's some machinery in SLIME for creating streams that are actually connected to sockets that communicate with emacs.
The current implementation of the streams with extra sockets is primarily an efficiency hack and not easily reusable. Currently the Emacs side has doesn't know much about streams and just inserts the output in the REPL buffer.
My question is there an easy way to, on the Common Lisp side, open a stream such that a new buffer is created in emacs and all data sent to the stream will end up in that buffer?
No, there's no easy way. A hacky way is this:
(in-package :swank)
(defun make-log-stream () (make-fn-streams (lambda () (error "Not implemented")) (lambda (string) (send-oob-to-emacs `(:%apply "message" ("%s" ,string))))))
(setq s (nth-value 1 (make-log-stream))) (format s "hello, world!~%") (finish-output s)
This calls Emacs' message with the output of the stream (and message inserts the output in the *Messages* buffer). If you want to insert in an other buffer you could write the your own Emacs Lisp code to do the job. Note that this stream is fully buffered and finish-output is necessary if you have short messages.
Helmut.