changeset 16980:3da3a2934be5

(scroll_preserve_screen_position): New variable. (keys_of_window): Set up Lisp var. (window_scroll): If scroll_preserve_screen_position is 0, behave the old way (advancing point the minimum distance).
author Richard M. Stallman <rms@gnu.org>
date Sat, 08 Feb 1997 15:50:17 +0000
parents 8134c62c03d0
children 643e0f90e153
files src/window.c
diffstat 1 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Thu Feb 06 23:23:32 1997 +0000
+++ b/src/window.c	Sat Feb 08 15:50:17 1997 +0000
@@ -111,8 +111,14 @@
 /* Nonzero after init_window_once has finished.  */
 static int window_initialized;
 
+/* Nonzero means scroll commands try to put point
+   at the same screen height as previously.  */
+static int scroll_preserve_screen_position;
+
 #define min(a, b) ((a) < (b) ? (a) : (b))
 
+extern int scroll_margin;
+
 extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
 
 DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
@@ -2638,8 +2644,7 @@
 
 
 /* Scroll contents of window WINDOW up N lines.
-   If WHOLE is nonzero, it means we wanted to scroll
-   by entire screenfuls.  */
+   If WHOLE is nonzero, it means scroll N screenfuls instead.  */
 
 static void
 window_scroll (window, n, whole, noerror)
@@ -2693,8 +2698,6 @@
 
   if (pos < ZV)
     {
-      extern int scroll_margin;
-
       int this_scroll_margin = scroll_margin;
 
       /* Don't use a scroll margin that is negative or too large.  */
@@ -2713,7 +2716,7 @@
 	 the window-scroll-functions.  */
       w->force_start = Qt;
 
-      if (whole)
+      if (whole && scroll_preserve_screen_position)
 	{
 	  SET_PT (pos);
 	  Fvertical_motion (make_number (original_vpos), window);
@@ -2735,11 +2738,13 @@
 
 	  if (top_margin <= opoint)
 	    SET_PT (opoint);
-	  else
+	  else if (scroll_preserve_screen_position)
 	    {
 	      SET_PT (pos);
 	      Fvertical_motion (make_number (original_vpos), window);
 	    }
+	  else
+	    SET_PT (pos);
 	}
       else if (n < 0)
 	{
@@ -2758,8 +2763,13 @@
 	    SET_PT (opoint);
 	  else
 	    {
-	      SET_PT (pos);
-	      Fvertical_motion (make_number (original_vpos), window);
+	      if (scroll_preserve_screen_position)
+		{
+		  SET_PT (pos);
+		  Fvertical_motion (make_number (original_vpos), window);
+		}
+	      else
+		Fvertical_motion (make_number (-1), window);
 	    }
 	}
     }
@@ -3644,6 +3654,11 @@
     "*Delete any window less than this wide.");
   window_min_width = 10;
 
+  DEFVAR_BOOL ("scroll-preserve-screen-position",
+	       &scroll_preserve_screen_position,
+    "*Nonzero means scroll commands move point to keep its screen line unchanged.");
+  scroll_preserve_screen_position = 0;
+
   defsubr (&Sselected_window);
   defsubr (&Sminibuffer_window);
   defsubr (&Swindow_minibuffer_p);