Setting up SLIME Tramp filename translation

Picking up from “Remote login with SSH key pair” and the updated “Setting up Lisp & Hunchentoot on a web server”, when i run emacs locally and connect to my running lisp + hunchentoot process on the server, the REPL alone, although awesome, is insufficient for my hacking need. I’ll need some way to work with remote files…

First let’s see how we can open a remote lisp file that we will later on use to test compiling. First we must start an ssh tunnel to the remote box (look at step 13 in “Setting up Lisp & Hunchentoot on a web server”). Start up emacs and slime-connect to the remote box. To open up a remote file i do C-x C-f and then on the interaction line:

Here we are logging in through ssh to with user hunchentoot and we want to open file /var/lib/hunchentoot/test.lisp on the remote filesystem. Inside type:

I save it and when i try to compile it with C-c C-k i end up with something like:

As you can see it tries to load a non-existing file because it is not translating the pathnames. Let’s setup slime-tramp filename translations, for this you must load slime-tramp together with slime in emacs, either with:

(require 'slime-tramp)

Or the way i’m doing it, by means of slime-setup (from looking at the slime documentation i believe this is the recommended way of doing this now):

slime-setup '(slime-repl slime-tramp)

Now whenever slime is loaded slime-tramp will be loaded as well, here’s a list of current available packages/modules that can be loaded with slime.

We now have setup emacs to load slime-tramp but we still haven’t explained slime how to translate stuff, for this we start by slime-connect’ing to the remote lisp process and from the repl run:

Take note of the result, here it’s la45-12 and it is the name of our remote machine instance that we’ll need to setup the translations. Open your .emacs and set something like:

Note: The ssh url used here is for my login, you’ll need to change the user and domain name/ip address to reflect your own ssh login string.

This piece of code will execute when slime connects and run two PUSH forms. The first form (‘.*’ is a regular expression that will match any value) and it’s purpose is to deal with local files, this is a safeguard in case you ever run slime with a local lisp process, if i only had the second PUSH form and tried to compile a local file in a local lisp session emacs would spit the following error:

No filename-translations for hostname: workstation

The second PUSH will add the translation functions for interacting with the machine-instance “li45-12” (if you remember you noted this value when you ran (cl:machine-instance) on the remote repl).

Where workstation is my local machine-instance.

Now, restart emacs, slime-connect again and, open the remote file we just created:

Now when i retry compiling the file it compiles successfully, we can test this by switching our buffer to the slime repl.

Now finally i can go ahead and hack away at my remote lisp environment. Hope this was helpful to anyone, i know it will definitely come in handy to me in a few months.

2 thoughts on “Setting up SLIME Tramp filename translation”

Leave a Reply

Your email address will not be published. Required fields are marked *