Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find which .emacs file has been loaded?

How do I get emacs to tell me the location of the .emacs file it has loaded?

My situation is simply when I do sudo emacs, it loads up a very different .emacs file than the one in my home directory. I can get around with by doing M-x eval-buffer on my own .emacs file, but that's a lot of extra steps, plus it doesnt seem to clear out the goofy binds in whatever .emacs file is being loaded. If anything, I'd simply like to find the .emacs file and remove some of the stranger binds (c-n, c-p, c-a all rebound to strange stuff)

My main question is still, how do I get emacs to tell me the location of the .emacs file it has loaded?

like image 666
Silfheed Avatar asked May 14 '09 18:05

Silfheed


People also ask

Where can I find my .Emacs file?

Within Emacs, ~ at the beginning of a file name is expanded to your HOME directory, so you can always find your . emacs file with C-x C-f ~/. emacs . There's further information at HOME and Startup Directories on MS-Windows.

Where is my .Emacs file Linux?

emacs config file usually resides in your home directory. See also The Emacs Initialization File. If you need to start with a blank . emacs , try touch ~/.

How do I reload a .Emacs file?

You can use the command load-file ( M-x load-file , then press return twice to accept the default filename, which is the current file being edited). You can also just move the point to the end of any sexp and press C-x C-e to execute just that sexp.


3 Answers

The init file used is stored in the variable 'user-init-file'. To see this use 'describe-variable' (C-h v), type in 'user-init-file' and it will display the file used.

like image 159
Beano Avatar answered Sep 30 '22 01:09

Beano


You could try to see what file is found by:

C-x C-f ~/.emacs RET

~ gets translated to the value of the HOME environment variable. Emacs looks for .emacs, then .emacs.elc (the byte compiled version), then .emacs.el, then ~/.emacs.d/init.elc and ~/.emacs.d/init.el. This documentation shows the alternatives. It also depends on the environment variabls LOGNAME and USER.

You can also check out the contents of the *Messages* buffer - though you should set (setq message-log-max t) (if you can) to ensure that all the Messages are kept. Inside that buffer there are lines that look like:

Loading /home/tjackson/.emacs.tjackson.el (source)...

which will show what files were loaded.

You should also check out the Find-Init documentation that shows even more files that can be loaded like the site-start.el, and terminal specific initialization (new to me).

like image 44
Trey Jackson Avatar answered Sep 30 '22 00:09

Trey Jackson


If you are on Linux, you could try this to see what files are opened by emacs when it launches.

sudo strace -o /tmp/emacs.txt -e open emacs
like image 6
sigjuice Avatar answered Sep 30 '22 01:09

sigjuice