Clojure/Slime on Arch (and maybe elsewhere)...

Tagged as Programming

Written on 2010-05-22 13:00:56

This is just a quick configuration post.  On Archlinux, clojure, clojure-contrib and swank-clojure-git packages are already available from the AUR. I'm a big fan of Common Lisp and use it for most of my programming, so I wanted to be able to use any of the 3 common lisp implementations installed from distro packages along with SBCL git built with clbuild or clojure without much fuss. Though there are a fair number of articles on clojure/emacs/slime setup and still more a google search away, I found it a bit of a pain to get things going the way I wanted.

I can't vouch for whether or not this will work for non-Arch users but if you have clojure and swank-clojure installed then aside from changing paths or setting environment variables this ought to work for you. (Let me know if I'm wrong, of course.)

I've got my lisp implementations defined as follows:
(setq slime-lisp-implementations
'((ccl ("ccl64"))
(ecl ("ecl"))
(sbcl ("sbcl"))
(sbcl-git ("/home/redline/builds/clbuild-dev/clbuild" "lisp"))))
(setq slime-default-lisp 'sbcl-git))

If that looks completely alien to you or you don't already have some additional code in your .emacs for SLIME setup, you're in the wrong place. You probably just want an easy Emacs starter kit for clojure. Or, alternately, to look at my full .emacs file.

And the following big chunk to get swank-clojure and the rest set up:
(add-to-list 'load-path "/usr/share/emacs/site-lisp/clojure-mode")
(require 'clojure-mode)
(add-to-list 'load-path "/usr/share/emacs/site-lisp/swank-clojure")
(require 'swank-clojure)
(add-hook 'clojure-mode-hook
'(lambda ()
(define-key clojure-mode-map "\C-c\C-e" 'lisp-eval-last-sexp)
(define-key clojure-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)))
(eval-after-load "slime"
`(progn
(require 'assoc)
(setq swank-clojure-classpath
(list "/usr/share/clojure/clojure.jar"
"/usr/share/clojure/clojure-contrib.jar"
"/usr/share/emacs/site-lisp/swank-clojure/src"))
(aput 'slime-lisp-implementations 'clojure
(list (swank-clojure-cmd) :init 'swank-clojure-init))))

At this point, you should be able to start Emacs and then do M- - M- x slime, followed by enter and either the word clojure or one of your lisp implementations. Alternately, you could just do M-x slime and get sbcl-git. See? Not so bad after all.
comments powered by Disqus

Unless otherwise credited all material Creative Commons License by Brit Butler