I've changed a setting in emacs and 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?
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.
If you want to reset emacs settings, you could rename your current .emacs file to something else to have a backup - then relaunch Emacs.
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).