CIDER is a popular Clojure
programming environment for Emacs.
In a nutshell - CIDER extends Emacs with support for interactive
programming in Clojure. The features are centered around
an Emacs minor-mode that complements
supports editing Clojure source files,
cider-mode adds support for
interacting with a running Clojure process for compilation, debugging,
definition and documentation lookup, running tests and so on.
You can safely think of CIDER as SLIME (a legendary Common Lisp programming
environment) for Clojure - after all SLIME was the principle
inspiration for CIDER to begin with. If you’re interested in some
historical background you can check out my talk on the subject The
Evolution of the Emacs tooling for
Many people who are new to Lisps (and Emacs) really struggle with the concept of
“interactive programming” and are often asking what’s the easiest (and
fastest) way to “grok” (understand) it.
While CIDER has an extensive manual and a section
on interactive programming there,
it seems for most people that’s not enough to get a clear understanding
of interactive programming fundamentals and appreciate its advantages.
I always felt what CIDER needed were more video tutorials on the
subject, but for one reason or another I never found the time to
produce any. In the past this amazing intro to
SLIME really changed my
perception of SLIME and got me from 0 to 80 in like one hour. I wanted
to do the same for CIDER users! And I accidentally did this in a way
last year - at a FP conference I was attending to present CIDER, one
of the speakers dropped out, and I was invited to fill in for them
with a hands-on session on CIDER. It was officially named Deep Dive
into CIDER, but probably
“Intro to CIDER” would have been a more appropriate name, and it’s
likely the best video introduction to CIDER around today. It’s
certainly not my finest piece of work, and I definitely have to
revisit the idea for proper high-quality tutorials in the future, but
it’s better than nothing. I hope at least some of you would find it useful!
You might also find some of the additional CIDER
mentioned in the manual helpful.
In Emacs you can evaluate Emacs Lisp pretty much anywhere - even
in the minibuffer. Writing
Emacs Lisp in the minibuffer, however, is not exactly fantastic
experience out-of-the-box - there’s
TAB completion, but what about
paredit for instance?
If only there was a way to enable them… I suggested one trick in my
original post on
eval-expression, but Emacs 24.4 made things even
easier by adding
eval-expression-minibuffer-setup-hook. To enable
eldoc for minibuffer evaluations use this snippet:
(add-hook 'eval-expression-minibuffer-setup-hook #'eldoc-mode)
paredit you can use this one:
(add-hook 'eval-expression-minibuffer-setup-hook #'paredit-mode)
Obviously you can do the same for any other minor mode you might need.
The best thing about this setup is that it will work with tools like
SLIME as well (they have similar
commands which allow you to evaluate Clojure & Common Lisp code and
those command trigger
If you know the name of some command, but you’ve forgotten its
keybinding(s) there are 3 common options to look the keybinding(s) up.
This will display some information about the command in question in a help buffer.
Important bits of this information include where is the command defined, what are its
keybindingings if any, and its documentation.
This will display the keybindings of the command in the minibuffer. If you’re interested only
in the keybindings you should prefer this option over
After you invoke some command using
M-x you’ll see a suggestion to use
its keybinding instead in the minibuffer.
That’s all for now, folks!
By default Emacs has some pretty annoying audio notifications for
certain events (e.g. trying to move past the end of a buffer). You’ve
got two options to get rid of them. Option 1 is to replace them with visual
notifications (the Emacs frame will flash):
This doesn’t work well on OS X and is just as annoying (if not even
more), so I’d suggest going with option 2 instead - disable those
(setq ring-bell-function 'ignore)
At last - some peace and quiet!
One of the things I hate the most while programming, is having to
manually adjust the indentation of some code, after I’ve moved or
renamed something in it. While it’s pretty easy to do such re-indent
operations using commands like
crux-with-region-or-buffer (you remember,
crux, right?), there’s an even more
efficient way to tackle the issue at hand. Enter
aggressive-indent-mode’s name is a bit of a misnomer - it should
probably have been named
auto-indent-mode, as this is what it
does. When you edit your code it will adjust the indentation
automatically. It’s easier to show this than to explain it.
Here’s one example showing
agressive-indent-mode enabled in
And another example using
Provided you’ve installed the mode, enabling it for particular major modes is a piece of cake:
(add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
(add-hook 'clojure-mode-hook #'aggressive-indent-mode)
(add-hook 'ruby-mode-hook #'aggressive-indent-mode)
If you want to enable it in all major modes you can do this as well:
Note that this is not going to work well with modes like
haml-mode where the proper indentation can’t be reliably
global-aggressive-indent-mode is enabled it will
not affect major modes listed in
For more info - head over to the