Unlike some Emacs old-schoolers, I make heavy use of the Emacs built-in GUI-ish customization system. In order to make customizations in my new blank-slate setup, I need to first set it up to use a different file than the default. So the first additions I make to my init.el are to customize the customizations file.

First, I set up some variables recording the full path of the init.el file and the directory it lives in. That way I can refer to relative paths within my .emacs24.d directory without hardcoding any paths.

Note that I prefix all of my variables with “abg-” (my initials) in order to avoid stepping on existing variable names.

Once I have a reference to the current directory, I set up the custom file and then load it.

Here’s the code:

Then to test it out, I load the file with M-x load-file and then open up a customize buffer for the tool-bar-mode toggle.

Once I toggle the toolbar mode to “off” and click “Save for future sessions” I can see the customizations have been saved to ~/.emacs24.d/emacs-customizations.el:

Published by Avdi Grimm

2 Comments

  1. This is a nice touch:

    (setq abg-emacs-init-file load-file-name)
    (setq abg-emacs-config-dir
    (file-name-directory abg-emacs-init-file))
    
    Reply
  2. Nice trick!

    I’m revisiting my emacs config. I have all my customization stuff at the bottom of my ~/.emacs.d/init.el. Emacs does it by default. Having it in the different file is convenient. Thanks Avdi!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *