7

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?

nbro
  • 15,395
  • 32
  • 113
  • 196
Nick
  • 71
  • 1
  • 2
  • 1
    Most likely you have set `initial-buffer-choice` to `t`, maybe via customization Environment -> Initialization. – starblue Jul 05 '12 at 07:16

5 Answers5

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

Roberto Aloi
  • 30,570
  • 21
  • 75
  • 112
3

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.

Community
  • 1
  • 1
Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
  • 1
    Nick 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... – Brian Postow Mar 10 '10 at 16:17
  • @Brian Thanks, I've updated the answer to reflect your interpretation (which sounds reasonable). – Trey Jackson Mar 10 '10 at 18:10
1

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.

nbro
  • 15,395
  • 32
  • 113
  • 196
Jeffrey Martinez
  • 4,384
  • 2
  • 31
  • 36
1

If you want to reset emacs settings, you could rename your current .emacs file to something else to have a backup - then relaunch Emacs.

cit
  • 2,465
  • 5
  • 28
  • 36
-1

I removed my ~/.emacs.d directory and that fixed the situation for me.

nbro
  • 15,395
  • 32
  • 113
  • 196
Selah
  • 7,728
  • 9
  • 48
  • 60