Subject: Re: bug#20189: 25.0.50; Feature request: Alternative split-window-sensibly functions

From: Tassilo Horn <[email-masked]>
Date: Thu, 26 Mar 2015 05:27:43 +0100

Eli Zaretskii <[email-masked]> writes:

>> But for the time being, I prefer some solution which is available
>> right now and good enough for my personal preferences.  And that's
>> the point of the issue.  Window handling is extremely hard to
>> configure in Emacs with the amounts of options we have.  That's why
>> I've suggested to have a small set of alternatives one can choose
>> from without having to dig into the details of window thresholds,
>> window parameters, window combinations, etc.
>
> So how about adding 2 more parameters that we've discussed a few
> messages ago, and then come up with a logic that uses all 4 of them to
> give more "sensible" results?

With the new parameters you mean something like `window-preferred-width'
and `window-preferred-height', right?

Sounds legit to me.  In my case, I'd set the preferred width to 80 but
my preferred height is usually as high as possible or as high as needed
to fit the contents of the buffer we want to show in that new window.

Maybe it would make sense to use the values of these two variables (if
non-nil) as defaults for the `window-width' and `window-height' alist
entries of `display-buffer'.

I'm still a bit unsure how to differentiate "preferred width" from
`window-min-width'.  For me, preferred width means a lower bound for
windows with "normal" buffers.  So maybe I want to set
`window-min-width' to 80 instead of its default of 10?  But what about
special, narrow buffers such as `sr-speedbar' (speedbar shown in a
narrow window instead of an extra frame)?

To answer myself: it seems I actually want to use a minimum width of
80.  That seems to supress any splits that result in windows smaller
than 80 columns unless the width is explicitly given, e.g.,

  (setq window-min-width 80)
  (display-buffer (get-buffer "*Help*")
                  '(display-buffer-pop-up-window
                    (window-width . 10)))

still splits although the new window is just 10 columns wide.

Bye,
Tassilo