0
C-h v
user-init-file

shows

~/.emacs

but I want this user-init-file point to ~/emacs.d/init.el

Requirement is to be able to switch between .emacs and .emacs.d/init.el and .emacs.el anytime, without deleting/replacing these init files

I do not see any options here

Question:

Without deleting .emacs file from its place, What is the procedure for emacs user to pick different init file, for future emacs session?

13
  • 1
    Refer to gnu.org/software/emacs/manual/html_node/emacs/Init-File.html . If ~/.emacs exists, that takes precedence over ~/.emacs.d/init.el. Simply delete or rename ~/.emacs to something that Emacs doesn't look for, and then it'll find your init.el file.
    – phils
    Commented May 15, 2017 at 2:35
  • @phils I read that content. But deleting file looks weird. I have my own work in .emacs. I paste the same reference Commented May 15, 2017 at 2:37
  • You shouldn't have both an ~/.emacs file and a ~/.emacs.d/init.el file. They are alternative names for a single purpose, and they are both "your own work" in that they are expected to be your personal init file. Pick whichever filename works best for you, and remove the other file. You can most certainly put custom code into multiple different .el files, but those particular filenames are reserved for use as the init filename.
    – phils
    Commented May 15, 2017 at 2:39
  • If you're trying to maintain multiple emacs configurations then emacs.stackexchange.com/q/4253 might be helpful.
    – phils
    Commented May 15, 2017 at 2:43
  • 1
    You can generally work around that, but there are other answers to that question as well. I don't actually know what you're trying to do, though. Do you need one emacs configuration, or multiple emacs configurations? Or do you only need to load a particular elisp file in some cases, but not others? Or something else?
    – phils
    Commented May 15, 2017 at 2:50

2 Answers 2

1

Start emacs with below options,

emacs -q --load "~/.emacs.d/init.el"

where:

-q - Do not load any initialization file

--load - Load a Lisp library named file with the function load. If file is not an absolute file name, Emacs first looks for it in the current directory, then in the directories listed in load-path

1
  • And to reiterate for the benefit of anyone else reading this, be aware that this technique isn't the same thing as Emacs using ~/.emacs.d/init.el as the init file. emacs.stackexchange.com/a/4258 has additional information.
    – phils
    Commented May 15, 2017 at 5:17
1

Without clarifying why you want to alternate between those two specific files, it's hard to give a good answer, but besides overexchange's use of --load (aka -l), you can also use a trick such as:

ln -s ~/.emacs ~/.emacs.elc
emacs

to run Emacs using ~/.emacs and then

ln -s ~/.emacs.d/init.el ~/.emacs.elc
emacs

to run Emacs using ~/.emacs.d/init.el.

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