changeset 13104:ea64c261c72a

(Qwindow_scroll_functions, Vwindow_scroll_functions): New variables. (syms_of_xdisp): Initialize them. (redisplay_window): Call the functions when appropriate.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 Oct 1995 09:12:50 +0000
parents a537b52d6668
children a9efbc138c23
files src/xdisp.c
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Tue Oct 03 09:11:08 1995 +0000
+++ b/src/xdisp.c	Tue Oct 03 09:12:50 1995 +0000
@@ -49,6 +49,7 @@
 extern Lisp_Object Voverriding_local_map_menu_flag;
 
 Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
+Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
 
 /* Nonzero means print newline to stdout before next minibuffer message.  */
 
@@ -1498,13 +1499,21 @@
     {
       /* Forget any recorded base line for line number display.  */
       w->base_line_number = Qnil;
-      /* Redisplay the mode line.  Select the buffer properly for that.  */
-      if (!update_mode_line)
+      /* Redisplay the mode line.  Select the buffer properly for that.
+	 Also, run the hook window-scroll-functions
+	 because we have scrolled.  */
+      if (!update_mode_line
+	  || ! NILP (Vwindow_scroll_functions))
 	{
+	  Lisp_Object temp[3];
+
 	  set_buffer_temp (old);
 	  set_buffer_internal_1 (XBUFFER (w->buffer));
 	  update_mode_line = 1;
 	  w->update_mode_line = Qt;
+	  if (! NILP (Vwindow_scroll_functions))
+	    run_hook_with_args_2 (Qwindow_scroll_functions, window,
+				  make_number (startp));
 	}
       w->force_start = Qnil;
       XSETFASTINT (w->last_modified, 0);
@@ -1678,6 +1687,9 @@
 
       if (PT >= pos.bufpos)
 	{
+	  if (! NILP (Vwindow_scroll_functions))
+	    run_hook_with_args_2 (Qwindow_scroll_functions, window,
+				  make_number (pos.bufpos));
 	  try_window (window, pos.bufpos);
 	  if (cursor_vpos >= 0)
 	    {
@@ -1700,6 +1712,9 @@
   w->base_line_number = Qnil;
 
   pos = *vmotion (PT, - (height / 2), w);
+  if (! NILP (Vwindow_scroll_functions))
+    run_hook_with_args_2 (Qwindow_scroll_functions, window,
+			  make_number (pos.bufpos));
   try_window (window, pos.bufpos);
 
   startp = marker_position (w->start);
@@ -4185,6 +4200,9 @@
   staticpro (&Qoverriding_local_map);
   Qoverriding_local_map = intern ("overriding-local-map");
 
+  staticpro (&Qwindow_scroll_functions);
+  Qwindow_scroll_functions = intern ("window-scroll-functions");
+
   staticpro (&last_arrow_position);
   staticpro (&last_arrow_string);
   last_arrow_position = Qnil;
@@ -4270,6 +4288,12 @@
 size since the last redisplay, or have been split or deleted,\n\
 all the functions in the list are called, with the frame as argument.");
   Vwindow_size_change_functions = Qnil;
+
+  DEFVAR_LISP ("window-scroll-functions", &Vwindow_scroll_functions,
+    "Functions to call when a window is redisplayed with scrolling.\n\
+Each function is called with two arguments, the window\n\
+and its new display-start position.");
+  Vwindow_scroll_functions = Qnil;
 }
 
 /* initialize the window system */