# HG changeset patch # User Juri Linkov # Date 1206831896 0 # Node ID da5b46bdd92cebae4b450fc3e5681cd59c1ee213 # Parent 2428ecdc8ca0b1a7cec40ff68ec82f5c8a6ea309 (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) : Change the default value from `split-window' to nil. diff -r 2428ecdc8ca0 -r da5b46bdd92c src/window.c --- a/src/window.c Sat Mar 29 23:04:17 2008 +0000 +++ b/src/window.c Sat Mar 29 23:04:56 2008 +0000 @@ -3848,16 +3848,22 @@ else window = Fget_largest_window (frames, Qt); - /* If the largest window is tall enough, full-width, and either eligible - for splitting or the only window, split it. */ - if (!NILP (window) - && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) - && WINDOW_FULL_WIDTH_P (XWINDOW (window)) - && (window_height (window) >= split_height_threshold - || (NILP (XWINDOW (window)->parent))) - && (window_height (window) - >= (2 * window_min_size_2 (XWINDOW (window), 0)))) - window = call1 (Vsplit_window_preferred_function, window); + 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) + && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) + && WINDOW_FULL_WIDTH_P (XWINDOW (window)) + && (window_height (window) >= split_height_threshold + || (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; @@ -3867,12 +3873,12 @@ splitting and selected or the only window, split it. */ if (!NILP (window) && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) - && ((EQ (window, selected_window) - && window_height (window) >= split_height_threshold) - || (NILP (XWINDOW (window)->parent))) - && (window_height (window) - >= (2 * window_min_size_2 (XWINDOW (window), 0)))) - window = call1 (Vsplit_window_preferred_function, window); + && ((EQ (window, selected_window) + && window_height (window) >= split_height_threshold) + || (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. */ @@ -7596,9 +7602,12 @@ doc: /* Function to use to split a window. This is used by `display-buffer' to allow the user to choose whether to split windows horizontally or vertically or some mix of the two. +When this variable is nil, `display-buffer' splits windows vertically. +Otherwise, `display-buffer' calls this function to split a window. 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"); +and return the new window, or return an appropriate existing window +if splitting is not eligible. */); + 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).