comparison src/window.c @ 93407:da5b46bdd92c

(Fdisplay_buffer): Move call to Vsplit_window_preferred_function out of conditions that check if window is eligible for vertical splitting. When Vsplit_window_preferred_function is non-nil, call it and use its non-nil return value as window. Otherwise, continue doing vertical splitting using Fsplit_window with arg horflag=nil. (syms_of_window) <Vsplit_window_preferred_function>: Change the default value from `split-window' to nil.
author Juri Linkov <juri@jurta.org>
date Sat, 29 Mar 2008 23:04:56 +0000
parents 3ca0c43ea37d
children eb9ab4139643
comparison
equal deleted inserted replaced
93406:2428ecdc8ca0 93407:da5b46bdd92c
3846 #endif 3846 #endif
3847 } 3847 }
3848 else 3848 else
3849 window = Fget_largest_window (frames, Qt); 3849 window = Fget_largest_window (frames, Qt);
3850 3850
3851 /* If the largest window is tall enough, full-width, and either eligible 3851 if (!NILP (Vsplit_window_preferred_function))
3852 for splitting or the only window, split it. */ 3852 tem = call1 (Vsplit_window_preferred_function, window);
3853 if (!NILP (window) 3853
3854 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) 3854 if (!NILP (tem))
3855 && WINDOW_FULL_WIDTH_P (XWINDOW (window)) 3855 window = tem;
3856 && (window_height (window) >= split_height_threshold 3856 else
3857 || (NILP (XWINDOW (window)->parent))) 3857 /* If the largest window is tall enough, full-width, and either eligible
3858 && (window_height (window) 3858 for splitting or the only window, split it. */
3859 >= (2 * window_min_size_2 (XWINDOW (window), 0)))) 3859 if (!NILP (window)
3860 window = call1 (Vsplit_window_preferred_function, window); 3860 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3861 && WINDOW_FULL_WIDTH_P (XWINDOW (window))
3862 && (window_height (window) >= split_height_threshold
3863 || (NILP (XWINDOW (window)->parent)))
3864 && (window_height (window)
3865 >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3866 window = Fsplit_window (window, Qnil, Qnil);
3861 else 3867 else
3862 { 3868 {
3863 Lisp_Object upper, other; 3869 Lisp_Object upper, other;
3864 3870
3865 window = Fget_lru_window (frames, Qt); 3871 window = Fget_lru_window (frames, Qt);
3866 /* If the LRU window is tall enough, and either eligible for 3872 /* If the LRU window is tall enough, and either eligible for
3867 splitting and selected or the only window, split it. */ 3873 splitting and selected or the only window, split it. */
3868 if (!NILP (window) 3874 if (!NILP (window)
3869 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) 3875 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3870 && ((EQ (window, selected_window) 3876 && ((EQ (window, selected_window)
3871 && window_height (window) >= split_height_threshold) 3877 && window_height (window) >= split_height_threshold)
3872 || (NILP (XWINDOW (window)->parent))) 3878 || (NILP (XWINDOW (window)->parent)))
3873 && (window_height (window) 3879 && (window_height (window)
3874 >= (2 * window_min_size_2 (XWINDOW (window), 0)))) 3880 >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3875 window = call1 (Vsplit_window_preferred_function, window); 3881 window = Fsplit_window (window, Qnil, Qnil);
3876 else 3882 else
3877 window = Fget_lru_window (frames, Qnil); 3883 window = Fget_lru_window (frames, Qnil);
3878 /* If Fget_lru_window returned nil, try other approaches. */ 3884 /* If Fget_lru_window returned nil, try other approaches. */
3879 3885
3880 /* Try visible frames first. */ 3886 /* Try visible frames first. */
7594 DEFVAR_LISP ("split-window-preferred-function", 7600 DEFVAR_LISP ("split-window-preferred-function",
7595 &Vsplit_window_preferred_function, 7601 &Vsplit_window_preferred_function,
7596 doc: /* Function to use to split a window. 7602 doc: /* Function to use to split a window.
7597 This is used by `display-buffer' to allow the user to choose whether 7603 This is used by `display-buffer' to allow the user to choose whether
7598 to split windows horizontally or vertically or some mix of the two. 7604 to split windows horizontally or vertically or some mix of the two.
7605 When this variable is nil, `display-buffer' splits windows vertically.
7606 Otherwise, `display-buffer' calls this function to split a window.
7599 It is called with a window as single argument and should split it in two 7607 It is called with a window as single argument and should split it in two
7600 and return the new window. */); 7608 and return the new window, or return an appropriate existing window
7601 Vsplit_window_preferred_function = intern ("split-window"); 7609 if splitting is not eligible. */);
7610 Vsplit_window_preferred_function = Qnil;
7602 7611
7603 DEFVAR_INT ("window-min-height", &window_min_height, 7612 DEFVAR_INT ("window-min-height", &window_min_height,
7604 doc: /* *Delete any window less than this tall (including its mode line). 7613 doc: /* *Delete any window less than this tall (including its mode line).
7605 The value is in line units. */); 7614 The value is in line units. */);
7606 window_min_height = 4; 7615 window_min_height = 4;