2

I do not find init.el in .emacs.d. Where should I put my configuration?

% ls -a .emacs.d
.           .session        auto-save-list      recentf
..          .uptimes.el     org-clock-save.el   var
zell
  • 173
  • 6
  • see also https://emacs.stackexchange.com/questions/1/are-there-any-advantages-to-using-emacs-d-init-el-instead-of-emacs – Tyler May 10 '21 at 17:32
  • 1
    It feels like this question must have been asked before, but I didn't find a duplicate in the `init-file` FAQ list – Tyler May 10 '21 at 17:36

2 Answers2

4

From the manual (emacs) Find Init:

Emacs looks for your init file using the filenames ‘~/.emacs.el’, ‘~/.emacs’, or ‘~/.emacs.d/init.el’ in that order; you can choose to use any one of these names. (Note that only the locations directly in your home directory have a leading dot in the location’s basename.)

There are a few other, less common, possibilities. See the manual for more details.

If you don't have an init file in any of these locations, you need to create one. Since you already have an .emacs.d directory, it's probably most convenient to create a new file .emacs.d/init.el.

init.el is just a plain text file with elisp code in it. There's nothing special needed to create it, just start saving your config code in a file with that name and you're ready to go.

Tyler
  • 21,719
  • 1
  • 52
  • 92
1

If you want to find where the init file for an existing Emacs is located, from within Emacs itself, you can look at the value of the user-init-file variable with C-h v user-init-file RET.

This will open a buffer showing the value of the variable. If it is nil then no init file is used. Otherwise it will show the path to the currently used init file.

PRouleau
  • 744
  • 3
  • 10