info@beaconhill.com | 914-834-2820

Setting up Clojure with Slime on Ubuntu

Prerequisites

Emacs and Slime are installed. If you have Slime installed aready via the Package Manager read the following else skip over the next section.

Slime

Originally, when I started to setup Clojure with Slime I has already installed Slime through the Package Manager. This worked fine with sbcl but it doesn't with clojure. It seems that a newer version is available that works fine. So, if you have the same setup uninstall the Slime installed through the Package manager and restart Emacs. Then install Slime with the following.

$ cd /opt
    $ git clone git://git.boinkor.net/slime.git

clojure-mode

The emacs mode to handle clojure files

$ cd /opt
    $ git clone git://github.com/jochu/clojure-mode.git

swank-clojure

swank-clojure is the server-side backend of slime.

$ cd /opt
    $ git clone git://github.com/jochu/swank-clojure.git

Configure Emacs

;; clojure-mode
    (add-to-list 'load-path "/opt/clojure-mode")
    (require 'clojure-mode)

    ;; swank-clojure
    (add-to-list 'load-path "/opt/swank-clojure/src/emacs")

    (setq swank-clojure-jar-path "/opt/clojure/clojure.jar"
    swank-clojure-extra-classpaths (list
    "/opt/swank-clojure/src/main/clojure"
    "/opt/clojure-contrib/clojure-contrib.jar"))

    (require 'swank-clojure-autoload)

    ;; slime
    (eval-after-load "slime"
    '(progn (slime-setup '(slime-repl))))
    (add-to-list 'load-path "/opt/slime")
    (require 'slime)
    (slime-setup)