Getting Started with Emacs

History Key

  • New content
  • Removed content

Recent Versions

Choose two versions to compare, or click the link to view it.

  1. 13. about 1 year by stuart.halloway
  2. 12. over 1 year by technomancy
  3. 11. almost 2 years by justin.balthrop
  4. 10. almost 2 years by technomancy
  5. 9. about 2 years by technomancy
  6. 8. about 2 years by technomancy
  7. 7. about 2 years by stuartsierra
  8. 6. about 2 years by stuartsierra
  9. 5. about 2 years by technomancy
  10. 4. about 2 years by technomancy
  11. 3. about 2 years by technomancy
  12. 2. about 2 years by stuart.halloway
  13. 1. about 2 years by stuart.halloway
 

IfThe youClojure areGetting newStarted pages have moved to Emacs, you may find the Emacs Starter Kit helpful.

If you already have your own Emacs configuration, you will need to get package.el in order to install the necessary elisp libraries. If you are using Emacs 24 you will already have it installed, but you'll need to add ELPA as a package source: (add-to-list 'package-archives '("elpa" . "http://tromey.com/elpa/"))

  • Run the command M-x package-list-packages.
  • Select clojure-mode (press i), and then install the selected package (press x).

Open or create a Clojure .clj file, and you should find that clojure-mode enabled since built-in functions and forms are syntax-highlighted. The simplest way to eval expressions at a Clojure REPL is to set Clojure to be your inferior-lisp program (inferior as in a subprocess, not as in worse-than) as follows:

  • M-x describe-variable inferior-lisp-program
  • Customize the variable to point to a 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. For example:
    • java -cp path/to/clojure.jar clojure.main for a basic repl (no rlwrap/jline needed)
    • lein repl for a leiningen project
    • cake repl for a cake (or lein) project
    • mvn clojure:repl for a maven project
    • script/repl for the labrepl tutorial project.
  • M-x inferior-lisp (or C-c C-z)
  • 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.

There is also swank-clojure, which provides a richer level of interaction using SLIME. Go back to the packages list with M-x package-list-packages and choose slime-repl. This will install all the elisp code needed. There will be some compilation failures; these are normal and do not affect the installation process.

Use your project's build tool to launch a swank server (for example, by using lein swank or cake swank) and then connect using M-x slime-connect. For more details see the swank-clojure readme or the cake swank wikihttp://dev.clojure.org.