Clicky

Harry R. Schwartz

Software engineer, nominal scientist, gentleman of the internet. Member, ←Hotline Webring→.

· 1B41 8F2C 23DE DD9C 807E A74F 841B 3DAE 25AE 721B

Switching to a Literate Emacs Configuration

Published 15 Feb 2016. Tags: emacs.

Emacs’ org-mode has a number of nifty features. Among them is the ability to sequentially evaluate all the code blocks in an org document with org-babel-load-file.

This makes literate programming extremely easy. Just write a document, intersperse some code blocks, and evaluate. Literate programming has numerous applications: it’s a handy tool for reproducible research, for example.

A number of folks in the Emacs community structure their configuration files as literate programs in org-mode. I’ve been thinking about that for a while, and I finally gave it a shot last weekend. I got some pretty nice results!

How to do it:

If you’re interested in rewriting your own configuration as a literate org program, it’s simple:

#+BEGIN_SRC emacs-lisp
  (all-your-config-stuff ...)
#+END_SRC
(org-babel-load-file "~/.emacs.d/configuration.org")

That’s the first thing Emacs’ll run; it’ll read through that configuration.org file and evaluate that code block.

Enjoy!