Ubuntu – Keeping emacs from splitting the window when openning multiple files

configurationemacs

Whenever I open more than one file at the same time with emacs, as in:

emacs foo.dat bar.dat

The window that opens will be split between the two files (a buffer for each file). I would like to avoid that. Is there a line I can place in my .emacs file to keep that from happening? I would like emacs to only open one buffer in the window, no matter how many files I'm loading.

I'm using version 23.1.1.

Best Answer

The following code works for me (add into ~/.emacs):

(add-hook 'emacs-startup-hook
          (lambda () (delete-other-windows)) t)

The emacs-startup-hook is run after loading the init file and processing the command line, so all files have been loaded and opened; calling delete-other-windows leaves just one of them visible (normally the last one given on the command line).

Note: you might also need to customize inhibit-startup-screen and set it to t for the above to work.