Getting Started with Clojure and Aquamacs

July 2, 2008

I just posted a short screencast on how to get started with Clojure and Aquamacs:

One of the fun features of Clojure, or any Lisp I suppose, is the interactive development workflow. As you can see in the video, you write code by creating expressions that define functions and then you evaluate those functions in the REPL (Read-Eval-Print-Loop). You can redefine a function at any time. You can imagine that if you had a production system running, you could connect to it via a REPL or something like that, evaluate some expressions that redefine functions that contain bugs, and the system would be fixed with no downtime.

Here's the contents of the ~/bin/clj script:

#!/bin/bash 

SRC_DIR=/Users/pbarry/src

CLOJURE_JAR=$SRC_DIR/clojure/clojure.jar
JLINE_JAR=$SRC_DIR/jline/jline-0.9.94.jar

if [ -z "$1" ]; then 
    java -cp $JLINE_JAR:$CLOJURE_JAR jline.ConsoleRunner clojure.lang.Repl    
else
    java -cp $CLOJURE_JAR clojure.lang.Script $1
fi

Posted in Technology | Tags Emacs, Clojure, Aquamacs, Lisp

Comments

1.

Awesome.

# Posted By Lombardi on Wednesday, July 2 2008 at 9:41 PM

2.

Thanks for sharing this!

# Posted By David J. on Sunday, November 2 2008 at 7:19 PM

3.

Very helpful. Thank you. Here is that customization.el snippet for your copy / paste pleasure:

---
(add-to-list 'load-path "~/clojure/clojure-mode")
(setq inferior-lisp-program "clj")
(require 'clojure-mode)
(setq auto-mode-alist
(cons '("\\.clj$" . clojure-mode)
auto-mode-alist))

(add-hook 'clojure-mode-hook
'(lambda ()
(define-key clojure-mode-map "\C-c\C-e" 'lisp-eval-last-sexp)))
---

Also, this may be an obvious point, but make sure the clj executable is in your path and properly CHMODed.

# Posted By JMan on Monday, November 3 2008 at 2:36 PM

4.

Thanks Paul, works really well.

# Posted By Martin on Tuesday, November 25 2008 at 4:21 PM

5.

Thanks a lot for this!

Btw, if you are running os x 10.4 (and git is somewhat a hassle to setup in that env.) you can get the latest tar here:

http://clojure.codestuffs.com/

/R

# Posted By Joubin on Monday, December 8 2008 at 10:27 PM

6.

hi, so am trying to learn clojure and i've never used emacs before.
I followed the steps but i can get the REPL start in aquamacs.

When i open the helloworld.clj file i do see that aquamacs identifies the file as clojure file but C-c C-z does not launch the REPL.
Is there a step that i missed?

thanks a lot for the help

PS:
just to be sure i chmod clj to 777
clojure clojure-mode and jlime where installed in ~/src

# Posted By Adrien on Monday, February 1 2010 at 5:51 AM

7.

Having trouble running this in Snow Leopard. I can launch a repl, but trying to ctrl-x ctrl-e on this s-expr:
(range 0 10)

gives this error:

Debugger entered--Lisp error: (void-function range)

It doesn't seem that it's running through clojure, but through elisp.

# Posted By Adam on Monday, May 17 2010 at 5:23 AM

Comments Disabled