Emacs Demystified

There’s a discussion on the Clojure mailing list about which development environment is most suitable for beginners who want to get started with Clojure.

If you’re already an expert IDE user for other work, such as Java development, it makes sense to try Clojure out in environment you’re used to. However, what should a beginner do if they aren’t already familiar with an IDE? If this is you, my strong advice is that you learn Emacs.

Emacs optimises the tail

Most tools try to optimise the first few hours of use by giving access to all the features via menu-bars and icons. These certainly make learning the tool easier. In fact, the Windows operating system seems to me to be designed to optimise a person’s first experience with a computer.

However, once you are familiar with how to use a tool most users find that using keyboard shortcuts makes them more productive, just as many computer users discover that they get more done with a command line. Duplicating access to a feature via a menu and/or an icon only adds to the visual clutter which, detracting from the overall experience. And when you’re trying to focus on creating content, visual noise can be a distraction.

Emacs is different. In Emacs, the keyboard shortcut is the primary way of accessing a feature. Many features aren’t even available via the menu and toolbar. For the sake of reducing visual clutter to a minimum I recommend you toggle off even the basic menu and toolbar that Emacs
displays when you first start it (see below for how).

So rather than optimise the first few hours of use, Emacs makes the subsequent years as productive as possible.

Once you’re familiar with a tool it’s easy to forget how you felt when you started out. I remember being a little overwhelmed the first time I tried IntelliJ, I couldn’t work out how to view 2 files side by side. I also remember finding Eclipse overwhelming, I was confused by its views and perspectives.


Learning any complex tool like an IDE or Emacs is not a trivial undertaking. But scrambling up the initial learning curve with Emacs is really not all that hard. Here’s how :-

Get Emacs.

Get a recent copy, version 24 or above. If you’re on a Mac, avoid Aquamacs for the time being.

Start Emacs.

Read the text in front of you. Start the tutorial. Run through the tutorial, have a break, come back and do it again. This is really important. Don’t try to do anything complex (like configure a Clojure environment) until you’re comfortable with the basics. Don’t try to learn everything in one go. Emacs has a long learning curve but it doesn’t have to be steep. Nobody knows all of Emacs and you don’t have to know much of it to start with. Gradually you will pick up new tips and tricks from other Emacs users and your own curiosity.

Minimise the visual clutter.

The tutorial will have taught you what M-x means.

 M-x cust-var<RET>
 Customize variable: menu-bar-mode
 (click Toggle, then State - 'Save for Future Sessions')

 M-x cust-var<RET>
 Customize variable: tool-bar-mode
 (click Toggle, then State - 'Save for Future Sessions')

 M-x cust-var<RET>
 Customize variable: scroll-bar-mode
 (click Toggle, then State - 'Save for Future Sessions')

Kill the caps

Rebind your useless CAPS-LOCK key to a Control key. On a Mac, you can
do that by going to Sytsem Preferences/Keyboard/Modifiers. GNOME and KDE
users can also do this via settings. For raw X Windows, I find it’s best
to add the following to your X conf :

Section "InputClass"
    Identifier  "Keyboard Defaults"
    MatchIsKeyboard "yes"
    Option  "XkbOptions" "ctrl:nocaps"

Customize your Clojure environment.

There are plenty of tutorials on this. Find a recent one and follow it. Most advice is to use
nRepl. Personally I find nRepl to be still lacking in certain useful features so I run the original swank instead. In my lein user profile I add the swank plugin.


{:user {:plugins [
                  [lein-swank "1.4.4"]

Then I run up an Emacs shell

M-x eshell

Then I run the swank listener via lein to start my JVM with my project’s classpath

$ cd ~/src/myproject
$ lein swank

Then I connect to localhost and port 4005 (ie. the defaults).

M-x slime-connect

Then I locate a Clojure file and compile it with C-c C-k.

Install and learn paredit.

Many people recommend using an Emacs ‘starter kit’ which provide various bells and whistles intended for certain user groups (eg. Clojure developers). You’ll find many examples on github. My advice is to avoid these until you are more comfortable with the default Emacs environment. Personally I don’t use a starter kit and find that Emacs 24 has ironed out plenty of the wrinkles that these starter kits were created to address.

IDE strengths are not tuned to Clojure development

For Java developers there are a number of features that tip the balance
firmly in favour of using an IDE :-

  1. Java, being both statically types and verbose lends itself to
    code-completion facilities in the editor.

  2. Improving the design of object oriented code demands heavy
    refactoring, where a good IDE can greatly help.

  3. Java’s requirements on file organisation (one file per public class)
    means that large project can run into thousands of individual files,
    which are more easily accessed using tree controls characteristic of

All these benefits are significantly less useful for Clojure
development, so the balance tips in back in favour of Emacs which excels
at text editing. As an expert user in multiple IDEs and Emacs I can
attest that the text editing in IDEs feels awkward and even cumbersome
by Emacs standards.

A sound investment

Commiting the time to learn Emacs is a very sound investment. I’ve been using Emacs myself since 1991. The initial learning curve was a few days, which is a tiny fraction of that 20 years. Many tools have come and gone since 1991, including Windows 3.1, Lotus Notes, Visual Age for Java. Emacs predates all these and it’s very much the same tool now (at version 24) as it was then (at version 18). I fully expect to be using Emacs for another 20 years.

That would be a big payback if I only used Emacs for development. But I can use Emacs for lots of other tasks. Right now I’m writing this blog in Emacs using a mode specially designed for creating Markdown formatted articles (which this is one). The same keybindings apply and much of the feature set is just as relevant as when I’m developing :-

  • slick navigation
  • text manipulation
  • bookmarks
  • git integration
  • kill-rings
  • macros
  • narrowing to region
  • grep-find

I don’t have to work hard to remember all the keybindings associated with these features, they are burnt into my muscle memory. If you haven’t yet learned to properly touch-type, I also recommend you add that to your ‘to-do’ list. Emacs is kind to touch-typists. Like vi, Emacs allows you to navigate without moving your hands over to the arrow keys and back.

6 thoughts on “Emacs Demystified

  1. The fine people over at http://clojure-doc.org are working on great tutorials for beginners. I have even contributed with my own small section for installing Emacs, at http://clojure-doc.org/articles/tutorials/emacs.html

    About swank: Phil Hagelberg, the Clojure developer behind Leiningen, suggests replacing swank with nrepl. http://technomancy.us/163 Specially in Leiningen 2.0, it seems the default is now nrepl instead of swank. Have you given that a try ? What are your thoughts ?

  2. Emacs is so cool it works even for die-hard Vim fanatics like me, just had to install the Evil plugin :)
    And no IDE will be as powerful as a text editor with embedded Lisp scripting

  3. Learning to touch type is IMHO more important than learning a specific editor.

    Emacs may well be around well beyond the current crop of IDEs but I hit tl;dr state of consciousness and gave up once I realised I’d have to compile it to install on the Windows OS I’m forced to use at work (I don’t have VC or gcc). I suppose I could’ve tried in one of the Linux VMs I use for various purposes but it just doesn’t seem worth it for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>