It comes prepackaged for Aquamacs users, see the Download page on aquamacs.org.
Start Slime with
M-x slime. The first time, a lot of elip files will be compiled on the fly, but the next time it will start much faster. From the on-line help, "This uses the inferior-lisp package to start a Lisp process, loads and starts the Lisp-side server (known as “Swank”), and establishes a socket connection between Emacs and Lisp." The REPL starts CMUCL in my case, because it is the one specified as
inferior-lisp-program. It can be changed by adding, e.g.
(setq inferior-lisp-program "/Developer/CCL/scripts/ccl")
.emacs file. Should you want to use other flavours of CL implementations, you can just replace the above by something like
(setq slime-lisp-implementations '((cmucl (lisp "-quiet")) (sbcl ("/opt/sbcl/bin/sbcl") :coding-system utf-8-unix) (ccl ("/Developer/CCL/scripts/ccl"))))
The first program will be selected by default, but it can be changed by using
M-- M-x slime. In this case, Emacs will prompt you to give the name of the program you want to bind to Slime.
We can also use
(append slime-lisp-implementations ...) into the
(setq slime-lisp-implementations ...) to add other programs. This is basically what we will do in the next section.
The SLIME User Manual is available as PDF. Here are my very first impression when using Slime.
First, we lauch Slime and just ask to eval
(+ 1 3).
Then, we deliberately introduce an error when submitting our code to the REPL, in this case we ask
1-2: it popups an SLDB window saying
the variable [1-2] is unbound which means that it has no value bounded to it. Now we can click or select
1: [ABORT] Return to Top-Level. and we're back to the REPL. Another cool thing from using Slime is that you get auto-completion when you are typing into the REPL. For example, let's write a function x -> x^2,
(defun square (x) (* x x))
(We could also use
(def square (lambda (x) (* x x))).)
As soon as you start typing
defun, you'll get this nice prompt for name and argument:
Let's again introduce an error when typing the function definition, say we wrote
(*x x) instead of
(* x x). Here is what we get from the SLDB when we run
(square 5) at the prompt:
Going back to the REPL,
Esc-p two times gives back the previous function definition that we can now correct.
Slime and Clojure
(autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t) (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode)) (require 'swank-clojure) (setq slime-lisp-implementations (append slime-lisp-implementations `((clojure ,(swank-clojure-cmd) :init swank-clojure-init))))
I found a nice tutorial on setting up Slime and Clojure by watching at Emacs with Clojure, Slime and Swank (by Seth Buntin).