emacs-devel
[Top][All Lists]
Advanced

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

Re: split-window-preferred-function


From: Stefan Monnier
Subject: Re: split-window-preferred-function
Date: Sat, 22 Mar 2008 12:36:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> I think we need to allow the function to return nil and in this case
>> continue with the rest of the code.  I.e. it should be possible to
>> reproduce in Elisp what happens when split-window-preferred-function
>> is nil.  A good way to make sure that's true is to write the code in
>> Elisp in the first place.

> If I understand you correctly, this patch implements what you meant:

Part of it, the missing parts:
1 - update the docstring of split_window_preferred_function.
2 - provide a non-nil default for split_window_preferred_function
    by moving the current C code that checks the size and calls
    split-window to Elisp.


-- Stefan


> 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      22 Mar 2008 01:07:04 -0000
> ***************
> *** 3848,3853 ****
> --- 3848,3859 ----
>         else
>       window = Fget_largest_window (frames, Qt);
  
> +       if (!NILP (Vsplit_window_preferred_function))
> +     tem = call1 (Vsplit_window_preferred_function, window);
> + 
> +       if (!NILP (tem))
> +     window = tem;
> +       else
>       /* If the largest window is tall enough, full-width, and either eligible
>          for splitting or the only window, split it.  */
>       if (!NILP (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;
> --- 3863,3869 ----
>               || (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.  */
> --- 3878,3884 ----
>                 || (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).
> --- 7604,7610 ----
>   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]