changeset 17281:4f3c71b28278

(Qwindow_configuration_change_hook): New variable. (Vwindow_configuration_change_hook): New variable. (syms_of_window): Initialize; set up Lisp var. (delete_window): New subroutine, from Fdelete_window. Most callers changed. (Fdelete_window): Call Vwindow_configuration_change_functions. (Fset_window_buffer, Fenlarge_window, Fshrink_window): Call the Vwindow_configuration_change_functions. (Fset_window_configuration): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Wed, 02 Apr 1997 03:44:32 +0000
parents 96762d1abb7c
children 5023bea28298
files src/window.c
diffstat 1 files changed, 48 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Tue Apr 01 23:38:01 1997 +0000
+++ b/src/window.c	Wed Apr 02 03:44:32 1997 +0000
@@ -111,6 +111,10 @@
 /* Nonzero after init_window_once has finished.  */
 static int window_initialized;
 
+/* Hook to run when window config changes.  */
+Lisp_Object Qwindow_configuration_change_hook;
+Lisp_Object Vwindow_configuration_change_hook;
+
 /* Nonzero means scroll commands try to put point
    at the same screen height as previously.  */
 static int scroll_preserve_screen_position;
@@ -786,6 +790,18 @@
   (window)
      register Lisp_Object window;
 {
+  delete_window (window);
+
+  if (! NILP (Vwindow_configuration_change_hook)
+      && ! NILP (Vrun_hooks))
+    call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
+  return Qnil;
+}
+
+delete_window (window)
+     register Lisp_Object window;
+{
   register Lisp_Object tem, parent, sib;
   register struct window *p;
   register struct window *par;
@@ -910,8 +926,6 @@
 
   /* Mark this window as deleted.  */
   p->buffer = p->hchild = p->vchild = Qnil;
-
-  return Qnil;
 }
 
 
@@ -1719,7 +1733,7 @@
       && ! NILP (w->parent)
       && height < window_min_height)
     {
-      Fdelete_window (window);
+      delete_window (window);
       return;
     }
 
@@ -1783,7 +1797,7 @@
 
   if (!nodelete && width < window_min_width && !NILP (w->parent))
     {
-      Fdelete_window (window);
+      delete_window (window);
       return;
     }
 
@@ -1910,6 +1924,10 @@
     run_hook_with_args_2 (Qwindow_scroll_functions, window,
 			  Fmarker_position (w->start));
 
+  if (! NILP (Vwindow_configuration_change_hook)
+      && ! NILP (Vrun_hooks))
+    call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
   unbind_to (count, Qnil);
 
   return Qnil;
@@ -2420,8 +2438,6 @@
   p->parent = o->parent;
   p->buffer = Qt;
 
-  Fset_window_buffer (new, o->buffer);
-
   /* Apportion the available frame space among the two new windows */
 
   if (!NILP (horflag))
@@ -2441,6 +2457,8 @@
       XSETFASTINT (p->top, XFASTINT (o->top) + size_int);
     }
 
+  Fset_window_buffer (new, o->buffer);
+
   return new;
 }
 
@@ -2452,6 +2470,10 @@
 {
   CHECK_NUMBER (arg, 0);
   change_window_height (XINT (arg), !NILP (side));
+
+  if (! NILP (Vwindow_configuration_change_hook))
+    call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
   return Qnil;
 }
 
@@ -2463,6 +2485,10 @@
 {
   CHECK_NUMBER (arg, 0);
   change_window_height (-XINT (arg), !NILP (side));
+
+  if (! NILP (Vwindow_configuration_change_hook))
+    call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
   return Qnil;
 }
 
@@ -2552,7 +2578,7 @@
 
   if (*sizep + delta < MINSIZE (window))
     {
-      Fdelete_window (window);
+      delete_window (window);
       return;
     }
 
@@ -3377,6 +3403,11 @@
     Fset_buffer (new_current_buffer);
 
   Vminibuf_scroll_window = data->minibuf_scroll_window;
+
+  if (! NILP (Vwindow_configuration_change_hook)
+      && ! NILP (Vrun_hooks))
+    call1 (Vrun_hooks, Qwindow_configuration_change_hook);
+
   return (Qnil);
 }
 
@@ -3583,6 +3614,10 @@
 
 syms_of_window ()
 {
+  staticpro (&Qwindow_configuration_change_hook);
+  Qwindow_configuration_change_hook
+    = intern ("window-configuration-change-hook");
+
   Qwindowp = intern ("windowp");
   staticpro (&Qwindowp);
 
@@ -3722,6 +3757,12 @@
     "*Nonzero means scroll commands move point to keep its screen line unchanged.");
   scroll_preserve_screen_position = 0;
 
+  DEFVAR_LISP ("window-configuration-change-hook",
+	       &Vwindow_configuration_change_hook,
+    "Functions to call when window configuration changes.\n\
+The selected frae is the one whose configuration has changed.");
+  Vwindow_configuration_change_hook = Qnil;
+
   defsubr (&Sselected_window);
   defsubr (&Sminibuffer_window);
   defsubr (&Swindow_minibuffer_p);