Open or create a Clojure .clj file, and you should find that clojure-mode enabled since built-in functions and forms are syntax-highlighted.
There are multiple approaches for interacting with a live Clojure process:
- SLIME and Swank Clojure: a rich, complex mode that provides various commands to communicate with an external Clojure instance via a socket.
- inferior-lisp: a simple mode that will start a Clojure instance as a subprocess and then communicates with its REPL via stdin/stdout pipes.
In both cases, you need to launch a Clojure subprocess. This is most commonly done using a tool such as Leiningen.
SLIME and Swank Clojure
M-x clojure-jack-in once Leiningen is installed to begin a Slime session for the current project.
The most commonly-used key bindings are
C-c C-k to compile the current file,
M-. to jump to a definition, and
C-c M-p to change the namespace of the repl session.
For more key bindings and other details see the swank-clojure readme.
The simplest way to interact with Clojure is to launch a subprocess by invoking M-x run-lisp (C-c C-z) from a clojure buffer.
Use C-x C-e at the end of an expression to evaluate it, showing the result in the inferior-lisp buffer. C-c C-l will load the current file. C-M-x can evaluate a whole def form.
If you don't use Leiningen you'll need to customize the command that launches a Clojure REPL. You can use an absolute path, or a relative path that will be interpreted relative to the current directory in emacs. M-x describe-variable inferior-lisp-program with one of the following:
java -cp path/to/clojure.jar clojure.mainfor a basic repl (no rlwrap/jline needed)
lein replfor a Leiningen project
cake replfor a Cake project
mvn clojure:replfor a Maven project
script/replfor the labrepl tutorial project
Automated VM Setup
If you don't mind working in a virtual machine, you can get a fully-automated VM set up with Emacs configured using Slime and Swank-Clojure using Vagrant: https://github.com/Seajure/emacs-clojure-vagrant