comparison src/window.c @ 84357:7a92dcd56a24

(Vsplit_window_preferred_function): New var. (Fdisplay_buffer): Use it. (syms_of_window): Export, and initialize it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 07 Sep 2007 03:26:06 +0000
parents 5b644ae74c91
children 584ae8393da8
comparison
equal deleted inserted replaced
84356:357b5ff720d4 84357:7a92dcd56a24
189 189
190 /* Fdisplay_buffer always splits the largest window 190 /* Fdisplay_buffer always splits the largest window
191 if that window is more than this high. */ 191 if that window is more than this high. */
192 192
193 EMACS_INT split_height_threshold; 193 EMACS_INT split_height_threshold;
194
195 /* How to split windows (horizontally/vertically/hybrid). */
196
197 Lisp_Object Vsplit_window_preferred_function;
194 198
195 /* Number of lines of continuity in scrolling by screenfuls. */ 199 /* Number of lines of continuity in scrolling by screenfuls. */
196 200
197 EMACS_INT next_screen_context_lines; 201 EMACS_INT next_screen_context_lines;
198 202
3721 /* If the current frame is a special display frame, 3725 /* If the current frame is a special display frame,
3722 don't try to reuse its windows. */ 3726 don't try to reuse its windows. */
3723 || !NILP (XWINDOW (FRAME_ROOT_WINDOW (f))->dedicated)) 3727 || !NILP (XWINDOW (FRAME_ROOT_WINDOW (f))->dedicated))
3724 { 3728 {
3725 Lisp_Object frames; 3729 Lisp_Object frames;
3730 struct gcpro gcpro1;
3731 GCPRO1 (buffer);
3726 3732
3727 frames = Qnil; 3733 frames = Qnil;
3728 if (FRAME_MINIBUF_ONLY_P (f)) 3734 if (FRAME_MINIBUF_ONLY_P (f))
3729 XSETFRAME (frames, last_nonminibuf_frame); 3735 XSETFRAME (frames, last_nonminibuf_frame);
3730 3736
3756 && WINDOW_FULL_WIDTH_P (XWINDOW (window)) 3762 && WINDOW_FULL_WIDTH_P (XWINDOW (window))
3757 && (window_height (window) >= split_height_threshold 3763 && (window_height (window) >= split_height_threshold
3758 || (NILP (XWINDOW (window)->parent))) 3764 || (NILP (XWINDOW (window)->parent)))
3759 && (window_height (window) 3765 && (window_height (window)
3760 >= (2 * window_min_size_2 (XWINDOW (window), 0)))) 3766 >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3761 window = Fsplit_window (window, Qnil, Qnil); 3767 window = call1 (Vsplit_window_preferred_function, window);
3762 else 3768 else
3763 { 3769 {
3764 Lisp_Object upper, lower, other; 3770 Lisp_Object upper, lower, other;
3765 3771
3766 window = Fget_lru_window (frames, Qt); 3772 window = Fget_lru_window (frames, Qt);
3767 /* If the LRU window is tall enough, and either eligible for splitting 3773 /* If the LRU window is tall enough, and either eligible for
3768 and selected or the only window, split it. */ 3774 splitting and selected or the only window, split it. */
3769 if (!NILP (window) 3775 if (!NILP (window)
3770 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) 3776 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3771 && ((EQ (window, selected_window) 3777 && ((EQ (window, selected_window)
3772 && window_height (window) >= split_height_threshold) 3778 && window_height (window) >= split_height_threshold)
3773 || (NILP (XWINDOW (window)->parent))) 3779 || (NILP (XWINDOW (window)->parent)))
3774 && (window_height (window) 3780 && (window_height (window)
3775 >= (2 * window_min_size_2 (XWINDOW (window), 0)))) 3781 >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3776 window = Fsplit_window (window, Qnil, Qnil); 3782 window = call1 (Vsplit_window_preferred_function, window);
3777 else 3783 else
3778 window = Fget_lru_window (frames, Qnil); 3784 window = Fget_lru_window (frames, Qnil);
3779 /* If Fget_lru_window returned nil, try other approaches. */ 3785 /* If Fget_lru_window returned nil, try other approaches. */
3780 3786
3781 /* Try visible frames first. */ 3787 /* Try visible frames first. */
3817 enlarge_window (upper, 3823 enlarge_window (upper,
3818 total / 2 - XFASTINT (XWINDOW (upper)->total_lines), 3824 total / 2 - XFASTINT (XWINDOW (upper)->total_lines),
3819 0); 3825 0);
3820 } 3826 }
3821 } 3827 }
3828 UNGCPRO;
3822 } 3829 }
3823 else 3830 else
3824 window = Fget_lru_window (Qnil, Qnil); 3831 window = Fget_lru_window (Qnil, Qnil);
3825 3832
3826 Fset_window_buffer (window, buffer, Qnil); 3833 Fset_window_buffer (window, buffer, Qnil);
7487 DEFVAR_INT ("split-height-threshold", &split_height_threshold, 7494 DEFVAR_INT ("split-height-threshold", &split_height_threshold,
7488 doc: /* *A window must be at least this tall to be eligible for splitting 7495 doc: /* *A window must be at least this tall to be eligible for splitting
7489 by `display-buffer'. The value is in line units. 7496 by `display-buffer'. The value is in line units.
7490 If there is only one window, it is split regardless of this value. */); 7497 If there is only one window, it is split regardless of this value. */);
7491 split_height_threshold = 500; 7498 split_height_threshold = 500;
7499
7500 DEFVAR_LISP ("split-window-preferred-function",
7501 &Vsplit_window_preferred_function,
7502 doc: /* Function to use to split a window.
7503 This is used by `display-buffer' to allow the user to choose whether
7504 to split windows horizontally or vertically or some mix of the two.
7505 It is called with a window as single argument and should split it in two
7506 and return the new window. */);
7507 Vsplit_window_preferred_function = intern ("split-window");
7492 7508
7493 DEFVAR_INT ("window-min-height", &window_min_height, 7509 DEFVAR_INT ("window-min-height", &window_min_height,
7494 doc: /* *Delete any window less than this tall (including its mode line). 7510 doc: /* *Delete any window less than this tall (including its mode line).
7495 The value is in line units. */); 7511 The value is in line units. */);
7496 window_min_height = 4; 7512 window_min_height = 4;