I spent some considerable time yesterday poring over the shelves in the programmer’s section of a local bookstore yesterday. Based on the available jobs at the moment, I was trying to decide whether it would be less painful to learn C#/.NET/AFW/blurpz or Hibernate/Springs/Struts/glorpka. My lambda, those things are fugly. When I open a book to find that my
simple database example takes eight XML configuration files and twenty-five lines of calls to the same function (with a 25-character identifier (which, technically, should be namespace qualified, too)), I just don’t want to go there.
So, I walked away with Programming Clojure and a determination to
think really hard about how to get paid to do something that’s not intensely painful.
Well, yesterday afternoon and late-night were intensely painful trying to get Clojure/Emacs/Slime all working together. Today, magickly, I messed something up in my .emacs file that convinced swank-clojure to download its own copies of the three JAR files it needs and zoom… I’m out of the gate.
Someday, I’d still like to be able to use my own JAR files for all of this, but in the meantime, I’m up and running.
Here’s what works
This is the relevant configuration from my .emacs file. It draws partly from these instructions by I’m not sure who, partly from this message by Constantine Vetoshev, partly from how my .emacs file was previously arranged, partly from sources now lost in the browser history sea, and partly from sheer luck.
First, some generic stuff up at the beginning:
(let ((default-directory (concat dir "/")))
(add-to-list 'load-path "~/.emacs.d/site-lisp")
Then, prepping slime a bit:
(add-to-list 'load-path "~/.emacs.d/site-lisp/slime/contrib")
(add-hook 'lisp-mode-hook (lambda () (slime-mode t)))
(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
(setq slime-net-coding-system 'utf-8-unix)
Then, setting up some general stuff for easy lisp implementations. (The –sbcl-nolineedit is something I personally use in my .sbclrc to decide whether to load linedit.)
'((sbcl ("sbcl" "--sbcl-nolineedit"))
Some commands to simplify things so I don’t have to remember to
M–– M-x slime:
`(defun ,name ()
(let ((slime-default-lisp ,mapping))
(defslime-start ccl 'ccl)
(defslime-start ccl64 'ccl64)
(defslime-start clojure 'clojure)
(defslime-start sbcl 'sbcl)
Then, Clojure-specific SLIME stuff
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
`((clojure ,(swank-clojure-cmd) :init swank-clojure-init))))
And, a touch more slime stuff to make things a little happier.
(setq slime-truncate-lines nil)
In my .emacs.d/site-lisp, I did the following:
% git clone git://git.boinkor.net/slime.git
% git clone http://github.com/technomancy/swank-clojure.git
% git clone http://github.com/jochu/clojure-mode.git
What didn’t work
Before accidentally triggering swank-clojure to download its own JARs, I tried installing what I could with ELPA. I tried installing clojure, clojure-contrib, and swank-clojure with Lein. I tried installing them with Maven. I tried various combinations of versions of clojure and swank-clojure.
I have no idea how the JARs that swank-clojure built itself got built. I cannot reproduce it.
Edit: Ah, it appears that the Subversion repository for Clojure that I found is deprecated. But, I don’t have the energy to try the git repository myself at this point. Maybe next week.