views:

256

answers:

3

Heyas

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?

+1  A: 

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
sigjuice
+4  A: 

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).

Trey Jackson
+10  A: 

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.

Beano