Search code examples
emacsdired

how to prevent Emacs dired from splitting frame into more than two windows?


In an Emacs dired buffer, if I navigate point over a filename and hit o for dired-find-file-other-window, dired successfully produces desired behavior: opening the file in a secondary window.

But if I then navigate point over a SECOND filename and again hit o, dired splits the frame AGAIN and opens the file in a THIRD window.

How do I direct dired to reuse the second window, such that I always have a maximum of two windows in a frame?


Solution

  • Raise value of split-height-threshold to the extend it will not do another split.

    You might have to raise split-width-threshold also - in case Emacs thinks it's smart to split that way than.

    WRT questions in comment:

    The value to choose IMO depends from number of lines displayed at window. Let's assume 40 lines are displayed. If a window is split, 20 are left. Then a `split-height-threshold' of 15 should prevent further split. Preventing further side-by-side split should work respective, just consider the columns displayed.

    BTW would expect a way to adapt that dynamically.