(Vsplit_window_preferred_function): New var.
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Sep 2007 03:26:06 +0000 (03:26 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Sep 2007 03:26:06 +0000 (03:26 +0000)
(Fdisplay_buffer): Use it.
(syms_of_window): Export, and initialize it.

etc/NEWS
src/ChangeLog
src/window.c

index bd14758..a3250b1 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -34,6 +34,9 @@ a GIF library.
 \f
 * 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 @@ global keymaps to set up translations and function key sequences
 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.
 
index 86d84bb..7fc05c4 100644 (file)
@@ -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.
index 3db1802..2b33bf5 100644 (file)
@@ -192,6 +192,10 @@ Lisp_Object Qtemp_buffer_show_hook;
 
 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 @@ displayed.  */)
       || !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 @@ displayed.  */)
              || (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 @@ displayed.  */)
                  || (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 @@ displayed.  */)
                              0);
            }
        }
+      UNGCPRO;
     }
   else
     window = Fget_lru_window (Qnil, Qnil);
@@ -7490,6 +7497,15 @@ by `display-buffer'.  The value is in line units.
 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. */);