C-x C-c

M-x shell

C-x M-j     --- launch repl

July 2014

June 2012 - overview

Emacs-based clojure environment, tested on

This will walk through the simplest and best environment for clojure in emacs, as of [25 Mar 2012]. You don’t have to think about slime and swank - after installation it “just works”.


  1. lein:
  2. latest emacs:

                brew install emacs --cocoa                                #stable

                brew install emacs --cocoa --use-git-head --HEAD        #latest

  1. emacs plugins for clojure: emacs prelude

in .bashrc:

export TERM=xterm-256color

alias emacs='open -a /Applications/ $1'

export PATH=$PATH:~/.cabal/bin (for example)

in .bash_profile:

[[ -s ~/.bashrc ]] && source ~/.bashrc

in ~/.lein/profiles.clj: (


 {:plugins [[cider/cider-nrepl "0.8.0-SNAPSHOT"]]}}

(by convention, i put software that is not managed by a package manager in ~/opt, as opposed to using an installer or homebrew, which can go wherever it ends up. that way i can remove them by hand too.)

Everything below here is obselete and probably no longer relevant or correct

first project

  1. lein new helloworld
  2. cd helloworld
  3. lein deps
  4. emacs src/helloworld/core.clj
  5. `M-x clojure-jack-in`
  6. in core.clj, type in (+ 3 4), put the cursor after the last paren, C-x C-e to evaluate the expression, observe “7” in bottom left



i’m starting to use emacs in windowed mode, iterm eats certain keychords like C-M-f which is pretty important in paredit. `open -a emacs` was sufficient. i don’t think i’m going to make an alias to keep the distinction between terminal and cocoa emacs.

here’s whats going on under the hood

There are different ways people configure their emacs and clojure, some deprecated, many different ways to get working with various levels of success and complexity. This document will walk you through my way with no magic, from scratch. I don’t like magic because when it breaks i can’t fix it, and it requires putting complicated stuff in my .emacs that i don’t understand.

My preferred way:

other, less easy (imo) ways:

approaches i have not looked in to (due to less control and more magic)

I don’t recommend cloning one of many emacs configurations on github. They may not be using the best tools and they will have lots of other dependencies, custom keybindings, etc. However they are useful to look at if you get stuck. Here are two configurations from PHL Clojure Club members:


other definitions


get a working clojure repl

configure emacs to edit clojure source

emacs plugins are loaded via ~/.emacs or ~/.emacs.d/init.el. I don’t know the difference, I’m using init.el.

(add-to-list 'load-path "~/.emacs.d/")

(require 'clojure-mode)

(load "paredit.el")

(defun turn-on-paredit () (paredit-mode 1))

(add-hook 'clojure-mode-hook 'turn-on-paredit)

configure emacs to run and debug clojure

further work

configuration notes