My personal .emacs.d

Daniel 5a4cbd6a27 Changed <up> & <down> to ▲ & ▼ 5 years ago
etc b2c9050f49 Add Accidental aRt feed. 5 years ago
snippets a252573d57 Remove the last submodule and just copy in the snippets. 6 years ago
.gitignore 689c0a658f Ignore .cask directory. 5 years ago 5a4cbd6a27 Changed <up> & <down> to ▲ & ▼ 5 years ago
UNLICENSE beed37e378 Add the UNLICENSE. 6 years ago
extras.el 8f3c5ee413 Oops, don't add binding until help-mode loads. 5 years ago
init.el 174d921757 Highlight gv-define-setter. 5 years ago
utility.el 3a8860625c Move expose into utility.el. 6 years ago

My Personal Emacs Configuration

This is my personal Emacs configuration. This is the second repository I clone -- after my dotfiles -- when settling in on a new computer . I'm using package.el and Emacs 24 themes, so this requires at least Emacs 24.3!

To use it, clone it into your home directory, or at least wherever Emacs thinks your home directory is. Move your existing .emacs file out of the way, since it being there prevents Emacs from using the init.el in this repository. I do still use a .emacs file for system-specific configuration, but I put this at the top,

(load-file "~/.emacs.d/init.el")

If you did everything right Emacs should simply launch with no errors. You will be greeted with a featureless, empty gray box awaiting your instructions.


I try to keep my Emacs configuration tight and tidy. I generally spend somewhere between 30-60 hours a week in front of Emacs, so this configuration has been carefully pieced together and every line is important.

The Little Things

Here's a list of some small features added by init.el or extras.el.

  • M-▲ -- Move the current line up.
  • M-▼ -- Move the current line down.
  • C-x ! -- Insert a UUID.
  • C-x ~ -- Set the current buffer to 80 columns.
  • C-c r -- Insert random number.
  • C-c e -- Eval and replace.
  • M-g -- Go to line.
  • C-x C-k -- Compile.
  • [f1] -- Start a terminal.
  • [f2] -- Revert the buffer, no questions asked.
  • [pause] -- Dedicate the current window to the current buffer.

And some of the more interesting functions/macros, especially if you're an Elisp developer,

  • unfill-paragraph
  • dos2unix and unix2dos
  • expose
  • measure-time
  • compile-bind*

That last one is used to create bindings to run make: C-x c runs make with the compile target and C-x C runs make with the clean target.


There's a customized hook for whitespace-cleanup in before-save-hook. It will remove all trailing whitespace, and, because I'm so picky, also convert all tabs to spaces just before saving a buffer. To disable this on a per-buffer basis -- for example, to precisely edit a sloppily-spaced file -- run toggle-whitespace-cleanup.

See whitespace-cleanup.el for all the details.


Something experienced Emacs users may notice at first is that I make heavy use of ido-mode. It's turned on with flex matching, I've got smex loaded to complete M-x commands, and I use it for picking Java documentation. It's a wonderful feature and every Emacs user should be using it.


To interact with Git repositories, I use Magit (pronounced like "magic"). You can run it at any time with C-x g. As the manual points out, Magit is not a complete interface for Git, nor should it be. It covers 95% of my Git use, with the other 5% directly with Git on the command line. Magit is one of the main reasons I use Git.

Web Server

This configuration includes a built-in web server, written by me. You can launch it with httpd-start and stop it with httpd-stop. It will serve files from the directory at httpd-root and log messages in s-expression form to the *httpd* buffer.


The most important use of the web server is for skewer-mode. I run its associated userscript in my browser allowing me to, at any time on any page, attach Emacs to a webpage. Once attached to Emacs I can fully interact with the browser's JavaScript runtime through a JavaScript REPL (skewer-repl) and live expression evaluation in JavaScript buffers, very similar to the various lisp interaction modes. It can also do live "evaluation" of CSS (skewer-css-mode) and HTML (skewer-html-mode).

Lisp: Paredit and Parenface

Paredit is a very significant behavioral change for Lisp modes. It enforces parenthesis balance and provides all sorts of shortcuts for manipulating entire s-expressions at once. It may feel annoying at first, but it quickly becomes indispensable. Keep looking at the cheatsheet until you've got the hang of it.

I also have parenface configured, which darkens the parenthesis in Lisp modes. It makes Lisp code all the more pleasing to look at -- reading Lisp is all about indentation, not parenthesis. It won't be enabled in the *scratch* buffer automatically because that buffer gets set up before parenface does.

You may wonder why I don't have Slime here. That's because I let Quicklisp install and manage it for me. Remember my note about using .emacs for system-specific configuration? That's where I put the hook to load Slime.


I interact with Clojure projects using nrepl.el and nREPL. This can be fired up at any time with nrepl-jack-in. This requires Leiningen, which is very easy to set up.


This was one of the big ones when I used spend a lot of time writing Java, and Emacs was lacking solid Java support. I built up my own extensions to support Java development: ant-project-mode and javadoc-lookup. The full documentation is listed in the ant-project-mode.el header, but here's a quick rundown of my configuration.

First, I use javadoc-lookup for class completion and lookup, which works by examining the file structure of Javadoc documentation. While it comes with the core API Javadoc built-in, to make more effective use of it I need to tell it about what other things I'll want to look up. Its configuration looks like this,

(javadoc-add-artifacts [org.lwjgl.lwjgl lwjgl "2.8.2"]
                       [com.nullprogram native-guide "0.2"]
                       [joda-time joda-time "2.1"])

I can jump to any class's documentation with C-h j. I use Firefox, so this will try to open the documentation in Firefox if possible.

Notice: ant-project-mode is not currently part of this configuration, so the following will not work at the moment.

Next, when in a java-mode buffer, I can add an import to the imports section at any time with C-x I (the ant-project-short-keybindings binding). Like javadoc-lookup, C-h j, Ido will do a completing read asking you which class I'd like to import. It's inserted in the proper position inside the imports section.

When using Ant like I do, there are a number of bindings that trigger specific Ant targets. The three I use most often are,

  • C-x c -- Compile the program.
  • C-x r -- Run the program.
  • C-x t -- Run the unit tests.

The compilation buffer name is derived from the prefix argument. Using prefixes (C-u number), you can run any number of compilation processes at once. I find this especially useful for hot code replacement.

The YASnippets in emacs-java/snippets/ take advantage of my java-mode extensions. My favorite snippet is cls ("class"): start a fresh Java source file inside a package, type cls, and hit tab. It will attempt to guess the package name from your path and fill out the basics with it, allowing you to quickly get on with your business.