emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: split-window-preferred-function


From: Juri Linkov
Subject: Re: split-window-preferred-function
Date: Fri, 21 Mar 2008 01:02:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

> `split-window-preferred-function' appears half-baked: In
> `display-buffer' its calls are preceded by things like
>
>         && (window_height (window) >= split_height_threshold
>         ...
>         && (window_height (window)
>             >= (2 * window_min_size_2 (XWINDOW (window), 0))))
>
> Set to some horizontal splitting function, splitting will be wrongly
> rejected when the original window is not sufficiently high and wrongly
> accepted when the window is not wide enough.  Hence it seems that we
> need something like `split-width-threshold' and a way to detect how
> `split-window-preferred-function' is going to split the window in order
> to know which of our checks should be applied.

Maybe a function in `split-window-preferred-function' should take care
of all these conditions to decide how to split within a given
window configuration?

This means we could remove `split-window' from the default value of
`split-window-preferred-function', and then check in `display-buffer'
if `split-window-preferred-function' is non-nil, then call it without
checking any condition.  Otherwise, call `split-window', i.e. exactly
as it was implemented before introducing `split-window-preferred-function'.

The following patch implements this (note that checking for non-nil
Vsplit_window_preferred_function is not necessary in the else-branch
because when Vsplit_window_preferred_function is called unconditionally
it never reaches this else-branch with the second place where
Fsplit_window is called).

Index: src/window.c
===================================================================
RCS file: /sources/emacs/emacs/src/window.c,v
retrieving revision 1.604
diff -c -w -b -r1.604 window.c
*** src/window.c        19 Mar 2008 15:18:29 -0000      1.604
--- src/window.c        20 Mar 2008 22:01:17 -0000
***************
*** 3850,3855 ****
--- 3850,3858 ----
  
        /* If the largest window is tall enough, full-width, and either eligible
         for splitting or the only window, split it.  */
+       if (!NILP (Vsplit_window_preferred_function))
+       window = call1 (Vsplit_window_preferred_function, window);
+       else
        if (!NILP (window)
            && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
            && WINDOW_FULL_WIDTH_P (XWINDOW (window))
***************
*** 3857,3863 ****
                   || (NILP (XWINDOW (window)->parent)))
          && (window_height (window)
              >= (2 * window_min_size_2 (XWINDOW (window), 0))))
!       window = call1 (Vsplit_window_preferred_function, window);
        else
        {
          Lisp_Object upper, other;
--- 3860,3866 ----
                || (NILP (XWINDOW (window)->parent)))
            && (window_height (window)
                >= (2 * window_min_size_2 (XWINDOW (window), 0))))
!         window = Fsplit_window (window, Qnil, Qnil);
        else
        {
          Lisp_Object upper, other;
***************
*** 3872,3878 ****
                       || (NILP (XWINDOW (window)->parent)))
                   && (window_height (window)
                       >= (2 * window_min_size_2 (XWINDOW (window), 0))))
!           window = call1 (Vsplit_window_preferred_function, window);
          else
            window = Fget_lru_window (frames, Qnil);
          /* If Fget_lru_window returned nil, try other approaches.  */
--- 3875,3881 ----
                  || (NILP (XWINDOW (window)->parent)))
              && (window_height (window)
                  >= (2 * window_min_size_2 (XWINDOW (window), 0))))
!           window = Fsplit_window (window, Qnil, Qnil);
          else
            window = Fget_lru_window (frames, Qnil);
          /* If Fget_lru_window returned nil, try other approaches.  */
***************
*** 7598,7604 ****
  to split windows horizontally or vertically or some mix of the two.
  It is called with a window as single argument and should split it in two
  and return the new window.  */);
!   Vsplit_window_preferred_function = intern ("split-window");
  
    DEFVAR_INT ("window-min-height", &window_min_height,
              doc: /* *Delete any window less than this tall (including its 
mode line).
--- 7601,7607 ----
  to split windows horizontally or vertically or some mix of the two.
  It is called with a window as single argument and should split it in two
  and return the new window.  */);
!   Vsplit_window_preferred_function = Qnil;
  
    DEFVAR_INT ("window-min-height", &window_min_height,
              doc: /* *Delete any window less than this tall (including its 
mode line).

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]