Protesilaos Stavrou (Prot) has another really excellent video up. This time it’s about organizing your Emacs configuration file. Prot looks at two possible approaches. The first is to use the built-in outline mode and appropriately marked comments to have an Org-mode-like presentation of your init.el
with section folding and easy search.
The second approach is probably the most common today. It’s to write your configuration file as a literate Org document and tangle the code into the file that Emacs loads at startup. There’s a lot to be said for this approach. You can completely annotate your configuration with what it’s doing and why it’s doing it in that particular way. That’s especially useful if you want to share your configuration. You can export it to HTML, PDF, or even something like Docx. It is, after all, just another Org document.
All of that is old news, of course, but the real benefit for me from Prot’s video is how you can start with a traditional init.el
and transform it into a literate Org document. The nice thing is that this can be done piecemeal so that you can convert it bit by bit over a period of time.
It’s pretty easy. First just put the whole init.el
into a single code block in the new Org file. You can add a title and perhaps some introductory comments. Finally add a property that tells Org where to tangle the file and you can generate your init.el
directly from the new Org file.
The key to breaking the Org document into sections is the org-babel-demarcate-block
command. This command splits the current block into two distinct blocks so that you can add headers and commentary between them. Take a look at Prot’s video to see the process in action.
If you’ve ever thought that you’d like to have a literate Emacs configuration file, Prot’s video is what you need. He shows you how to start with what you have and incrementally change it into a complete literate document.