Strange Loops

No Matter Where You Go, There You Are

Setting Up Clojure, Emacs and SLIME

| Comments

[Update: I redid these instructions when I moved to clojure 1.1 . Take a look if you're interested]

For the last couple of days, I've been enjoying the combination of Clojure + Emacs + SLIME . Getting it working on my Mac was relatively straightforward (although I hit one minor bump). 

To get started, git and Java 6 need to be installed on your Mac. I used the Java 6 SDK supplied by Apple (Java 5 might also work but I'm not using that). git was installed through MacPorts .

1. Get clojure-mode

> mkdir ~/src
> cd ~/src
> git clone git://github.com/jochu/clojure-mode.git

2. Add these lines to your .emacs

(add-to-list 'load-path "~/src/clojure-mode") 

(require 'clojure-mode)

Restart emacs (or evaluate the 2 lines above)

3. M-x clojure-install (inside emacs)

Voila_Capture12

You'll be prompted with a default installation directory of ~/src. Note the M(eta) key here is mapped to my Alt and Esc key. YMMV.

Voila_Capture13

I used the default.

4. When done, you'll see something like this.

Voila_Capture14

5. If you do as the instruction suggest, you'll get an error about missing a file or directory.

Voila_Capture15

6. Add the following lines to your .emacs

(setq swank-clojure-classpath '())
(add-to-list 'swank-clojure-classpath "~/src/clojure-contrib/clojure-contrib.jar")
(add-to-list 'swank-clojure-classpath "~/src/clojure/clojure-1.0.0-SNAPSHOT.jar")
(clojure-slime-config)

Restart emacs (or evaluate these lines). Note: you can use the swank-clojure-classpath variable to add jar files or directories to your classpath to work with in SLIME.

7. M-x slime

Voila_Capture17

You're done! Have fun. To get started with clojure, I recommend this book:

P.S Some weirdness with the formatting. I was having trouble with the blog editor.