The Emacs manual often talk about
.emacs interchangeably, generally referring to them as "the Init File" like so:
When you start Emacs, it normally attempts to load your init file. This is either a file named .emacs or .emacs.el in your home directory, or a file named init.el in a subdirectory named .emacs.d in your home directory.
I try to put all my customization code into
init.el because, according to this site, it is 'modern' and 'preferred':
On linux and Mac, by default, emacs look for init file at
~/.emacs ~/.emacs.el ~/.emacs.d/init.el (this is modern, preferred, since ~2010)
I also try not to manually edit
.emacs too often because there are
custom-set-variables sitting in the file and there is a warning that says:
;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right.
Other advantages of using the
.emacs can be found here.
But I recently realize that some of the code I put in
init.el have been left unevaluated when Emacs is restarted. So I have to call up the file and
M-x eval-buffer every time I restart.
Therefore, I'd like to ask:
What is the difference between
.emacsas far as customization is concerned? (question has been partly answered here.)
What is the point of keeping two (or more) Init files when having one would do? Some people even talked about splitting
init.elinto different files, quoting lunaryorn on Reddit:
It makes version control easier, especially if you split your init.el into different files in ~/.emacs.d.
- What to do when (some) code in one of them are persistently left unevaluated?
.emacs and moved all its contents into
init.el, but part of the code in
init.el ,such as the one below, is still unevaluated everytime emacs restarts.
;;set Chinese table alignment font size (set-face-attribute 'default nil :font (font-spec :name "-*-Menlo-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1" :weight 'normal :slant 'normal :size 24)) (dolist (charset '(kana han symbol cjk-misc bopomofo)) (set-fontset-font (frame-parameter nil 'font) charset (font-spec :name "-*-STFangsong-normal-normal-normal-*-*-*-*-*-p-0-iso10646-1" :weight 'normal :slant 'normal :size 28)))