Moved to clojure-doc.org:

(I wanted to edit the original page, but somehow I couldn't; I spent 10 minutes looking for an edit link or button and then I gave up; someone please integrate this with the rest.)

There are three main ways to work with Clojure from Emacs:

1. Inferior-mode : a simple mode that will start a VM as a subprocess and then
communicates with its repl via stdin/stdout pipes.

Functionality is minimal (you can send expressions to eval and do a little
bit more), but...

Due to its simplicity this is always working. Also, all output goes to a
single place (it's just like a REPL).

This is how the core developers work, because often support for the other
method of connecting lags behind a littlebit.

Advantages: simple; working with all versions of Clojure (including
the very bleeding edge).

Disadvantages: limited number of commands; simplistic output (results
of expressions is intermixed with stdout output); it's easy to kill
the REPL buffer by accident and that kills your VM subprocess.

Setup: you typically need to write a script that will start you
clojure VM, and configure Emacs to tell it where to run this script.

2. SLIME: a rich, complex mode that provides various commands to
communicate with an external VM via a socket. The VM is started
independently, and loaded with a package called swank-clojure,
which opens a server that listens on port 4005. This server
interprets an asynchronous protocol by SLIME ("emacs-rex") which
consists of simple s-expressions. swank-clojure implements many of
the commands in the emacs-rex protocol, and provides SLIME with
appropriate responses. SLIME is an Emacs package which provides
UI/workflow for various LISP targets, and it is able to connect to
the VM with a TCP socket (via its slime-connect command).

About 70% of SLIME functionality is implemented by Swank-Clojure.
Evaluating expressions, bringing up documentation, browsing
(a-propos) of symbols from packages, completion, list and killing
threads, etc. The "who calls" functions aren't there, and a few
others.

Swank-clojure sometimes breaks on newer versions, and can be
difficult to debug quickly if you're not familiar with its code.
On the other hand, it does get fixed eventually--people are using
it--and on relatively "recent" versions it works well.

Make sure you're using the versions above, which are usually in a
known working state. The minimal setup in Emacs for making this work
is:

Note: clojure-mode is independent of SLIME, and provides editing
functionality in Emacs only, has nothing to do with SLIME; you only
need it to make editing easier.

Note(2): you need the slime-repl add-on for Swank-Clojure to work
properly.

3. nREPL and others: a server for sending asynchronous eval requests
via a socket is being worked on (nREPL). The purpose of it is to have
other GUIs than Emacs share a common server connection method to a
running VM. It does not yet provide a common package of utilities that
you can invoke, its definition is limited to asynchronous evaluations.
A common library of backend tools is being worked on, and it is hoped
that correspond Emacs support will arise to take advantage of that
library, to replace SLIME with more Clojure-specific support.

I'm having trouble following these instructions. I have GNU Emacs 22.1.1 (i586-suse-linux-gnu). Whether I start with my normal .emacs_d or technomancy-emacs-starter-kit-4ba4630/init.el, loading package.el and/or package-maint.el gives me the error message "unknown keyword :risky", and presumably as a result, the command M-x package-list-packages does not get defined. I would upgrade to Emacs 24 if it had been released! Any suggestions welcome. Thanks.

I've spent quite a bit of time trying to get this setup. The nice folks on #clojure irc.freenode.net helped me out. A lot of blog posts are outdated. These details are for a slime/swank setup. I may not be 100% correct on my descriptions, so apologies for that in advance.

General overview:

emacs->slime <-> swank->swank-clojure->clojure

My understanding is that emacs talks to a swank server via the slime library. Swank can communicate to a number of lisps via a back end, one of which is clojure via the swank-clojure backend.

You should install the package manager as described at the top of this page. I used the emacs-starter-kit so all I needed to do was run (in emacs):

M-x package-install, scroll down to clojure-mode and then press i (for install) then x (to execute). y (yes) I want to install clojure-mode.

I installed leiningen (links are further up on the page as to how to do this). I personally used Homebrew since I'm on OSX (via terminal): brew install leiningen

Then, as of the time of writing (via terminal):lein plugin install swank-clojure 1.3.2

Create a new project (via terminal):lein new <projectname>

Open a file in the lein created clojure project in emacs and M-x clojure-jack-in

Switch to the swank buffer. If you get an error as I did about not being able to find lein, add this to your dotemacs:(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
where /usr/local/bin is the path to lein. Because you're appending the path to lein to the start of the existing PATH, you will still need to include the colon. Restart emacs and repeat the jack-in process.

clojure-jack-in is defined in clojure-mode. This tells lein to start the swank server using swank-clojure, and grabs a known working copy of SLIME from the swank-clojure jar file that's downloaded when you install swank-clojure as a lein plugin. Meanwhile, lein walks the filesystem from the current working directory looking for the project.clj and will setup the correct class paths. Clojure-mode then loads the copy of SLIME it received from the swank jar into emacs and uses it to connect to the now running swank server.

The general process of the instructions at the top of this page are correct. A further outline can be found on the swank-clojure github readme, linked earlier on in this page. Hopefully this comment will shed a little more light on some of the magic that happens.

Thanks for the effort and the instructions given above. As a new entrant into clojure and to some extent to Emacs, I struggled a bit to install and get them working and had to refer many resources in web.

To help people like me starting out in "Emacs + Clojure + Swank + Leiningen", I am putting together detailed set of instructions building on top of what is in the page above:

1.2.1 Either of them alone did not work for me. I created both. BEWARE: Don’t waste time looking for these files if yours is a fresh installation. Both these files need to be created manually afresh.

In init.el add:

(require 'package)

(add-to-list 'package-archives

'("marmalade" . "http://marmalade-repo.org/packages/") t)

(package-initialize)

In .emacs file add the contents given in top of the page.

1.3 Next run ‘M-x: "package-refresh-contents"’. (M is Alt key in windows). Again, first time this needs to be manually installed. Emacs tab completion did not show the command for me. Just type and press enter.

For now I have given up with emacs. I went over the no match issue, but had some other kind of error.

This has been a VERY LONG adventure in frustration atter frustration for an older user of Visual Lisp an Visual Basic. I have hack some code here and there and know that clojure can do exactly what I want. In my case the clojure code is not a problem but it is becoming mission impossible to find an IDE that you can install, code and compile without having to install and configure a bounch of other things like lein, swank, slime etc ... etc...

I'll keep on trying until the come out with the clojure install for windows with all the goodies inside.

Can we get this information clearly flagged at the top of the page, please? It's not clear from anywhere in the text of this page (or, in fact, anywhere else that I can see) that tromey.com/elpa is deprecated. I wasted a couple of hours last night in part because of this.

There's a further source of confusion in that if you're on emacs23, you need to grab a specific version of package.el - from http://github.com/technomancy/package.el. If you follow the clojure-mode link in the body of this page, the README you end up at has apparently the right link, but it's directly to a blob in a git repo, so it's not abundantly clear that it's a link that's maintained to point at the correct version.

It also seems that if you're going to use package.el, you must use the Marmalade repository.