aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2011-03-26 20:31:36 +0200
committerEli Zaretskii2011-03-26 20:31:36 +0200
commit06b6bbb578cae9ebc00ffd6d4a2c7dc4995588bf (patch)
treeb612992a6c260719e0e7e456880da008772c1be4
parent5d9bd9764f0c3dc7592c0232420e4bbc1e366b7f (diff)
downloademacs-06b6bbb578cae9ebc00ffd6d4a2c7dc4995588bf.tar.gz
emacs-06b6bbb578cae9ebc00ffd6d4a2c7dc4995588bf.zip
Fix bug #6671 with point position in the window when scrolling far away.
src/xdisp.c (redisplay_window): Don't check buffer's clip_changed flag as a prerequisite for invoking try_scrolling. (try_scrolling): Limit scrolling to 100 screen lines. (SCROLL_LIMIT): New macro. (try_scrolling): Use it when setting scroll_limit. (redisplay_window): Even when falling back on "recentering", position point in the window according to scroll-conservatively, scroll-margin, and scroll-*-aggressively variables.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/xdisp.c69
2 files changed, 67 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 83bcca1db65..ef3a1546913 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,11 @@
3 * xdisp.c (redisplay_window): Don't check buffer's clip_changed 3 * xdisp.c (redisplay_window): Don't check buffer's clip_changed
4 flag as a prerequisite for invoking try_scrolling. (Bug#6671) 4 flag as a prerequisite for invoking try_scrolling. (Bug#6671)
5 (try_scrolling): Limit scrolling to 100 screen lines. 5 (try_scrolling): Limit scrolling to 100 screen lines.
6 (SCROLL_LIMIT): New macro.
7 (try_scrolling): Use it when setting scroll_limit.
8 (redisplay_window): Even when falling back on "recentering",
9 position point in the window according to scroll-conservatively,
10 scroll-margin, and scroll-*-aggressively variables. (Bug#6671)
6 11
72011-03-26 Juanma Barranquero <lekktu@gmail.com> 122011-03-26 Juanma Barranquero <lekktu@gmail.com>
8 13
diff --git a/src/xdisp.c b/src/xdisp.c
index 270d29d0213..263bedec4a2 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13003,6 +13003,9 @@ enum
13003 SCROLLING_NEED_LARGER_MATRICES 13003 SCROLLING_NEED_LARGER_MATRICES
13004}; 13004};
13005 13005
13006/* If scroll-conservatively is more than this, never recenter. */
13007#define SCROLL_LIMIT 100
13008
13006static int 13009static int
13007try_scrolling (Lisp_Object window, int just_this_one_p, 13010try_scrolling (Lisp_Object window, int just_this_one_p,
13008 EMACS_INT arg_scroll_conservatively, EMACS_INT scroll_step, 13011 EMACS_INT arg_scroll_conservatively, EMACS_INT scroll_step,
@@ -13017,7 +13020,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
13017 int extra_scroll_margin_lines = last_line_misfit ? 1 : 0; 13020 int extra_scroll_margin_lines = last_line_misfit ? 1 : 0;
13018 Lisp_Object aggressive; 13021 Lisp_Object aggressive;
13019 /* We will never try scrolling more than this number of lines. */ 13022 /* We will never try scrolling more than this number of lines. */
13020 int scroll_limit = 100; 13023 int scroll_limit = SCROLL_LIMIT;
13021 13024
13022#if GLYPH_DEBUG 13025#if GLYPH_DEBUG
13023 debug_method_add (w, "try_scrolling"); 13026 debug_method_add (w, "try_scrolling");
@@ -14202,11 +14205,10 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
14202 } 14205 }
14203 } 14206 }
14204 14207
14205 /* Finally, just choose place to start which centers point */ 14208 /* Finally, just choose a place to start which positions point
14209 according to user preferences. */
14206 14210
14207 recenter: 14211 recenter:
14208 if (centering_position < 0)
14209 centering_position = window_box_height (w) / 2;
14210 14212
14211#if GLYPH_DEBUG 14213#if GLYPH_DEBUG
14212 debug_method_add (w, "recenter"); 14214 debug_method_add (w, "recenter");
@@ -14218,10 +14220,62 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
14218 if (!buffer_unchanged_p) 14220 if (!buffer_unchanged_p)
14219 w->base_line_number = Qnil; 14221 w->base_line_number = Qnil;
14220 14222
14221 /* Move backward half the height of the window. */ 14223 /* Determine the window start relative to point. */
14222 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); 14224 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
14223 it.current_y = it.last_visible_y; 14225 it.current_y = it.last_visible_y;
14226 if (centering_position < 0)
14227 {
14228 int margin =
14229 scroll_margin > 0
14230 ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4)
14231 : 0;
14232 int scrolling_up = PT > CHARPOS (startp) + margin;
14233 Lisp_Object aggressive =
14234 scrolling_up
14235 ? BVAR (current_buffer, scroll_up_aggressively)
14236 : BVAR (current_buffer, scroll_down_aggressively);
14237
14238 if (!MINI_WINDOW_P (w)
14239 && scroll_conservatively > SCROLL_LIMIT || NUMBERP (aggressive))
14240 {
14241 int pt_offset = 0;
14242
14243 /* Setting scroll-conservatively overrides
14244 scroll-*-aggressively. */
14245 if (!scroll_conservatively && NUMBERP (aggressive))
14246 {
14247 double float_amount = XFLOATINT (aggressive);
14248
14249 pt_offset = float_amount * WINDOW_BOX_TEXT_HEIGHT (w);
14250 if (pt_offset == 0 && float_amount > 0)
14251 pt_offset = 1;
14252 if (pt_offset)
14253 margin -= 1;
14254 }
14255 /* Compute how much to move the window start backward from
14256 point so that point will be displayed where the user
14257 wants it. */
14258 if (scrolling_up)
14259 {
14260 centering_position = it.last_visible_y;
14261 if (pt_offset)
14262 centering_position -= pt_offset;
14263 centering_position -=
14264 FRAME_LINE_HEIGHT (f) * (1 + margin + (last_line_misfit != 0));
14265 /* Don't let point enter the scroll margin near top of
14266 the window. */
14267 if (centering_position < margin * FRAME_LINE_HEIGHT (f))
14268 centering_position = margin * FRAME_LINE_HEIGHT (f);
14269 }
14270 else
14271 centering_position = margin * FRAME_LINE_HEIGHT (f) + pt_offset;
14272 }
14273 else
14274 /* Move backward from point half the height of the window. */
14275 centering_position = window_box_height (w) / 2;
14276 }
14224 move_it_vertically_backward (&it, centering_position); 14277 move_it_vertically_backward (&it, centering_position);
14278
14225 xassert (IT_CHARPOS (it) >= BEGV); 14279 xassert (IT_CHARPOS (it) >= BEGV);
14226 14280
14227 /* The function move_it_vertically_backward may move over more 14281 /* The function move_it_vertically_backward may move over more
@@ -14238,8 +14292,9 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
14238 14292
14239 it.current_x = it.hpos = 0; 14293 it.current_x = it.hpos = 0;
14240 14294
14241 /* Set startp here explicitly in case that helps avoid an infinite loop 14295 /* Set the window start position here explicitly, to avoid an
14242 in case the window-scroll-functions functions get errors. */ 14296 infinite loop in case the functions in window-scroll-functions
14297 get errors. */
14243 set_marker_both (w->start, Qnil, IT_CHARPOS (it), IT_BYTEPOS (it)); 14298 set_marker_both (w->start, Qnil, IT_CHARPOS (it), IT_BYTEPOS (it));
14244 14299
14245 /* Run scroll hooks. */ 14300 /* Run scroll hooks. */