I’ve recently started learning Clojure, and so of course the first thing I did was set up emacs to properly be able to format and code in it. To do this, you should first download clojure-mode. Now, manually load the file, with M-x load-file, and then perform M-x clojure-install. This only needs to be done once. The clojure-install function will install all of the necessary dependencies, including slime integration for clojure. Once this is set, I have the following to configure clojure-mode:
(require 'clojure-mode) (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode)) (setq clojure-src-root "/home/nflath/.emacs.d") (setq swank-clojure-extra-classpaths '()) (clojure-slime-config)
This is admittedly a fairly minimal install. It requires clojure-mode to be installed and then sets clojure-mode to be used on all .clj files. You also have to specify the directory you specified with clojure-install as clojure-src-root. If you have any extra jar files or anything that you want Slime to know about, you need to add them to swank-clojure-extra-classpaths, and then clojure-slime-config will enable slime. Once this is done, M-x slime will load up Slime using clojure, acting as a Clojure repl. You can also send expressions in your .clj files to the repl to be evaluated with C-x C-e and all the usual emacs-lisp evaluation functions.
One note: learning the S-exp movement commands will help tremendously for editing clojure. I have only recently been using them, and they have sped up moving around the expressions by a huge amount. C-M-f is forward-sexp, which will take you to the next s-exp inside the current one, and C-M-b is backwards-sexp, which will do the opposite.