2
votes

When opening emacs with two files $ emacs a.txt b.txt, the window splits vertically.

I need to have a horizontal split instead. Is there a variable that controls this behavior or is there a hook where I can override the one behavior without changing other behaviors as well?

I've looked at related questions on StackOverflow but they had a different focus and their answers weren't directly applicable:

I would like to find the specific code runs when emacs is opened and change just the one call to (split-window-vertically).

In case it matters, I'm using GNU Emacs 24.3.1.

3

3 Answers

2
votes

The specific code to open files from the command line is in startup.el. The function is command-line-1 and it calls find-file-other-window (in two different places).

You should be able to do something like this in your .emacs, but I'm not sure about the details:

(defadvice find-file-other-window (before split (file &optional wildcards))
  (if <during command line processing>
      (split-window-horizontally)))
(ad-activate 'find-file-other-window)
2
votes
emacs -Q a.txt -eval "(split-window-horizontally)" -eval "(find-file \"b.txt\")"

Maybe set some font too, for example Liberation Mono-18:

emacs -Q a.txt -eval "(split-window-horizontally)" -eval "(find-file \"b.txt\")" --font 'Liberation Mono-18'

Without option -Q load your init-file also.

Well, just for completeness, when at a file already: C-x 3

0
votes

There's an option to transpose vertical/horizontal split. Very convenient and fun.