aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2008-10-27 18:33:06 +0000
committerChong Yidong2008-10-27 18:33:06 +0000
commit3d7185083b5a4630dace916bd51709fa0e9c8522 (patch)
tree1f898d6aa925941ecc1fbffd523b41077fcb09e5 /src
parentd8bdbe6fb3c523233152542e3d12fb489f5f1ff2 (diff)
downloademacs-3d7185083b5a4630dace916bd51709fa0e9c8522.tar.gz
emacs-3d7185083b5a4630dace916bd51709fa0e9c8522.zip
(try_scrolling): When computing the distance from the scroll margin to
PT, try moving some distance past the window bottom before giving up.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index b7c05f9eed4..d6ac67a7333 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12636,17 +12636,15 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12636 /* Compute scroll margin height in pixels. We scroll when point is 12636 /* Compute scroll margin height in pixels. We scroll when point is
12637 within this distance from the top or bottom of the window. */ 12637 within this distance from the top or bottom of the window. */
12638 if (scroll_margin > 0) 12638 if (scroll_margin > 0)
12639 { 12639 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4)
12640 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 12640 * FRAME_LINE_HEIGHT (f);
12641 this_scroll_margin *= FRAME_LINE_HEIGHT (f);
12642 }
12643 else 12641 else
12644 this_scroll_margin = 0; 12642 this_scroll_margin = 0;
12645 12643
12646 /* Force scroll_conservatively to have a reasonable value, to avoid 12644 /* Force scroll_conservatively to have a reasonable value, to avoid
12647 overflow while computing how much to scroll. Note that it's 12645 overflow while computing how much to scroll. Note that the user
12648 fairly common for users to supply scroll-conservatively equal to 12646 can supply scroll-conservatively equal to `most-positive-fixnum',
12649 `most-positive-fixnum', which can be larger than INT_MAX. */ 12647 which can be larger than INT_MAX. */
12650 if (scroll_conservatively > scroll_limit) 12648 if (scroll_conservatively > scroll_limit)
12651 { 12649 {
12652 scroll_conservatively = scroll_limit; 12650 scroll_conservatively = scroll_limit;
@@ -12668,7 +12666,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12668 12666
12669 too_near_end: 12667 too_near_end:
12670 12668
12671 /* Decide whether we have to scroll down. */ 12669 /* Decide whether to scroll down. */
12672 if (PT > CHARPOS (startp)) 12670 if (PT > CHARPOS (startp))
12673 { 12671 {
12674 int scroll_margin_y; 12672 int scroll_margin_y;
@@ -12683,17 +12681,17 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12683 12681
12684 if (PT > CHARPOS (it.current.pos)) 12682 if (PT > CHARPOS (it.current.pos))
12685 { 12683 {
12686 /* Point is in the scroll margin at the bottom of the 12684 int y0 = line_bottom_y (&it);
12687 window, or below. Compute the distance from the scroll
12688 margin to PT, and give up if the distance is greater than
12689 scroll_max. */
12690 move_it_to (&it, PT, -1, it.last_visible_y - 1, -1,
12691 MOVE_TO_POS | MOVE_TO_Y);
12692 12685
12693 /* To make point visible, we must move the window start down 12686 /* Compute the distance from the scroll margin to PT
12694 so that the cursor line is visible, which means we have 12687 (including the height of the cursor line). Moving the
12695 to add in the height of the cursor line. */ 12688 iterator unconditionally to PT can be slow if PT is far
12696 dy = line_bottom_y (&it) - scroll_margin_y; 12689 away, so stop 10 lines past the window bottom (is there a
12690 way to do the right thing quickly?). */
12691 move_it_to (&it, PT, -1,
12692 it.last_visible_y + 10 * FRAME_LINE_HEIGHT (f),
12693 -1, MOVE_TO_POS | MOVE_TO_Y);
12694 dy = line_bottom_y (&it) - y0;
12697 12695
12698 if (dy > scroll_max) 12696 if (dy > scroll_max)
12699 return SCROLLING_FAILED; 12697 return SCROLLING_FAILED;
@@ -12704,14 +12702,11 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12704 12702
12705 if (scroll_down_p) 12703 if (scroll_down_p)
12706 { 12704 {
12707 /* Move the window start down. If scrolling conservatively, 12705 /* Point is in or below the bottom scroll margin, so move the
12708 move it just enough down to make point visible. If 12706 window start down. If scrolling conservatively, move it just
12709 scroll_step is set, move it down by scroll_step. */ 12707 enough down to make point visible. If scroll_step is set,
12710 start_display (&it, w, startp); 12708 move it down by scroll_step. */
12711
12712 if (scroll_conservatively) 12709 if (scroll_conservatively)
12713 /* Set AMOUNT_TO_SCROLL to at least one line,
12714 and at most scroll_conservatively lines. */
12715 amount_to_scroll 12710 amount_to_scroll
12716 = min (max (dy, FRAME_LINE_HEIGHT (f)), 12711 = min (max (dy, FRAME_LINE_HEIGHT (f)),
12717 FRAME_LINE_HEIGHT (f) * scroll_conservatively); 12712 FRAME_LINE_HEIGHT (f) * scroll_conservatively);
@@ -12733,10 +12728,10 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12733 if (amount_to_scroll <= 0) 12728 if (amount_to_scroll <= 0)
12734 return SCROLLING_FAILED; 12729 return SCROLLING_FAILED;
12735 12730
12736 /* If moving by amount_to_scroll leaves STARTP unchanged, 12731 start_display (&it, w, startp);
12737 move it down one screen line. */
12738
12739 move_it_vertically (&it, amount_to_scroll); 12732 move_it_vertically (&it, amount_to_scroll);
12733
12734 /* If STARTP is unchanged, move it down another screen line. */
12740 if (CHARPOS (it.current.pos) == CHARPOS (startp)) 12735 if (CHARPOS (it.current.pos) == CHARPOS (startp))
12741 move_it_by_lines (&it, 1, 1); 12736 move_it_by_lines (&it, 1, 1);
12742 startp = it.current.pos; 12737 startp = it.current.pos;