Strange Loops

No Matter Where You Go, There You Are

Moving to Clojure 1.1

| Comments

I'm not using the 1.1 features yet but I was planning on it. During the upgrade to clojure 1.1, I broke my emacs, slime and clojure setup. That's a good thing since the process has simplified since the last time I did it.

Here's what I did on my Mac (running Leopard). Git is a requirement. I installed mine through MacPorts.

First, I got myself an emacs starter kit. Since I'm using aquamacs, I went with an aquamacs variant of the starter kit. Aquamacs Emacs Starter Kit vs Emacs Starter Kit . Follow the instructions for installing the appropriate emacs starter kit. It should look something like this:

Voila_Capture19
 

In this process I learnt a little about Aquamacs. The dot emacs file aka ~/.emacs  are read after the preferences that are under  ~/Library/Preferences/Aquamacs Emacs. Since I mostly used Aquamacs for hacking clojure, I didn't care and nuked all my emacs preferences. Your mileage may vary. Afterward your Preferences.el file should look like this:

Voila_Capture20
Restart Aquamacs to ensure the new preferences get taken.

One of the important things the Emacs Starter Kit installs is the package manager for emacs (aka elpa). I used elpa to install the swank-clojure package. The starter kit also defaults Aquamacs to green text on a black background (changing that is left as an exercise to the reader).

You don't need to but I wanted to check out the packages available to be installed. The M key below is the meta key which on my Mac is bound to the Option and Esc key. Your key bindings might be set up differently but I would try the Option or Esc key to start with.

Voila_Capture21  

This is what the package list looks like.
Voila_Capture22
To install a package, I used the package-install command.

Voila_Capture23

You'll be prompted for the package to install.

Voila_Capture24
You'll see some text scrolling by in a buffer. It looks like various emacs lisp files are being compiled. I got some errors. I ignored them. It seemed alright.

Once swank-clojure is installed, it's time to install clojure. To do this, I started up slime.

Voila_Capture25  

You'll get prompted about clojure not being installed. You want to say yes here.

Voila_Capture26  

You'll see some status messages about clojure getting installed. For reference purposes, this process installs clojure, contrib and swank clojure jars in ~/.swank-clojure Voila_Capture27  

Once that's completed, restart Aquamacs and type   'M-x slime' . You should now be ready to hack clojure code.

If you need a custom classpath, you'll need to set the  swank-clojure-classpath variable. I created a directory containing all my jar files (in ~/.emacs.d/clojure ) and have all the jar files there available in my slime session. To do this, my ~/.emacs file contains the following lines:

(setq swank-clojure-classpath 

      (append 

       (directory-files "~/.swank-clojure" t ".jar$")

       (directory-files "~/.emacs.d/clojure" t ".jar$")))

This approach of globbing jar files together is simple and pretty effective. Alternatively,  leiningren appears to be the new hotness in terms of managing clojure dependancies. It's something I'll look at in the future.