Running Programming Clojure Examples on Clojure Box

Stuart Halloway’s Programming Clojure book is the only game in town for learning Clojure (at least until Luke VanderHart’s Practical Clojure is released), and Clojure Box is the easiest way to get Clojure running on Windows with a good IDE, if you don’t already have cygwin installed, but they don’t quite play nicely out of the box.

Craig McDaniel has some generally useful code for Emacs/Clojure, and that’s almost enough to get things working. With the following changes incorporated, all of the examples work for me:

(defun reset-swank ()
  "Because changing swank-clojure-extra-classpaths is not enough to force a new instance of slime to use it."
  (interactive)
  (setq slime-lisp-implementations
        (assq-delete-all 'clojure slime-lisp-implementations))
  (add-to-list 'slime-lisp-implementations
               `(clojure ,(swank-clojure-cmd) :init swank-clojure-init) t))
 
(defun run-slime (dir)
  (interactive "Project directory: ")
  (cd dir)
  (when (file-directory-p "~/.clojure") (directory-files "~/.clojure" t ".jar$")) 
    (make-directory "classes"))
  (setq swank-clojure-extra-classpaths '("src" "classes" "lib/*" ""))
  (reset-swank)
  (slime))
Running Programming Clojure Examples on Clojure Box