changeset 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 357b5ff720d4
children d2cda61c7c00
files etc/NEWS src/ChangeLog src/window.c
diffstat 3 files changed, 33 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS	Fri Sep 07 02:53:10 2007 +0000
+++ b/etc/NEWS	Fri Sep 07 03:26:06 2007 +0000
@@ -34,6 +34,9 @@
 
 * Changes in Emacs 23.1
 
+** split-window-preferred-function specifies whether display-buffer should
+split windows vertically or horizontally.
+
 ** Support for multiple terminal devices and simultaneous graphical
 and tty frames has been added.  You can test for the presence of this
 feature in your Lisp code by testing for the `multi-tty' feature.
@@ -263,9 +266,10 @@
 relevant to a specific terminal device.
 
 
-** The function invisible-p returns non-nil if the character
-   after a specified position is invisible, or if its argument
-   as an `invisible' property would make a character invisible.
+** You can now also pass the value of the `invisible' property to invisible-p
+to check whether it would cause the text to be invisible.  Convenient when
+checking invisibility of text which has no buffer position
+(e.g. in before/after-strings).
 
 ** Non-breaking space now acts as whitespace.
 
--- a/src/ChangeLog	Fri Sep 07 02:53:10 2007 +0000
+++ b/src/ChangeLog	Fri Sep 07 03:26:06 2007 +0000
@@ -1,3 +1,9 @@
+2007-09-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* window.c (Vsplit_window_preferred_function): New var.
+	(Fdisplay_buffer): Use it.
+	(syms_of_window): Export, and initialize it.
+
 2007-09-06  Pixel  <pixel@mandriva.com>  (tiny change)
 
 	* image.c (gif_load): Fix bug: Handle nonexistent colormap.
--- a/src/window.c	Fri Sep 07 02:53:10 2007 +0000
+++ b/src/window.c	Fri Sep 07 03:26:06 2007 +0000
@@ -192,6 +192,10 @@
 
 EMACS_INT split_height_threshold;
 
+/* How to split windows (horizontally/vertically/hybrid).  */
+
+Lisp_Object Vsplit_window_preferred_function;
+
 /* Number of lines of continuity in scrolling by screenfuls.  */
 
 EMACS_INT next_screen_context_lines;
@@ -3723,6 +3727,8 @@
       || !NILP (XWINDOW (FRAME_ROOT_WINDOW (f))->dedicated))
     {
       Lisp_Object frames;
+      struct gcpro gcpro1;
+      GCPRO1 (buffer);
 
       frames = Qnil;
       if (FRAME_MINIBUF_ONLY_P (f))
@@ -3758,14 +3764,14 @@
 	      || (NILP (XWINDOW (window)->parent)))
 	  && (window_height (window)
 	      >= (2 * window_min_size_2 (XWINDOW (window), 0))))
-	window = Fsplit_window (window, Qnil, Qnil);
+	window = call1 (Vsplit_window_preferred_function, window);
       else
 	{
 	  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 the LRU window is tall enough, and either eligible for
+	     splitting and selected or the only window, split it.  */
 	  if (!NILP (window)
 	      && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
 	      && ((EQ (window, selected_window)
@@ -3773,7 +3779,7 @@
 		  || (NILP (XWINDOW (window)->parent)))
 	      && (window_height (window)
 		  >= (2 * window_min_size_2 (XWINDOW (window), 0))))
-	    window = Fsplit_window (window, Qnil, Qnil);
+	    window = call1 (Vsplit_window_preferred_function, window);
 	  else
 	    window = Fget_lru_window (frames, Qnil);
 	  /* If Fget_lru_window returned nil, try other approaches.  */
@@ -3819,6 +3825,7 @@
 			      0);
 	    }
 	}
+      UNGCPRO;
     }
   else
     window = Fget_lru_window (Qnil, Qnil);
@@ -7490,6 +7497,15 @@
 If there is only one window, it is split regardless of this value.  */);
   split_height_threshold = 500;
 
+  DEFVAR_LISP ("split-window-preferred-function",
+	       &Vsplit_window_preferred_function,
+	       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.
+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");
+
   DEFVAR_INT ("window-min-height", &window_min_height,
 	      doc: /* *Delete any window less than this tall (including its mode line).
 The value is in line units. */);