aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/window.c55
1 files changed, 48 insertions, 7 deletions
diff --git a/src/window.c b/src/window.c
index 2112a1d357a..97a6c860598 100644
--- a/src/window.c
+++ b/src/window.c
@@ -111,6 +111,10 @@ static int sequence_number;
111/* Nonzero after init_window_once has finished. */ 111/* Nonzero after init_window_once has finished. */
112static int window_initialized; 112static int window_initialized;
113 113
114/* Hook to run when window config changes. */
115Lisp_Object Qwindow_configuration_change_hook;
116Lisp_Object Vwindow_configuration_change_hook;
117
114/* Nonzero means scroll commands try to put point 118/* Nonzero means scroll commands try to put point
115 at the same screen height as previously. */ 119 at the same screen height as previously. */
116static int scroll_preserve_screen_position; 120static int scroll_preserve_screen_position;
@@ -786,6 +790,18 @@ DEFUN ("delete-window", Fdelete_window, Sdelete_window, 0, 1, "",
786 (window) 790 (window)
787 register Lisp_Object window; 791 register Lisp_Object window;
788{ 792{
793 delete_window (window);
794
795 if (! NILP (Vwindow_configuration_change_hook)
796 && ! NILP (Vrun_hooks))
797 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
798
799 return Qnil;
800}
801
802delete_window (window)
803 register Lisp_Object window;
804{
789 register Lisp_Object tem, parent, sib; 805 register Lisp_Object tem, parent, sib;
790 register struct window *p; 806 register struct window *p;
791 register struct window *par; 807 register struct window *par;
@@ -910,8 +926,6 @@ DEFUN ("delete-window", Fdelete_window, Sdelete_window, 0, 1, "",
910 926
911 /* Mark this window as deleted. */ 927 /* Mark this window as deleted. */
912 p->buffer = p->hchild = p->vchild = Qnil; 928 p->buffer = p->hchild = p->vchild = Qnil;
913
914 return Qnil;
915} 929}
916 930
917 931
@@ -1719,7 +1733,7 @@ set_window_height (window, height, nodelete)
1719 && ! NILP (w->parent) 1733 && ! NILP (w->parent)
1720 && height < window_min_height) 1734 && height < window_min_height)
1721 { 1735 {
1722 Fdelete_window (window); 1736 delete_window (window);
1723 return; 1737 return;
1724 } 1738 }
1725 1739
@@ -1783,7 +1797,7 @@ set_window_width (window, width, nodelete)
1783 1797
1784 if (!nodelete && width < window_min_width && !NILP (w->parent)) 1798 if (!nodelete && width < window_min_width && !NILP (w->parent))
1785 { 1799 {
1786 Fdelete_window (window); 1800 delete_window (window);
1787 return; 1801 return;
1788 } 1802 }
1789 1803
@@ -1910,6 +1924,10 @@ BUFFER can be a buffer or buffer name.")
1910 run_hook_with_args_2 (Qwindow_scroll_functions, window, 1924 run_hook_with_args_2 (Qwindow_scroll_functions, window,
1911 Fmarker_position (w->start)); 1925 Fmarker_position (w->start));
1912 1926
1927 if (! NILP (Vwindow_configuration_change_hook)
1928 && ! NILP (Vrun_hooks))
1929 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
1930
1913 unbind_to (count, Qnil); 1931 unbind_to (count, Qnil);
1914 1932
1915 return Qnil; 1933 return Qnil;
@@ -2420,8 +2438,6 @@ and put SIZE columns in the first of the pair.")
2420 p->parent = o->parent; 2438 p->parent = o->parent;
2421 p->buffer = Qt; 2439 p->buffer = Qt;
2422 2440
2423 Fset_window_buffer (new, o->buffer);
2424
2425 /* Apportion the available frame space among the two new windows */ 2441 /* Apportion the available frame space among the two new windows */
2426 2442
2427 if (!NILP (horflag)) 2443 if (!NILP (horflag))
@@ -2441,6 +2457,8 @@ and put SIZE columns in the first of the pair.")
2441 XSETFASTINT (p->top, XFASTINT (o->top) + size_int); 2457 XSETFASTINT (p->top, XFASTINT (o->top) + size_int);
2442 } 2458 }
2443 2459
2460 Fset_window_buffer (new, o->buffer);
2461
2444 return new; 2462 return new;
2445} 2463}
2446 2464
@@ -2452,6 +2470,10 @@ From program, optional second arg non-nil means grow sideways ARG columns.")
2452{ 2470{
2453 CHECK_NUMBER (arg, 0); 2471 CHECK_NUMBER (arg, 0);
2454 change_window_height (XINT (arg), !NILP (side)); 2472 change_window_height (XINT (arg), !NILP (side));
2473
2474 if (! NILP (Vwindow_configuration_change_hook))
2475 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
2476
2455 return Qnil; 2477 return Qnil;
2456} 2478}
2457 2479
@@ -2463,6 +2485,10 @@ From program, optional second arg non-nil means shrink sideways arg columns.")
2463{ 2485{
2464 CHECK_NUMBER (arg, 0); 2486 CHECK_NUMBER (arg, 0);
2465 change_window_height (-XINT (arg), !NILP (side)); 2487 change_window_height (-XINT (arg), !NILP (side));
2488
2489 if (! NILP (Vwindow_configuration_change_hook))
2490 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
2491
2466 return Qnil; 2492 return Qnil;
2467} 2493}
2468 2494
@@ -2552,7 +2578,7 @@ change_window_height (delta, widthflag)
2552 2578
2553 if (*sizep + delta < MINSIZE (window)) 2579 if (*sizep + delta < MINSIZE (window))
2554 { 2580 {
2555 Fdelete_window (window); 2581 delete_window (window);
2556 return; 2582 return;
2557 } 2583 }
2558 2584
@@ -3377,6 +3403,11 @@ by `current-window-configuration' (which see).")
3377 Fset_buffer (new_current_buffer); 3403 Fset_buffer (new_current_buffer);
3378 3404
3379 Vminibuf_scroll_window = data->minibuf_scroll_window; 3405 Vminibuf_scroll_window = data->minibuf_scroll_window;
3406
3407 if (! NILP (Vwindow_configuration_change_hook)
3408 && ! NILP (Vrun_hooks))
3409 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
3410
3380 return (Qnil); 3411 return (Qnil);
3381} 3412}
3382 3413
@@ -3583,6 +3614,10 @@ init_window_once ()
3583 3614
3584syms_of_window () 3615syms_of_window ()
3585{ 3616{
3617 staticpro (&Qwindow_configuration_change_hook);
3618 Qwindow_configuration_change_hook
3619 = intern ("window-configuration-change-hook");
3620
3586 Qwindowp = intern ("windowp"); 3621 Qwindowp = intern ("windowp");
3587 staticpro (&Qwindowp); 3622 staticpro (&Qwindowp);
3588 3623
@@ -3722,6 +3757,12 @@ If there is only one window, it is split regardless of this value.");
3722 "*Nonzero means scroll commands move point to keep its screen line unchanged."); 3757 "*Nonzero means scroll commands move point to keep its screen line unchanged.");
3723 scroll_preserve_screen_position = 0; 3758 scroll_preserve_screen_position = 0;
3724 3759
3760 DEFVAR_LISP ("window-configuration-change-hook",
3761 &Vwindow_configuration_change_hook,
3762 "Functions to call when window configuration changes.\n\
3763The selected frae is the one whose configuration has changed.");
3764 Vwindow_configuration_change_hook = Qnil;
3765
3725 defsubr (&Sselected_window); 3766 defsubr (&Sselected_window);
3726 defsubr (&Sminibuffer_window); 3767 defsubr (&Sminibuffer_window);
3727 defsubr (&Swindow_minibuffer_p); 3768 defsubr (&Swindow_minibuffer_p);