(defun slime-project (path)
  "Setup classpaths for a clojure project and starts a new SLIME session.

Kills existing SLIME session, if any."
  (interactive (list
                (ido-read-directory-name
                 "Project root: "
                 (locate-dominating-file default-directory "pom.xml"))))
  (when (get-buffer "*inferior-lisp*")
    (kill-buffer "*inferior-lisp*"))
  (setq swank-clojure-binary nil
        swank-clojure-jar-path (expand-file-name "target/dependency/" path)
        swank-clojure-extra-classpaths
        (mapcar (lambda (d) (expand-file-name d path))
                '("src/" "target/classes/" "test/"))
        swank-clojure-extra-vm-args
        (list (format "-Dclojure.compile.path=%s"
                      (expand-file-name "target/classes/" path)))
        slime-lisp-implementations
        (cons `(clojure ,(swank-clojure-cmd) :init swank-clojure-init)
              (remove-if #'(lambda (x) (eq (car x) 'clojure))
                         slime-lisp-implementations)))
  (save-window-excursion
    (slime)))

Generated by Phil Hagelberg using scpaste at Fri May 8 15:32:40 2009. PDT. (original)