[Ecls-list] Problems with slime
Tobias C. Rittweiler
tcr at freebits.de
Sun Feb 7 23:02:54 UTC 2010
"Tobias C. Rittweiler" writes:
> Juan Jose Garcia-Ripoll writes:
>
>> Slime gets my computer at 100% activity because it has some strange way of
>> waiting for input: this is a loop over streams, inifite, using
>> read-char-no-hang without ever waiting. I am sure there are better ways of
>> doing this. This is in swank-backend.lisp -- do all implementations have
>> this problem?
>>
>> (defun wait-for-streams (streams timeout)
>> (loop
>> (when (check-slime-interrupts) (return :interrupt))
>> (let ((ready (remove-if-not #'stream-readable-p streams)))
>> (when ready (return ready)))
>> (when timeout (return nil))
>> (sleep 0.1)))
>
> The problem is that not more advanced ways are implemented. Slime can
> also me made to use threads, and serve-event, but ECL's backend does not
> support that.
>
> I tried to do both in past, but encountered non-obvious problems. I'll
> polish up, and commit the work in progress.
OK, juanjo, I committed the work in progress.
The threading stuff is defined at the end of swank-ecl.lisp.
To activate it, you have to put
;; for debugging messages of the swank server
(setq swank:*log-events* t)
(setq swank:*communication-style* :spawn)
into ~/.swank.lisp
Also make sure to put
(slime-setup '(slime-fancy))
into your .emacs, after (require 'slime).
If you start slime, you'll see it gets stuck.
It gets stuck in ENCODE-MESSAGE in swank-rpc.lisp, before writing to the
STREAM parameter.
The stream that is passed as STREAM parameters comes from:
make-socket-io-stream in swank-ecl.lisp
<- accept-connection in swank-ecl.lisp
<- accept-authenticated-connection in swank.lisp
<- serve-connection in swank.lisp
SERVE-CONNECTION will store the result of MAKE-SOCKET-IO-STREAM into the
SOCKET-IO slot of a CONNECTION.
DISPATCH-EVENT (which is run in a background control thread) will call
ENCODE-MESSAGE with the sockets-io stream.
The first thing the Emacs side will do once a socket connection has been
established is to send
(:emacs-rex
(swank:connection-info) ; <-- expression to be evaluated
"COMMON-LISP-USER" t 1) ; <-- metainformation
over to the Swank server. You can see that in the *slime-events*
buffer. (*slime-events* contains the events sent/received by the Emacs
client side; if swank:*log-events* is T, the Common Lisp swank server
will print events sent/received to error-output.
:EMACS-REX is a Remote-EXpression, or in other words: an RPC.
I.e. the Emacs side wants (SWANK:CONNECTION-INFO) to be evaluated by the
swank server.
Due to *LOG-EVENTS*, the last thing you'll see in *inferior-lisp* is
WRITE: (:return (:ok (:pid 17981
:style :spawn
:lisp-implementation (:type "ECL"
:name "ECL"
:version "10.2.1")
...)))
which is exactly what the Emacs side expects.
But because *slime-events* does only contain the (:EMACS-REX ...), but
no (:RETURN (:OK ...)), this means that this return value is not
transfered over the socket.
Hm, I hope that's enough to get you going.
-T.
More information about the ecl-devel
mailing list