changeset 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 66def171a3ee
children 16d15252a9d9
files src/window.c
diffstat 1 files changed, 57 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Sat Sep 08 09:53:34 2007 +0000
+++ b/src/window.c	Sat Sep 08 10:34:03 2007 +0000
@@ -163,6 +163,13 @@
 
 Lisp_Object Veven_window_heights;
 
+/* Non-nil means that windows are split horizontally, i.e. side-by-side,
+   instead of vertically by `display-buffer'.  An integer value means that
+   windows may only be split horizontally if the newly created window is at
+   least as wide as that value.  */
+
+Lisp_Object Vprefer_window_split_horizontally;
+
 /* List of buffer *names* for buffers that should have their own frames.  */
 
 Lisp_Object Vspecial_display_buffer_names;
@@ -3653,7 +3660,12 @@
 
 If `even-window-heights' is non-nil, window heights will be evened out
 if displaying the buffer causes two vertically adjacent windows to be
-displayed.  */)
+displayed.  
+
+If `prefer-window-split-horizontally' is non-nil, windows are split
+horizontally, i.e. side-by-side, instead of vertically if possible. If the
+variable has an integer value, windows may only be split horizontally if the
+newly created window is at least as wide as that value.  */)
      (buffer, not_this_window, frame)
      Lisp_Object buffer, not_this_window, frame;
 {
@@ -3755,13 +3767,26 @@
       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 we prefer to split horizontally and the window is wide
+         enough, split it horizontally.  */
       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)))
+	  && !NILP (Vprefer_window_split_horizontally)
+	  && (!NUMBERP (Vprefer_window_split_horizontally) ||
+              (window_width(window) >=
+	       2 * XINT (Vprefer_window_split_horizontally)))
+	  && (window_width(window)) >= (2 * window_min_width))
+	{
+	  window = Fsplit_window (window, Qnil, Qt);
+	}
+      /* Else, if the largest window is tall enough, full-width, and either
+	 eligible for splitting or the only window, split it. */
+      else 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);
@@ -3770,16 +3795,27 @@
 	  Lisp_Object upper, lower, other;
 
 	  window = Fget_lru_window (frames, Qt);
-	  /* If the LRU window is tall enough, and either eligible for
-	     splitting and selected or the only window, split it.  */
+	  /* If we prefer to split horizontally and the LRU window is
+	     wide enough, split it horizontally. */
 	  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);
+	      && !NILP (Vprefer_window_split_horizontally)
+	      && window_width(window) >= (2 * window_min_width)
+	      && (!NUMBERP (Vprefer_window_split_horizontally) ||
+		  window_width(window) >=
+		  (2 * XINT (Vprefer_window_split_horizontally))))
+	    window = Fsplit_window (window, Qnil, Qt);
+	  /* Else if the LRU window is tall enough, and either
+	     eligible for splitting and selected, or the only window,
+	     split it.  */
+	  else 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 = Fsplit_window (window, Qnil, Qnil);
 	  else
 	    window = Fget_lru_window (frames, Qnil);
 	  /* If Fget_lru_window returned nil, try other approaches.  */
@@ -7354,6 +7390,14 @@
 If nil, `display-buffer' will leave the window configuration alone.  */);
   Veven_window_heights = Qt;
 
+  DEFVAR_LISP ("prefer-window-split-horizontally", &Vprefer_window_split_horizontally,
+               doc: /* *Non-nil means that windows are split horizontally, i.e. 
+side-by-side, instead
+of vertically by `display-buffer'.
+An integer value means that windows may only be split horizontally if the newly
+created window is at least as wide as that value.  */);
+  Vprefer_window_split_horizontally = Qnil;
+
   DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window,
 	       doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll.  */);
   Vminibuf_scroll_window = Qnil;