How to reconnect to slime/swank-clojure session?
Asked Answered
C

1

4

It seems that whenever I disconnect from clojure slime session, I cannot reconnect again. I am using leiningen to start the swank session (with lein-swank plugin). So, every time I quit emacs (I know I shouldn't) or reboot/logout I have to restart both slime and swank. Is there a way to re-connect to a slime/clojure-swank session?

Clubfoot answered 2/5, 2010 at 7:6 Comment(0)
A
5

Yes, but you have to tell swank not to close the connection:

lein swank 4005 "localhost" :dont-close true

Note that you have to supply the port and host name if you want to pass the :dont-close true portion; 4005 and "localhost" are the default values.

In fact, this makes it possible to connect multiple REPLs to the same swank instance at the same time! Then you can type in (def foo :foo) in one Emacs and see foo evaluate to :foo in the other. :-)

Avalon answered 2/5, 2010 at 8:32 Comment(5)
Doesn't seem to work for me. I get Wrong number of args passed to: swank$swankClubfoot
Apparently this functionality was introduced in a commit to Leiningen (lein-swank resides in the main Leiningen repo) from 9 Feb without the host argument, then host was added on 21 Mar. Hopefully you're using the version which doesn't accept host -- try dropping it from the command line. If you're using a pre-9 Feb Leiningen, perhaps this might be a reason to upgrade!Sari
I am using whatever lein installed as a dependency (not sure, but it claims to be 1.1.0). When I remove "localhost" from the command I get the same error.Clubfoot
The solution seems to be to replace 1.1.0 lein-swank with 1.2.0-SNAPSHOT in the dev-dependencies. Then it takes all the mentioned arguments.Clubfoot
Be sure not to use the sayoonara command within SLIME, as that asks the Swank server running in the Lisp host to shut down. Instead, use the disconnect command. As of today, that causes some error messages to be printed by the Swank server, but it does seem to accommodate subsequent reconnection to the same running Clojure process.Galiot

© 2022 - 2024 — McMap. All rights reserved.