Breaking up init.el (Emacs Reboot #13)

My brand-new init.el has been steadily growing. Before I go any further, it’s time to break it up into manageable pieces.

I add some code to init.el which will load all elisp files in ~/.emacs24.d/init.d:

(if (file-exists-p abg-init-dir)
    (dolist (file (directory-files abg-init-dir t "\.el$"))
      (load file)))
 <p> Then I go through <code>init.el</code> and pull almost all of it out into separate files in <code>init.d</code>: </p>    <pre class="example">/home/avdi/.emacs24.d/init.d:

total used in directory 52 available 57769540
drwxr-xr-x 2 avdi avdi 4096 2011-10-08 00:19 .
drwxr-xr-x 8 avdi avdi 4096 2011-10-08 00:16 ..
-rw-r–r– 1 avdi avdi 268 2011-10-08 00:16 00_load_paths.el
-rw-r–r– 1 avdi avdi 422 2011-10-08 00:19 01_packages.el
-rw-r–r– 1 avdi avdi 103 2011-10-08 00:16 backup.el
-rw-r–r– 1 avdi avdi 335 2011-10-08 00:16 blogging.el
-rw-r–r– 1 avdi avdi 78 2011-10-08 00:16 code.el
-rw-r–r– 1 avdi avdi 115 2011-10-08 00:16 github.el
-rw-r–r– 1 avdi avdi 76 2011-10-08 00:16 ruby.el
-rw-r–r– 1 avdi avdi 150 2011-10-08 00:08 secrets.el
-rw-r–r– 1 avdi avdi 191 2011-10-08 00:16 text.el
-rw-r–r– 1 avdi avdi 184 2011-10-08 00:16 ZZ_keybindings.el

I give a few of the files special name prefixes to force the order in which they are loaded. I want load paths to be set up before anything else, so I prefix that file with 00_. I want to defer keybindings until everything else has been loaded, so I use a prefix of ZZ_ for that file. Since the default behavior of directory-files is to lexically sort the file names, I can rely on file prefixes to determine load order.

[boilerplate bypath=”emacs-reboot”]