]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix occasional recentering under scroll-conservatively.
authorEli Zaretskii <eliz@gnu.org>
Sat, 19 Jun 2010 09:40:15 +0000 (12:40 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 19 Jun 2010 09:40:15 +0000 (12:40 +0300)
 xdisp.c (try_scrolling): Compute the limit for searching point
 in forward scroll from scroll_max, instead of an arbitrary limit
 of 10 screen lines.  See
 http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00766.html and
 http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00773.html for
 details.

src/ChangeLog
src/xdisp.c

index 9e115942d398c2993c7c7565d55b74388c6ef4c2..7d875bf5bdaca7063a2b9de2f426bbf457a317e2 100644 (file)
@@ -1,3 +1,13 @@
+2010-06-19  Eli Zaretskii  <eliz@gnu.org>
+
+       * xdisp.c (try_scrolling): Compute the limit for searching point
+       in forward scroll from scroll_max, instead of an arbitrary limit
+       of 10 screen lines.  See
+       http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00766.html
+       and
+       http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00773.html
+       for details.
+
 2010-06-16  Glenn Morris  <rgm@gnu.org>
 
        * editfns.c (Fbyte_to_string): Pacify compiler.
index c8043308ec852e7add4daf6477d924930e7c3a01..c111ca2ffa38999f38dc54e1792f9f510a3077eb 100644 (file)
@@ -13431,14 +13431,19 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
       if (PT > CHARPOS (it.current.pos))
        {
          int y0 = line_bottom_y (&it);
-
-         /* Compute the distance from the scroll margin to PT
-            (including the height of the cursor line).  Moving the
-            iterator unconditionally to PT can be slow if PT is far
-            away, so stop 10 lines past the window bottom (is there a
-            way to do the right thing quickly?).  */
+         /* Compute how many pixels below window bottom to stop searching
+            for PT.  This avoids costly search for PT that is far away if
+            the user limited scrolling by a small number of lines, but
+            always finds PT if scroll_conservatively is set to a large
+            number, such as most-positive-fixnum.  */
+         int slack = min (scroll_max, 10 * FRAME_LINE_HEIGHT (f));
+
+         /* Compute the distance from the scroll margin to PT or to
+            the scroll limit, whichever comes first.  This should
+            include the height of the cursor line, to make that line
+            fully visible.  */
          move_it_to (&it, PT, -1,
-                     it.last_visible_y + 10 * FRAME_LINE_HEIGHT (f),
+                     it.last_visible_y + slack,
                      -1, MOVE_TO_POS | MOVE_TO_Y);
          dy = line_bottom_y (&it) - y0;