An Optimal .emacs File

I recently stumbled across this old post from Nickel’s Worth on optimizing your .emacs file. It’s from 2009 so it is, in some parts, dated but it still contains a lot of good ideas.

To me, the most controversial piece of advice is to avoid using load or require in your .emacs. I’ll let you read the post for the reasons for that but I will say that the suggestion is not without merit.

Another idea that solves a problem I seem to keep having is to use eval-after-load so that you can set various package-configuration variables without loading the package. For example, you might have the autoloaded package foo that requires that you configure the foo-blah1 and foo-blah2 variables. The way to do that is

(eval-after-load "foo"
  '(progn
    (setq foo-blah1 "some string")
    (setq foo-blah2 "some other string")))

That way, the setting of the foo-blah1 and foo-blah2 variables is not executed until the package is actually loaded so you won’t get a void-variable error. This suggestion alone makes the post worth reading.

This is a short post so there’s no reason not to give it a look. You may get some ideas that hadn’t occurred to you before.

This entry was posted in General and tagged . Bookmark the permalink.