SLIME

You don't want to be running Lisp from the command line. The best idea is to use an Emacs interface, and the best Emacs interface is probably SLIME. If you don't like Emacs, I won't be your friend any more.

Installation

Get the CVS version of SLIME:
cvs -d :pserver:anonymous@common-lisp.net:/project/slime/cvsroot login
<enter anonymous as password>
cvs -d :pserver:anonymous@common-lisp.net:/project/slime/cvsroot co -r
FAIRLY-STABLE slime

FAIRLY-STABLE is often a slightly-older-than-bleeding-edge version of SLIME. As of right now (24th Nov 2003) it's more than up to the job.

Installation can more or less follow the instructions in the README. Add this to your .emacs file

(add-to-list 'load-path "/the/path/to/this/directory")
(require 'slime)
(add-hook 'lisp-mode-hook (lambda () (slime-mode t)))
(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
(setq inferior-lisp-program "sbcl")
(setq common-lisp-hyperspec-root "file:///usr/share/doc/hyperspec/")
   ; or wherever you installed the HyperSpec

Getting started

Now restart emacs, then do M-x slime RET (hold down Meta and press x, so that the cursor moves to the minibuffer at the bottom of the screen, then type in "slime" and press Return). The first time you do this it may spend a few minutes scrolling incomprehensible messages while it compiles files, but subsequent invocations should go faster. Eventually you'll get a buffer called *slime-repl* with a CL-USER> prompt

and you can start typing Lisp into it. If anything you type causes an error, the window splits to show you the error message and what your options are for recovering (the "restarts"); just hit the appropriate number (which at this stage is probably TOPLEVEL) to carry on.

Editing files

Anything that you type in at the CL-USER prompt only exists for as long as Lisp is running, so for slightly more permanence it's good to use a file instead. This doesn't mean that you have to start using command-line clients and so on, though: SLIME has special commands in Lisp source file buffers as well to do things like send the current expression to Lisp, compile the file, etc.

Conventionally Lisp source code files have the suffix .lisp, so visit the file foo.lisp. We'll assume it doesn't exist already. Have a look at the screenshot below: we typed in the source code as shown then pressed C-c C-k to compile. The compilation threw up a style-warning in the form underlined in red, and by hovering the mouse over this text, we see what the error was.

As in any Emacs buffer, you can get a summary of the useful key bindings by typing C-h m.

Back to index


Daniel Barlow