I'm a newbie in Emacs who just is familiar with basic key bindings. I'm trying to learn more. I just learned to create initial file ~/.emacs.d/init.el and how to evaluate. But I find I need to load the initial file every time when I restart Emacs. I tried following things:

  1. check there is no ~/.emacs or ~/emacs.el
  2. go to /usr/local/share/emacs/site-lisp, add a code in subdris.el

    (add-to-list 'load-path "~/.emacs.d/init.el/")

    And I checked that this file is in load-path.

However, I still need to reload the init file every time I restart Emacs. Any suggestions?

  • 1
    You shouldn't need to change any site files to get your init file to load, and there's no point in adding the init file as a directory to the load-path, as it won't cause Emacs to load it, but rather to try looking for Elisp files there when someone requires something. – DoMiNeLa10 Feb 2 at 11:45

Start Emacs and type C-hv user-init-file RET

That will tell you the init file which Emacs is actually loading.

C-hig (emacs)Init File RET will explain in more detail how Emacs establishes which file to load.

I would guess that your understanding of ~/ and Emacs' understanding of ~/ are different.


That's incorrect. load-path should be a list of directories, not files. It tells Emacs where to look for libraries. It does not tell Emacs where to find your init file, however; so load-path is not relevant to your question.

For clarity, ~/.emacs.d should be a directory, and ~/.emacs.d/init.el (if used) should be a regular file within that directory.

  • I've tried the command you mentioned and found the init-file in fact is ~/.emacs.d/init.el . Then I found out I was using the set backgroud-color as the simple testing code which does not permanently change the color. Thank you very much for helping me find out the problem and learn more concept about emacs! – mqy Feb 2 at 19:35

Your Answer

