user140321
user140321

Reputation: 191

How do I prevent Emacs from horizontally splitting the screen when opening multiple files?

I want to be able to open multiple files with Emacs like the following command:

emacs file1 file2

and have the Emacs screen -not- be split horizontally when Emacs starts up. Opening the files in different buffers is what I expected, with just one of the files displayed in the entire Emacs window.

So how do I do this?

Upvotes: 8

Views: 3548

Answers (4)

Trey Jackson
Trey Jackson

Reputation: 74430

Well, you can set up an (tcsh) alias like so

alias emacs emacs -eval '"(run-with-idle-timer 0 nil (quote delete-other-windows))"'

This makes emacs hide all the other windows (so you only have one). So your invocation

emacs file1 file2

is translated to

emacs -eval '"(run-with-idle-timer 0 nil (quote delete-other-windows))"' file1 file2

Upvotes: 1

user140321
user140321

Reputation: 191

(add-hook 'window-setup-hook 'delete-other-windows)

works the way I want... just found that out after I asked here.

Upvotes: 11

jrockway
jrockway

Reputation: 42674

Or just press C-x 1 after the emacs has loaded.

Personally, I think you are misusing emacs if you invoke it from the command-line. I tend to visit files from within eshell, which is running inside emacs.

Upvotes: -2

user60401
user60401

Reputation: 668

Nasty and hackish, but it works:

$ emacs -nw --eval "(mapcar 'find-file '(\"1.txt\" \"2.txt\"))"

Upvotes: 0

Related Questions