I've changed a setting in Emacs. Now, whenever I try to open a file from the command line, it opens a *scratch*
buffer on top of the file. Is there a way to get rid of this? Or a way to reset my emacs startup settings?
5 Answers
M-x customize-group
initialization
Then, on Initial Buffer Choice, you can select among:
- Startup Screen
- Directory
- File
- scratch buffer
Finally, click on save for future sessions.
You can also toggle it on/off. See if this can help.
(The other thing you probably want to do is to open just a single buffer at start-up. I can't remember by heart how this is done. I'll post an update if I find it out).
You can reload your .emacs
file with M-x load-file ~/.emacs. There are also other ways to do it, check out the question How can I load changes to my .emacs without rebooting Emacs?.
If you think you have a problem with your .emacs
file, try opening using the -q
option:
emacs -q somefile
If that works as expected, you probably have an error in your .emacs, and a good way to debug your .emacs is to use the option --debug-init
:
emacs --debug-init
Which will tell Emacs to provide a stack trace of any error it encounters while loading your .emacs, something like:
Debugger entered--Lisp error: (wrong-type-argument symbolp (car n))
(setq (car n) 3)
(let ((n ...)) (setq (car n) 3))
eval-buffer(#<buffer *load*<2>> nil "/home/tjackson/.emacs.tjackson.el" nil t) ; Reading at buffer position 161460
load-with-code-conversion("/home/tjackson/.emacs.tjackson.el" "/home/tjackson/.emacs.tjackson.el" nil nil)
load("/home/tjackson/.emacs.tjackson.el")
(let ((debug-on-error t)) (load user-init-file))
(if init-file-debug (let (...) (load user-init-file)) (error (format "Problems while loading the file %s: %s" user-init-file ...)))
(condition-case err (load user-init-file) (error (if init-file-debug ... ...)))
(if (file-exists-p user-init-file) (condition-case err (load user-init-file) (error ...)))
eval-buffer(#<buffer *load*> nil "/home/tjackson/.emacs" nil t) ; Reading at buffer position 12150
load-with-code-conversion("/home/tjackson/.emacs" "/home/tjackson/.emacs" t t)
load("~/.emacs" t t)
#[nil "....."]
command-line()
normal-top-level()
And that generally can point you to what might be wrong. In my case above, I'm using setq
improperly, and it looks like it's inside a let
statement, which is inside the file /home/tjackson/.emacs.tjackson.el
. A quick search in that file leads me to the error and I can fix it.
-
1Nick said that it opens the scratch buffer ON TOP OF THE FILE (emphasis mine) which means to me that he's calling emacs with "emacs foo" and in that case, foo should come up on top of scratch. scratch will be there, but foo should be the buffer shown... Commented Mar 10, 2010 at 16:17
-
@Brian Thanks, I've updated the answer to reflect your interpretation (which sounds reasonable). Commented Mar 10, 2010 at 18:10
If you want to reset emacs settings, you could rename your current .emacs file to something else to have a backup - then relaunch Emacs.
My ~/.emacs.d
folder was owned by root with restrictive r/w/x
privileges, so I was unable to access as any non-root user.
Make sure your current user has read privileges for the emacs config files/directories.
This fixed it for me:
sudo chown -R user:group ~/.emacs.d/
The -R
works recursively in the directory.
initial-buffer-choice
tot
, maybe via customization Environment -> Initialization.