

Clojure with Emacs and Slime/Swank on Ubuntu
Warning!
This tutorial is out of date. Please refer to the latest tutorial on the subject: Clojure, Swank, and Leiningen with Emacs on Linux
Alternatively, The following list contains links to the offical documentation as well as Leiningen, one of the most popular tools for use in developing clojure projects.
- Clojure Wiki - Getting Started: http://www.assembla.com/wiki/show/clojure/Getting_Started
- Leiningen: http://github.com/technomancy/leiningen
Prerequisites
This tutorial assumes that the following tutorials have been successfully completed:
Install clojure-mode
clojure-mode is a emacs mode to handle clojure files.
~$ cd ~/opt ~$ git clone git://github.com/jochu/clojure-mode.git
Install Slime
Install Superior Lisp Interation Mode for Emacs.
Slime Homepage: http://common-lisp.net/project/slime
~$ cd ~/opt ~$ git clone git://git.boinkor.net/slime.git
Install swank-clojure
swank-clojure, the server-side of slime, provides a server-based clojure REPL.
~$ cd ~/opt ~$ git clone git://github.com/jochu/swank-clojure.git
Configure Emacs
Add these specifics to the .emacs file.
;; clojure-mode
(add-to-list 'load-path "~/opt/clojure-mode")
(require 'clojure-mode)
;; swank-clojure
(add-to-list 'load-path "~/opt/swank-clojure/src/emacs")
(setq swank-clojure-jar-path "~/.clojure/clojure.jar"
swank-clojure-extra-classpaths (list
"~/opt/swank-clojure/src/main/clojure"
"~/.clojure/clojure-contrib.jar"))
(require 'swank-clojure-autoload)
;; slime
(eval-after-load "slime"
'(progn (slime-setup '(slime-repl))))
(add-to-list 'load-path "~/opt/slime")
(require 'slime)
(slime-setup)
Test Configuration
Download ants.clj from http://clojure.googlegroups.com/web/ants.clj
Save ants.clj to your home directory.
Open emacs and load the file. Emacs key combinations are written like M-x and C-x where M stands for Meta (which is the Alt key on many keyboards) and C stands for Control (normally labeled Crtl.)
~$ emacs ### Open the ants file C-x C-f ants.clj
Split the screen horizontally and start slime.
C-x 2 ### Click with the mouse on the bottom buffer to select it. M-x slime
Back in the ants.clj file, page down to the ;; use ;; section. Compile and load the file with slime. This will also launch a new application window.
C-c C-k
Now, interactively execute the last four lines of the file. With the cursor after the line (def ants (setup)), do this:
C-x C-e
Execute the last three lines using the same key combination.
Ants marching ;-)