Bill Clementson's Blog

Bits and pieces (mostly Lisp-related) that I collect from the ether.

November 2008
Sun Mon Tue Wed Thu Fri Sat
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Oct  Dec

A Basic Emacs Setup for Clojure

Tuesday, November 18, 2008

A month ago, I wrote a post titled "Exploring Clojure (Lisp on the JVM) - Part 2 - Setup". In it, I listed the steps I went though to get Clojure setup on my machine. The steps I listed would normally work ok if you already use Emacs and SLIME and are used to customizing your .emacs file (Note: with the latest Clojure AOT changes, the setup instructions I listed in that post will need a little tweaking). However, my post wasn't meant to be a tutorial or a step-by-step set of instructions, it was just a list of things that I did to get going with Clojure. If you want/need a step-by-step tutorial for getting all the "key" components of a Clojure development environment setup, there is an excellent tutorial available. If, on the other hand, you want to avoid too many setup steps and want to get started with Clojure as quickly as possible, it is quite easy to get a working Emacs development environment setup for Clojure without using SLIME:

  1. Download latest Clojure from svn:
    svn co https://clojure.svn.sourceforge.net/svnroot/clojure clojure
  2. Download latest clojure-mode from git:
    git clone git://github.com/jochu/clojure-mode.git
  3. Use ant to build clojure (just "cd" to the clojure directory and type "ant")
  4. Put the following minimal setup in your .emacs file (adjusting the paths as necessary):
    (setq inferior-lisp-program "java -server -cp /path/to/clojure/trunk/clojure.jar clojure.lang.Repl") 
    (setq load-path (cons "/path/to/clojure-mode" load-path))   
    (require 'clojure-auto) 
  5. Restart Emacs, load a clojure (clj) file in a buffer, press C-c C-z to get a repl and you've got a working development environment setup.
A slightly more sophisticated version of the .emacs file setup is in the Clojure Wiki. Later, after you've programmed in Clojure a bit and are ready for a better Lisp development experience, you can install SLIME. SLIME is a great Lisp editing package; but, if you've never used it for programming in Lisp before, then you can wait until you're ready to use it. And, it looks like Rich Hickey agrees with this too.

emacs Copyright © 2008 by Bill Clementson