manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

57.2.4 Saving Customizations

Saving customizations from the customization buffer works by writing code that future sessions will read, code to set up those customizations again.

Normally this saves customizations in your init file, ‘~/.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 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"))
       ;; 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 section 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.

© 2000-2018
Individual documents may contain additional copyright information.