Next: , Up: Connecting to a remote lisp


7.1.1 Setting up the lisp image

When you want to load swank without going through the normal, Emacs based, process just load the swank-loader.lisp file. Just execute

     (load "/path/to/swank-loader.lisp")
     (swank-loader:init)

inside a running lisp image1. Now all we need to do is startup our swank server. The first example assumes we're using the default settings.

     (swank:create-server)

Since we're going to be tunneling our connection via ssh2 and we'll only have one port open we want to tell swank to not use an extra connection for output (this is actually the default in current SLIME):

     (setf swank:*use-dedicated-output-stream* nil)

If you need to do anything particular (like be able to reconnect to swank after you're done), look into swank:create-server's other arguments. Some of these arguments are

:PORT
Port number for the server to listen on (default: 4005).
:STYLE
See See Communication style.
:DONT-CLOSE
Boolean indicating if the server will continue to accept connections after the first one (default: NIL). For “long-running” lisp processes to which you want to be able to connect from time to time, specify :dont-close t
:CODING-SYSTEM
String designating the encoding to be used to communicate between the Emacs and Lisp.

So the more complete example will be

     (swank:create-server :port 4005  :dont-close t :coding-system "utf-8-unix")

On the emacs side you will use something like

     (setq slime-net-coding-system 'utf-8-unix)
     (slime-connect "127.0.0.1" 4005))

to connect to this lisp image from the same machine.


Footnotes

[1] SLIME also provides an ASDF system definition which does the same thing

[2] there is a way to connect without an ssh tunnel, but it has the side-effect of giving the entire world access to your lisp image, so we're not going to talk about it