changeset 16527:2337ed73b33e

(scroll_conservatively): New variable. (redisplay_window): Obey it. (syms_of_xdisp): Set up Lisp var.
author Richard M. Stallman <rms@gnu.org>
date Wed, 06 Nov 1996 23:26:02 +0000
parents f34bfb5aa684
children 62be63ee468d
files src/xdisp.c
diffstat 1 files changed, 76 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Wed Nov 06 22:52:06 1996 +0000
+++ b/src/xdisp.c	Wed Nov 06 23:26:02 1996 +0000
@@ -139,6 +139,10 @@
    Try scrolling this many lines up or down if that will bring it back.  */
 static int scroll_step;
 
+/* Non-0 means scroll just far enough to bring point back on the screen,
+   when appropriate.  */
+static int scroll_conservatively;
+
 /* Nonzero if try_window_id has made blank lines at window bottom
  since the last redisplay that paused */
 static int blank_end_of_window;
@@ -1778,6 +1782,74 @@
 
   /* Try to scroll by specified few lines */
 
+  if (scroll_conservatively && !current_buffer->clip_changed
+      && startp >= BEGV && startp <= ZV)
+    {
+      if (PT >= Z - XFASTINT (w->window_end_pos))
+	{
+	  struct position pos;
+	  pos = *compute_motion (Z - XFASTINT (w->window_end_pos), 0, 0, 0,
+				 PT, XFASTINT (w->height), 0,
+				 XFASTINT (w->width), XFASTINT (w->hscroll),
+				 pos_tab_offset (w, startp), w);
+	  if (pos.vpos > scroll_conservatively)
+	    goto scroll_fail_1;
+
+	  pos = *vmotion (startp, pos.vpos + 1, w);
+
+	  if (! NILP (Vwindow_scroll_functions))
+	    {
+	      Fset_marker (w->start, make_number (pos.bufpos), Qnil);
+	      run_hook_with_args_2 (Qwindow_scroll_functions, window,
+				    make_number (pos.bufpos));
+	      pos.bufpos = marker_position (w->start);
+	    }
+	  try_window (window, pos.bufpos);
+	  if (cursor_vpos >= 0)
+	    {
+	      if (!just_this_one || current_buffer->clip_changed
+		  || beg_unchanged < startp)
+		/* Forget any recorded base line for line number display.  */
+		w->base_line_number = Qnil;
+	      goto done;
+	    }
+	  else
+	    cancel_my_columns (w);
+	}
+      if (PT < startp)
+	{
+	  struct position pos;
+	  pos = *compute_motion (PT, 0, 0, 0,
+				 startp, XFASTINT (w->height), 0,
+				 XFASTINT (w->width), XFASTINT (w->hscroll),
+				 pos_tab_offset (w, startp), w);
+	  if (pos.vpos >= scroll_conservatively)
+	    goto scroll_fail_1;
+
+	  pos = *vmotion (startp, - pos.vpos, w);
+
+	  if (! NILP (Vwindow_scroll_functions))
+	    {
+	      Fset_marker (w->start, make_number (pos.bufpos), Qnil);
+	      run_hook_with_args_2 (Qwindow_scroll_functions, window,
+				    make_number (pos.bufpos));
+	      pos.bufpos = marker_position (w->start);
+	    }
+	  try_window (window, pos.bufpos);
+	  if (cursor_vpos >= 0)
+	    {
+	      if (!just_this_one || current_buffer->clip_changed
+		  || beg_unchanged < startp)
+		/* Forget any recorded base line for line number display.  */
+		w->base_line_number = Qnil;
+	      goto done;
+	    }
+	  else
+	    cancel_my_columns (w);
+	}
+    scroll_fail_1: ;
+    }
+
   if (scroll_step && !current_buffer->clip_changed
       && startp >= BEGV && startp <= ZV)
     {
@@ -4377,6 +4449,10 @@
 If that fails to bring point back on frame, point is centered instead.\n\
 If this is zero, point is always centered after it moves off frame.");
 
+  DEFVAR_INT ("scroll-conservatively", &scroll_conservatively,
+    "*Scroll up to this many lines, to bring point back on screen.");
+  scroll_conservatively = 0;
+
   DEFVAR_INT ("debug-end-pos", &debug_end_pos, "Don't ask");
 
   DEFVAR_BOOL ("truncate-partial-width-windows",