Setup Clojure with SLIME under Emacs


Updated:

Swank Clojure is deprecated in favour of nrepl.el

nrepl.el on Github


Clojure Side

Emcas Side

  • Emcas (normally with SLIME installed)
  • clojure-mode

Basically what you need is leiningen on Clojure side and clojure-mode on Emacs side.

Setup lein

Install lein according to the instructions on its index. For lein 2.0 add such line into your global user profile .lein/profiles.clj.

{:user {:plugins [[lein-swank "1.4.4"]]}}

If you still use lein 1.x, you need such steps.

  • run lein plugin install lein-swank 1.4.4
  • add :dev-dependencies [[lein-swank "1.4.4"]] to your project.clj

Setup clojure-mode

Download clojure-mode.el, place it under your emacs load path, add such line to your .emacs file.

1
(require 'clojure-mode)

You may install paredit and rainbow-delimiters to enhance experience for writting Clojure code with Emacs.

Start up SLIME with Clojure

Now

M-x clojure-jack-in

Warn: conflit with inferior-lisp-program

Sometimes you work under Emacs with Common Lisp before, you may see Emacs pop up with a window of error message when run the command above. That's might be caused by the previous compiled swank version for common lisp.

Comment out your setup for Common Lisp in your .emacs like below and try again:

(setq inferior-lisp-program "sbcl --noinform")