Adam B.
Adam B.

Reputation: 91

Emacs find-file-other-window command splits buffer vertically

I am just setting up Emacs on a new machine and I am running into trouble with the command find-file-other-window. The way I typically like to work is with the frame split horizontally into two windows. I'd like to be able to run said command and have it open the file in the other window, but instead most of the time it splits the current window into 2 new windows horizontally. How do I get it to stop doing this? Thanks.

EDIT: Also want to point out that this only happens when I scale the frame to a large enough size.

Upvotes: 4

Views: 1961

Answers (1)

Jim Janney
Jim Janney

Reputation: 501

Normally this action is performed by the function split-window-sensibly, and controlled by two variables, split-height-threshold and split-width-threshold. Per the documentation

If ‘split-height-threshold’ specifies an integer, WINDOW is at least ‘split-height-threshold’ lines tall and can be split vertically, split WINDOW into two windows one above the other and return the lower window. Otherwise, if ‘split-width-threshold’ specifies an integer, WINDOW is at least ‘split-width-threshold’ columns wide and can be split horizontally, split WINDOW into two windows side by side and return the window on the right. If this can’t be done either and WINDOW is the only window on its frame, try to split WINDOW vertically disregarding any value specified by ‘split-height-threshold’. If that succeeds, return the lower window. Return nil otherwise.

On my system the default value for split-height-threshold is 80 and split-width-threshold is 160. I think you could get the effect you want by setting split-width-threshold to something lower. Alternatively you could set split-height-threshold to nil, preventing it from ever splitting vertically, or set the variable split-window-preferred-function to a different function. Any of these would affect, not just find-file-in-other-window, but all the functions that split the screen.

Upvotes: 3

Related Questions