I started a Doom Emacs config in April with a handful of modules switched on. It's now a bit under 4,000 lines of Emacs Lisp spread over a dozen files, and it handles my notes, my tasks, my mail, my bank transactions and this blog.

I didn't plan any of that. Each piece was added because something had annoyed me for the third or fourth time. Below is what's in there, including the parts that went wrong. I think the real config says more about Emacs than a list of its features would.

The starting point

I use Doom with (evil +everywhere), so the editing keys are Vim's. My leader key is ;, the same as in my Neovim config, and both editors show relative line numbers and leave insert mode on C-c. I move between the two all day and I don't want to think about which one I'm in.

The module list in init.el is short. Completion is corfu and vertico. For languages I have C# through eglot and csharp-ls, plus Emacs Lisp, Markdown, shell and ledger. Then there's Magit, Org with org-roam, and mu4e for mail. I add four packages on top of what Doom ships:

(unpin! org-roam)
(package! org-roam-ui)
(package! ox-gfm)
(package! magit-delta)

The first version had even less. There was no LSP, no mail and no ledger. Those arrived months later, one at a time.

Everything is a function, including the bugs

People say that everything in Emacs is a Lisp function you can read and change. That's true, and I learned what it's worth from a bug I caused myself.

My notes used to live in iCloud, behind a chain of symlinks ending at ~/org. My config had a small loop that created the Org directories if they were missing. Every so often I'd start Emacs and all my notes would be gone. In their place was an empty folder.

It took a while to see what was happening. If iCloud hadn't finished mounting when Doom started, the symlink pointed at nothing for a moment. file-directory-p returns nil for a dangling symlink, so my loop decided the directory didn't exist and helpfully created a real, empty one on top of the link. The notes themselves were safe in iCloud. Emacs just couldn't see them any more.

The fix was one extra condition:

(dolist (dir (list org-directory +my/org-roam-directory +my/org-export-directory))
  (unless (or (file-directory-p dir) (file-symlink-p dir))
    (make-directory dir t)))

I've since moved the notes to Nextcloud and the symlinks are gone, but I left the guard in. What I like about this story is how ordinary the debugging was. I didn't have to guess at what a closed program was doing. I read my own five lines, looked up one function with C-h f, and the answer was in its docstring.

Org is where I spend the time

About a quarter of the config, a little over a thousand lines, is Org setup. Most of it is capture templates and one agenda view.

Capture is a single key that drops a task or a note into an inbox file without taking me away from what I was doing. I have templates for plain tasks, events, contacts, habits and a weekly review, and a set for the maths I'm studying: a session log, a mistake log, and one that schedules its own follow-up reviews on days 1, 3, 7 and 14.

The agenda view is a daily dashboard. The hard part of designing one is keeping the same task from showing up in three sections, because a list that repeats itself stops getting read. The rule I settled on is written at the top of the code:

;;; How a task reaches the daily dashboard.
;;
;; Through exactly one door, so nothing is listed twice:
;;
;;   - A date wins. Anything scheduled shows under TODAY on its day, whatever
;;     its state, and under DEADLINES once its deadline is a week off.
;;   - NEXT ACTIONS is the undated rest: NEXT tasks to pick from once today's
;;     list is done. A NEXT with a date is left out, which is why a NEXT can
;;     sit under TODAY and not here.
;;   - STUCK catches what neither door can: an open project with no task that
;;     is NEXT, WAITING or dated would otherwise show nowhere.

I write comments like that all through the config. Six months from now I won't remember why a NEXT task with a date is missing from the NEXT list, and the comment will save me from "fixing" it.

A registry for the things I forget I built

The usual advice is to automate something only once it has annoyed you a few times. I agree with it, but I found it's incomplete. The harder problem came after the automating.

I built a whole setup for studying maths. It had capture templates, a dashboard and a review cycle. Then I didn't open it for two months. Nothing was broken. I had simply forgotten it existed, because a keybinding only helps if you remember there's something to press.

So now every workflow in my config registers itself:

(+my/system! 'finance
  :name "Finance" :key "o $ d" :every 7
  :desc "Bank transactions synced into hledger, with a monthly budget dashboard. Sync, then categorize what is new."
  :action #'+my/finance-open-dashboard
  :commands '(+my/finance-open-dashboard +my/finance-sync
              +my/finance-review-uncategorized +my/finance-categorize-transaction)
  :files (list +my/finance-journal))

The registry is drawn on the Doom dashboard, which I see every time Emacs starts. Each system is listed with its key and how long ago I last used it. Anything that has gone longer than its :every interval is marked, and the daily agenda names it on a "Neglected" line.

The part I'm happiest with is how "used" is defined. Opening a dashboard doesn't count. A system counts as used when it did its job: a capture was filed, its file changed, or one of its real commands ran. Tracking the commands takes one piece of advice per command:

(dolist (command (plist-get plist :commands))
  ;; Named, so loading the config again does not stack a second copy.
  (advice-add command :before
              (lambda (&rest _) (+my/systems-touch id))
              `((name . ,(intern (format "+my/systems-touch-%s" id)))))))

That's about the most Emacs thing in the whole config. I can attach my own code to the front of any command, including ones from packages I didn't write, without touching their source.

Small fixes with numbers attached

In Magit, pressing + or - on a diff shows more or fewer lines of context around each hunk. In one of my repositories it felt sticky, so I profiled it. Each keypress took about 215ms, because Magit rebuilds every section of the status buffer on any change, and most of the time went to sections that a context change can't affect:

magit-insert-unpushed-to-upstream-or-recent ~108ms
magit-insert-unpulled-from-upstream          ~26ms
magit-insert-unpushed-to-pushremote          ~18ms
magit-insert-unpulled-from-pushremote        ~17ms

Those four all ask Git about remotes. The fix wraps the three context commands so that they run with a shorter section list:

(defun +my/magit-diff-context-fast (fn &rest args)
  "Call FN with ARGS, skipping status sections a context change cannot affect."
  (let ((magit-status-sections-hook
         (seq-difference magit-status-sections-hook
                         +my/magit-diff-context-skipped-sections)))
    (apply fn args)))

(dolist (cmd '(magit-diff-more-context
               magit-diff-less-context
               magit-diff-default-context))
  (advice-add cmd :around #'+my/magit-diff-context-fast))

A keypress now takes about 120ms. The header block costs another 100ms or so and I tried skipping that too, but Magit rebuilds headers as a unit, and leaving them out blanked the Merge and Tag lines on every keypress. So that one stays slow, and there's a comment explaining why, so I don't try it again.

The finance sync got a smaller fix of the same kind. It runs a Python script that pulls bank transactions into an hledger journal, and it used to pop open a window of raw output that I had to close by hand even when everything had worked. Now it shows a spinner in the echo area, and the output buffer only appears if the script fails.

Org links that open other programs

I draw diagrams in Excalidraw, and I wanted them inside my notes. Emacs can't host the Excalidraw canvas, so I split the job. Org gets a new link type, excalidraw:, which previews the rendered PNG inline. Pressing RET on the link starts a small Python server for that one drawing and opens the editor in a browser app window. Each edit is saved back to the file, the PNG is rendered again, and the server prints a line to stdout so Emacs knows to refresh the preview.

The Emacs side of that conversation is a process filter:

(defun +excalidraw--filter (proc output)
  (let ((lines (split-string (concat (process-get proc :pending) output) "\n")))
    ;; The last element is a partial line (or ""); keep it for the next chunk.
    (process-put proc :pending (car (last lines)))
    (dolist (line (butlast lines))
      (cond
       ((string-prefix-p "URL " line)
        (process-put proc :url (substring line 4))
        (+excalidraw--open-url (substring line 4)))
       ((string-prefix-p "RENDERED " line)
        (+excalidraw--refresh-previews (substring line 9)))
       ((string-prefix-p "ERROR " line)
        (message "Excalidraw: %s" (substring line 6)))))))

The comment about the partial line matters. Output from a process arrives in arbitrary chunks, and a chunk can end halfway through a line.

Where another program is better at a job, Emacs starts it and listens for what it says.

This site

The page you're reading is an Org file. The generator for the whole site is one file, publish.el, and it's 253 lines long. It uses only what ships with Emacs: org, ox-html, json and a couple of string libraries. I didn't use Org's own publishing framework. The HTML is put together with format and concat, which sounds crude and has been easy to live with.

The whole build is this function:

(defun site-publish ()
  (interactive)
  (when (file-directory-p site-output) (delete-directory site-output t))
  (make-directory site-output t)
  (site-copy-static)
  (let ((posts (site-posts)))
    (let ((ids (mapcar (lambda (post) (plist-get post :id)) posts)))
      (unless (= (length ids) (length (delete-dups (copy-sequence ids))))
        (error "POST_ID values must be unique")))
    (site-write "index.html" (site-about-page))
    (site-write "writing/index.html" (site-writing-page posts))
    (site-write "misc/index.html" (site-misc-page))
    (dolist (post posts)
      (site-write (format "post/%s/index.html" (plist-get post :id)) (site-post-page post)))
    (site-write "rss.xml" (site-rss posts))
    (site-write "sitemap.xml" (site-sitemap posts))
    ;; (the 404 page is written here too)
    )
  (message "Published site to %s" site-output))

Each post carries a #+POST_ID: line, and that number is its URL. This post is /post/9/. I can rename the file or change the title and the link keeps working, and the build refuses to run if two posts claim the same ID.

Deployment is a GitHub Actions job that installs emacs-nox and runs make build, which is emacs --batch -Q -l publish.el --funcall site-publish. The output is static files on GitHub Pages. No database or server is involved, and Emacs only runs during the build.

One job is left to the browser. Org can colour code blocks at export time, but it needs a major mode for each language, and a bare batch Emacs on a CI machine has none for Zig, Lua or C#. So the build emits plain blocks and a small script highlights them on the page. The RSS feed still has descriptions and no full text. That one is on the list, and it hasn't annoyed me enough yet.

What it costs

All of this took time, and some of it I'd count as wasted. The Org file holding the agenda setup is over a thousand lines, and a fair share of that is formatting I fiddled with for an evening and could have lived without.

There are also rough edges that come from the pieces not knowing about each other. Evil doesn't see a minor mode's keybindings until its keymaps are rebuilt, so my finance dashboard needs an extra hook. Nextcloud drops the executable bit on synced files, so the sync script has to be run through python3 instead of directly. Org's capture is asynchronous, so "file this task and start a clock on it" can't be written as two lines in a row. I found each of those by having something fail, and each one now has a comment next to its workaround.

What I got for it is a setup that fits me closely. My tasks, notes, mail and money are all plain text in one folder, with one set of keys, and when something bothers me I can usually fix it the same evening.

If you're starting out, my advice is to begin as small as I did. Turn on a few Doom modules, learn C-h f, C-h v and C-h k, and add nothing until something has annoyed you more than once. And when you do build something, put it where you'll see it. Otherwise you'll forget it's there, the way I forgot mine.