It should be mentioned, however, that only Emacs 22+ loads ~/.emacs.d/init.el
as alternate per-user init file. As a new but downward-compatible feature it priorizes ~/.emacs
. This is arranged in lisp/startup.el
.
After startup the user-init-file
variable contains the full pathname of the init file in charge, e.g. /home/me/.emacs.elc
or C:\Users\Me\.emacs.d\init.el
etc. To see its value, in the *scratch*
buffer type (insert user-init-file)
followed by C-x C-e
.
The ~/.emacs.d/
directory is actually a standard location for additional per-user files. The path is defined by the Emacs variable user-emacs-directory
. Under Windows this path depends on the HOME
(not USERPROFILE
) variable. When HOME
is set to C:\
, for example, it will be C:\.emacs.d
. When running Emacs portably I put upon this behavior, by using a batch-file that sets HOME
to a directory on the pen drive.
There are not only Lisp files in this directory! For example, the auto-save feature by default stores any edited file into ~/.emacs.d/auto-save-list/
(see the auto-save-list-file-prefix
variable). This inspired me to store backup-files there too:
(defvar --user-backup-directory (concat user-emacs-directory "backups"))
(if (not (file-exists-p --user-backup-directory))
(make-directory --user-backup-directory t))
(setq backup-directory-alist `(("." . ,--user-backup-directory)))
(setq make-backup-files t)
Prior to Emacs 22 I also had a ~/elisp
directory for my personal Lisp files. Now I use
(pushnew (expand-file-name "~/.emacs.d/elisp") load-path)
as advised here.
So ~/.emacs.d
is actually quite useful, although I find the idea of ~/.emacs.d/init.el
questionable. The ~/.emacs.d/
directory is a standard location for additional per-user files. Wouldn't it make more sense when Emacs reads ~/.emacs.d/init.el
additionally to ~/.emacs.el
?