# HG changeset patch # User Eli Zaretskii # Date 1276940415 -10800 # Node ID f24aeaefbe372bfca8840ffa3605b412e85f32b9 # Parent 8d29522e59d48594f2b606376e6d9ead60709dd9 Fix occasional recentering under scroll-conservatively. 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. diff -r 8d29522e59d4 -r f24aeaefbe37 src/ChangeLog --- a/src/ChangeLog Fri Jun 18 19:39:04 2010 -0700 +++ b/src/ChangeLog Sat Jun 19 12:40:15 2010 +0300 @@ -1,3 +1,13 @@ +2010-06-19 Eli Zaretskii + + * 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 * editfns.c (Fbyte_to_string): Pacify compiler. diff -r 8d29522e59d4 -r f24aeaefbe37 src/xdisp.c --- a/src/xdisp.c Fri Jun 18 19:39:04 2010 -0700 +++ b/src/xdisp.c Sat Jun 19 12:40:15 2010 +0300 @@ -13431,14 +13431,19 @@ 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;