开发者

Opening emacs without the scratch buffer when opening a file

I've changed a setting in Emacs. Now, whenever I try to open a file from t开发者_开发技巧he 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?


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜