On Mon, Dec 16, 2024 at 8:59 AM Juri Linkov wrote: > >> Maybe increasing the value of split-height-threshold will help you? > >> For example, I customized it to a large value, so I have no problems > >> because then windows are split only horizontally. > > > > Yes, but I do want it to split vertically at some point. > > Typically, in fullscreen mode, after 3 or 4 horizontal splits, I want it > to > > split vertically. > > Makes sense. Then what about adding a new option that defines > the minimal number of columns each window should have after split? > With a name like 'split-columns-threshold'. > > As long as the width of a new window will fit into > 'split-columns-threshold', > split horizontally, otherwise vertically. > > Then you can split to 3 or 4 horizontal splits until reaching the limit > of 'split-columns-threshold'. After that should split the narrow windows > vertically. > I think the variables split-width-threshold and split-height-threshold already do that. [...] > > > The patch I attached does this: > > > > if width > height and width > 80 > > try to split horizontally, then try vertically and finally fallback > to horizontal split > > else > > try to split vertically, then try horizontally and finally fallback > to vertical split > > We need to carefully check if it can handle various use cases. > Yes, one can install the new behavior using split-window-preferred-function to try it out. > > > I have been using it for a couple of weeks and it is working fine. > > The condition could be tweaked, specially the (widht > 80) part. We could > > also decide to always fallback to vertical split at the end (which will > fix > > my implementation problem). > > Indeed, better to fallback to vertical split when all options are > exhausted. > I wrote a new patch that always fallback on vertical split, and I got rid of the weird (width > 80) condition since split-width-threshold already does it. The result is a simpler patch that works perfectly. It basically does that: if width > height: try to split horizontally, then try to split vertically else try to split vertically, then try to split horizontally fallback to vertical split Cheers, -Nico