Organizing Emacs initfiles

I haven't done an #emacs bankruptcy for half a decade now. Think I settled into a good system (famous last words…).

Briefly tried the literate "init.org" some people like. Quickly bailed out because the code changes too often and then any lengthy explanations go stale. Short crisp code-comments survive more refactors.

(If y'ain't gonna write full paragraphs, there's no need for Org-mode.)

On the other extreme, the 1-file-per-package some people like, does not seem nice to my mind either. I have 10-20 elisp files total (for 8,000 lines of code).

Tips to past-me

  • collect all your defuns into a single "my-lib.el", then all the other files are cleaner
    • That's certainly going to become your single largest initfile, yet it cannot break init since new defuns don't affect emacs state!
  • set most builtin variables in one file
  • bind most keys in one file. load it early, so when half of init breaks, you still have your keys
  • load most low-config packages in one file
    • what needs more extensive conf get a dedicated file—for me that's 1 file for org-mode, 1 file for dired, 1 for shell/term, 1 for completion systems (helm/vertico/company), 1 for exwm… that's about it.
  • have an "experiment zone" which is the file that's loaded last. then if it breaks init, the rest still works
Created (3 months ago)