aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1996-11-11 00:34:50 +0000
committerRichard M. Stallman1996-11-11 00:34:50 +0000
commit0c7da84e740374854ce27528cd0de712ddb1f589 (patch)
tree2c3eee6075fbff261c7fc22f6b85b3ada2951b8a /src
parent7e90bcf5076ecc08903ba9763604f7010d3cc5da (diff)
downloademacs-0c7da84e740374854ce27528cd0de712ddb1f589.tar.gz
emacs-0c7da84e740374854ce27528cd0de712ddb1f589.zip
(window_scroll): Handle scroll_margin
by putting point at a place that won't force recentering.
Diffstat (limited to 'src')
-rw-r--r--src/window.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/window.c b/src/window.c
index 6f8cd8188f3..f9905e38c16 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2684,18 +2684,43 @@ window_scroll (window, n, noerror)
2684 2684
2685 if (pos < ZV) 2685 if (pos < ZV)
2686 { 2686 {
2687 extern int scroll_margin;
2688
2689 int this_scroll_margin = scroll_margin;
2690
2691 /* Don't use a scroll margin that is negative or too large. */
2692 if (this_scroll_margin < 0)
2693 this_scroll_margin = 0;
2694
2695 if (XINT (w->height) < 4 * scroll_margin)
2696 this_scroll_margin = XINT (w->height) / 4;
2697
2687 set_marker_restricted (w->start, make_number (pos), w->buffer); 2698 set_marker_restricted (w->start, make_number (pos), w->buffer);
2688 w->start_at_line_beg = bolp; 2699 w->start_at_line_beg = bolp;
2689 w->update_mode_line = Qt; 2700 w->update_mode_line = Qt;
2690 XSETFASTINT (w->last_modified, 0); 2701 XSETFASTINT (w->last_modified, 0);
2691 XSETFASTINT (w->last_overlay_modified, 0); 2702 XSETFASTINT (w->last_overlay_modified, 0);
2703
2704 /* If we scrolled forward, put point enough lines down
2705 that it is outside the scroll margin. */
2706 if (n > 0 && this_scroll_margin > 0)
2707 {
2708 SET_PT (pos);
2709 Fvertical_motion (make_number (this_scroll_margin), window);
2710 pos = PT;
2711 }
2712
2692 if (pos > opoint) 2713 if (pos > opoint)
2693 SET_PT (pos); 2714 {
2715 SET_PT (pos);
2716 }
2694 if (n < 0) 2717 if (n < 0)
2695 { 2718 {
2719 /* If we scrolled backward, put point near the end of the window
2720 but not within the scroll margin. */
2696 SET_PT (pos); 2721 SET_PT (pos);
2697 tem = Fvertical_motion (make_number (ht), window); 2722 tem = Fvertical_motion (make_number (ht - this_scroll_margin), window);
2698 if (PT > opoint || XFASTINT (tem) < ht) 2723 if (PT > opoint || XFASTINT (tem) < ht - this_scroll_margin)
2699 SET_PT (opoint); 2724 SET_PT (opoint);
2700 else 2725 else
2701 Fvertical_motion (make_number (-1), window); 2726 Fvertical_motion (make_number (-1), window);