0

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
  • 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.
    – user12563
    Feb 2, 2019 at 11:45

1 Answer 1

4

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.


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

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.

1
  • 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!
    – catfield
    Feb 2, 2019 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.