Subject: Re: bug#3142: 23.0.92; split-window-prefered-function should be able to use split-window-horizontally/split-window-vertically

From: martin rudalics <[email-masked]>
Date: Tue, 28 Apr 2009 08:29:47 +0200

> I would expect that split-window-preferred-function would accept
 > split-window-horizontally and split-window-vertically.

`split-window-preferred-function', if non-nil, must be a function called
with a WINDOW as single argument.  `split-window-vertically' and
`split-window-horizontally' are functions that split the selected window
and take a SIZE argument.  Hence, when you set
`split-window-preferred-function' to `split-window-vertically' as you
did you will get a

split-window-vertically: Window height 1 too small (after splitting)

error because you call `split-window-vertically' with a window as
argument, and `prefix-numeric-value' when called with a window as
argument returns 1, a SIZE argument disliked by `split-window'.
Sounds contrived, but I don't have a better explanation.

If you really need `split-window-preferred-function' use
`split-window-vertically' you have to write a wrapper like

(defun my-split-window-function (window)
   (with-selected-window window
     (split-window-vertically)))

 > At the very
 > least, there should be an easy way to set this to "always split
 > vertically", "always split horizontally", and "intelligently split".

Setting `split-width-threshold' nil for "always split vertically" and
`split-height-threshold' nil for "always split horizontally" should
accomplish that.  Can't you use these directly?

martin