comparison src/window.c @ 84400:076336b0f3c6

(prefer_window_split_horizontally): New variable. (display_buffer): Consider splitting window horizontally depending on prefer_window_split_horizontally.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 08 Sep 2007 10:34:03 +0000
parents 6c8a27754af8
children 8bd423438456
comparison
equal deleted inserted replaced
84399:66def171a3ee 84400:076336b0f3c6
160 Lisp_Object Vdisplay_buffer_function; 160 Lisp_Object Vdisplay_buffer_function;
161 161
162 /* Non-nil means that Fdisplay_buffer should even the heights of windows. */ 162 /* Non-nil means that Fdisplay_buffer should even the heights of windows. */
163 163
164 Lisp_Object Veven_window_heights; 164 Lisp_Object Veven_window_heights;
165
166 /* Non-nil means that windows are split horizontally, i.e. side-by-side,
167 instead of vertically by `display-buffer'. An integer value means that
168 windows may only be split horizontally if the newly created window is at
169 least as wide as that value. */
170
171 Lisp_Object Vprefer_window_split_horizontally;
165 172
166 /* List of buffer *names* for buffers that should have their own frames. */ 173 /* List of buffer *names* for buffers that should have their own frames. */
167 174
168 Lisp_Object Vspecial_display_buffer_names; 175 Lisp_Object Vspecial_display_buffer_names;
169 176
3651 the buffer, it may be split, subject to the value of the variable 3658 the buffer, it may be split, subject to the value of the variable
3652 `split-height-threshold'. 3659 `split-height-threshold'.
3653 3660
3654 If `even-window-heights' is non-nil, window heights will be evened out 3661 If `even-window-heights' is non-nil, window heights will be evened out
3655 if displaying the buffer causes two vertically adjacent windows to be 3662 if displaying the buffer causes two vertically adjacent windows to be
3656 displayed. */) 3663 displayed.
3664
3665 If `prefer-window-split-horizontally' is non-nil, windows are split
3666 horizontally, i.e. side-by-side, instead of vertically if possible. If the
3667 variable has an integer value, windows may only be split horizontally if the
3668 newly created window is at least as wide as that value. */)
3657 (buffer, not_this_window, frame) 3669 (buffer, not_this_window, frame)
3658 Lisp_Object buffer, not_this_window, frame; 3670 Lisp_Object buffer, not_this_window, frame;
3659 { 3671 {
3660 register Lisp_Object window, tem, swp; 3672 register Lisp_Object window, tem, swp;
3661 struct frame *f; 3673 struct frame *f;
3753 #endif 3765 #endif
3754 } 3766 }
3755 else 3767 else
3756 window = Fget_largest_window (frames, Qt); 3768 window = Fget_largest_window (frames, Qt);
3757 3769
3758 /* If the largest window is tall enough, full-width, and either eligible 3770 /* If we prefer to split horizontally and the window is wide
3759 for splitting or the only window, split it. */ 3771 enough, split it horizontally. */
3760 if (!NILP (window) 3772 if (!NILP (window)
3761 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) 3773 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3762 && WINDOW_FULL_WIDTH_P (XWINDOW (window)) 3774 && WINDOW_FULL_WIDTH_P (XWINDOW (window))
3763 && (window_height (window) >= split_height_threshold 3775 && !NILP (Vprefer_window_split_horizontally)
3764 || (NILP (XWINDOW (window)->parent))) 3776 && (!NUMBERP (Vprefer_window_split_horizontally) ||
3777 (window_width(window) >=
3778 2 * XINT (Vprefer_window_split_horizontally)))
3779 && (window_width(window)) >= (2 * window_min_width))
3780 {
3781 window = Fsplit_window (window, Qnil, Qt);
3782 }
3783 /* Else, if the largest window is tall enough, full-width, and either
3784 eligible for splitting or the only window, split it. */
3785 else if (!NILP (window)
3786 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3787 && WINDOW_FULL_WIDTH_P (XWINDOW (window))
3788 && (window_height (window) >= split_height_threshold
3789 || (NILP (XWINDOW (window)->parent)))
3765 && (window_height (window) 3790 && (window_height (window)
3766 >= (2 * window_min_size_2 (XWINDOW (window), 0)))) 3791 >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3767 window = call1 (Vsplit_window_preferred_function, window); 3792 window = call1 (Vsplit_window_preferred_function, window);
3768 else 3793 else
3769 { 3794 {
3770 Lisp_Object upper, lower, other; 3795 Lisp_Object upper, lower, other;
3771 3796
3772 window = Fget_lru_window (frames, Qt); 3797 window = Fget_lru_window (frames, Qt);
3773 /* If the LRU window is tall enough, and either eligible for 3798 /* If we prefer to split horizontally and the LRU window is
3774 splitting and selected or the only window, split it. */ 3799 wide enough, split it horizontally. */
3775 if (!NILP (window) 3800 if (!NILP (window)
3776 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) 3801 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3777 && ((EQ (window, selected_window) 3802 && !NILP (Vprefer_window_split_horizontally)
3778 && window_height (window) >= split_height_threshold) 3803 && window_width(window) >= (2 * window_min_width)
3779 || (NILP (XWINDOW (window)->parent))) 3804 && (!NUMBERP (Vprefer_window_split_horizontally) ||
3780 && (window_height (window) 3805 window_width(window) >=
3781 >= (2 * window_min_size_2 (XWINDOW (window), 0)))) 3806 (2 * XINT (Vprefer_window_split_horizontally))))
3782 window = call1 (Vsplit_window_preferred_function, window); 3807 window = Fsplit_window (window, Qnil, Qt);
3808 /* Else if the LRU window is tall enough, and either
3809 eligible for splitting and selected, or the only window,
3810 split it. */
3811 else if (!NILP (window)
3812 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3813 && ((EQ (window, selected_window)
3814 && window_height (window) >= split_height_threshold)
3815 || (NILP (XWINDOW (window)->parent)))
3816 && (window_height (window)
3817 >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3818 window = Fsplit_window (window, Qnil, Qnil);
3783 else 3819 else
3784 window = Fget_lru_window (frames, Qnil); 3820 window = Fget_lru_window (frames, Qnil);
3785 /* If Fget_lru_window returned nil, try other approaches. */ 3821 /* If Fget_lru_window returned nil, try other approaches. */
3786 3822
3787 /* Try visible frames first. */ 3823 /* Try visible frames first. */
7351 7387
7352 DEFVAR_LISP ("even-window-heights", &Veven_window_heights, 7388 DEFVAR_LISP ("even-window-heights", &Veven_window_heights,
7353 doc: /* *If non-nil, `display-buffer' should even the window heights. 7389 doc: /* *If non-nil, `display-buffer' should even the window heights.
7354 If nil, `display-buffer' will leave the window configuration alone. */); 7390 If nil, `display-buffer' will leave the window configuration alone. */);
7355 Veven_window_heights = Qt; 7391 Veven_window_heights = Qt;
7392
7393 DEFVAR_LISP ("prefer-window-split-horizontally", &Vprefer_window_split_horizontally,
7394 doc: /* *Non-nil means that windows are split horizontally, i.e.
7395 side-by-side, instead
7396 of vertically by `display-buffer'.
7397 An integer value means that windows may only be split horizontally if the newly
7398 created window is at least as wide as that value. */);
7399 Vprefer_window_split_horizontally = Qnil;
7356 7400
7357 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window, 7401 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window,
7358 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */); 7402 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */);
7359 Vminibuf_scroll_window = Qnil; 7403 Vminibuf_scroll_window = Qnil;
7360 7404