M-x all-things-emacs

Quick Tip: Detaching the custom-file

December 6th, 2008 by Ryan McGeary · 12 Comments

I’ve never really liked the built-in customization UI in Emacs (M-x customize). I’m sure plenty of people use it and enjoy it, but, to me, it feels like an abominable tree of never ending and difficult to navigate options. Plus, it sticks your saved customizations as an unorganized mess of elisp smack at the bottom of your init file. I’m not quite sure how to solve my first gripe, but the second is manageable.

By setting the custom-file variable, you can keep those automated customizations in a separate file. Put this in your Emacs init:

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)

Both lines are necessary. The first line tells Custom to save all customizations in the file, but does not load it. The 'noerror argument passed to load prevents errors if the file doesn’t exist. If you had existing customizations in your init file, be sure to copy them to the new custom file.

Now, go enjoy a cleaner init file. This tip is especially useful if you keep your init files under a version control system. You do keep your init files under version control, right?

Tags: elisp · quick · tips

12 responses so far ↓

  • 1 me // Dec 7, 2008 at 2:01 pm

    Amen, brudda! And yes, I’ve been keeping my dotfiles in revision control for years … inspired by http://joey.kitenet.net/svnhome/

  • 2 Bob Erb // Dec 8, 2008 at 7:12 pm

    Thank you. I hate that custom cruft, too.

  • 3 Karl Anderson // Dec 9, 2008 at 7:39 pm

    I just have a one-liner .emacs: “(load-library “~/emacs/my-emacs”)”, and let emacs do what it wants with .emacs. A simpler solution IMHO, because it does less – my-emacs.el loads a lot of my-foo.el libraries for various foo, anyway.

  • 4 Gimmmo // Mar 29, 2009 at 12:14 am

    Thanks, you save my day :)

  • 5 coder // Apr 11, 2009 at 11:50 am

    Hello, I am writing a new Java source browser for Emacs, using Pymacs and Python. It’s called PyJDE.

    http://code.google.com/p/pyjde/

    Take a look.

  • 6 Las Vegas Escorts // Jul 1, 2015 at 10:09 pm

    ... [Trackback]

    [...] Read More Infos here: emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ [...]

  • 7 http://localprohandymen.org // Jul 2, 2015 at 2:54 am

    ... [Trackback]

    [...] Informations on that Topic: emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ [...]

  • 8 pop over to these guys // Jul 2, 2015 at 4:25 am

    ... [Trackback]

    [...] Read More here: emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ [...]

  • 9 what is inner trading circle // Jul 2, 2015 at 11:04 am

    ... [Trackback]

    [...] Informations on that Topic: emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ [...]

  • 10 this content // Jul 2, 2015 at 4:49 pm

    ... [Trackback]

    [...] Informations on that Topic: emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ [...]

  • 11 new dentist // Jul 2, 2015 at 10:27 pm

    ... [Trackback]

    [...] Read More: emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ [...]

  • 12 london pest control // Jul 3, 2015 at 10:18 pm

    ... [Trackback]

    [...] There you will find 61745 more Infos: emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ [...]