ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial
Web Hosting by 1&1

57.2.4 Saving Customizations

Saving customizations from the customization buffer works by writing code to a file. By reading this code, future sessions can set up the customizations again. Normally, the code is saved in your initialization file (see Init File).

You can choose to save your customizations in a file other than your initialization file. To make this work, you must add a couple of lines of code to your initialization file, to set the variable custom-file to the name of the desired file, and to load that file. For example:

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

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

     (cond ((< emacs-major-version 22)
            ;; Emacs 21 customization.
            (setq custom-file "~/.custom-21.el"))
           ((and (= emacs-major-version 22) (< emacs-minor-version 3))
            ;; Emacs 22 customization, before version 22.3.
            (setq custom-file "~/.custom-22.el"))
           (t
            ;; Emacs version 22.3 or later.
            (setq custom-file "~/.emacs-custom.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 initialization file. This is because saving customizations from such a session would wipe out all the other customizations you might have on your initialization file.

blog comments powered by Disqus