Next: , Previous: Changing a Variable, Up: Easy Customization


57.2.4 Saving Customizations

The customization buffer normally saves customizations in ~/.emacs. If you wish, you can save customizations in another file instead. To make this work, your ~/.emacs should set custom-file to the name of that file. Then you should load the file by calling load. For example:

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

You can also use custom-file to specify different customization files for different Emacs versions, like this:

     (cond ((< emacs-major-version 21)
            ;; Emacs 20 customization.
            (setq custom-file "~/.custom-20.el"))
           ((and (= emacs-major-version 21) (< emacs-minor-version 4))
            ;; Emacs 21 customization, before version 21.4.
            (setq custom-file "~/.custom-21.el"))
           ((< emacs-major-version 22)
            ;; Emacs version 21.4 or later.
            (setq custom-file "~/.custom-21.4.el"))
           (t
            ;; Emacs version 22.1 or later.
            (setq custom-file "~/.custom-22.el")))
     
     (load custom-file)

If Emacs was invoked with the -q or --no-init-file options (see Initial Options), it will not let you save your customizations in your ~/.emacs init file. This is because saving customizations from such a session would wipe out all the other customizations you might have on your init file.