summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-11-11 00:35:31 +0000
committerRichard M. Stallman <rms@gnu.org>1996-11-11 00:35:31 +0000
commit9afd2168d4b157e9249c082ab9e07fca4594e92f (patch)
tree91c668f4d27bba8322bd884fd5358099c0a8a0f0 /src
parent0c7da84e740374854ce27528cd0de712ddb1f589 (diff)
downloademacs-9afd2168d4b157e9249c082ab9e07fca4594e92f.tar.gz
(scroll_margin): New variable.
(init_xdisp): Set up Lisp variable. (redisplay_window): Implement scroll_margin; don't use old start pos if point is inside the margin.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 7151877a6f8..b74fe724300 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -143,6 +143,10 @@ static int scroll_step;
when appropriate. */
static int scroll_conservatively;
+/* Recenter the window whenever point gets within this many lines
+ of the top or bottom of the window. */
+int scroll_margin;
+
/* Nonzero if try_window_id has made blank lines at window bottom
since the last redisplay that paused */
static int blank_end_of_window;
@@ -1699,11 +1703,23 @@ redisplay_window (window, just_this_one, preserve_echo_area)
&& XFASTINT (w->window_end_vpos) < XFASTINT (w->height)
&& !EQ (window, minibuf_window))
{
+ int this_scroll_margin = scroll_margin;
+
pos = *compute_motion (startp, 0, (hscroll ? 1 - hscroll : 0), 0,
PT, height, 0, width, hscroll,
pos_tab_offset (w, startp), w);
- if (pos.vpos < height)
+ /* Don't use a scroll margin that is negative or too large. */
+ if (this_scroll_margin < 0)
+ this_scroll_margin = 0;
+
+ if (XINT (w->height) < 4 * scroll_margin)
+ this_scroll_margin = XINT (w->height) / 4;
+
+ /* If point fits on the screen, and not within the scroll margin,
+ we are ok. */
+ if (pos.vpos < height - this_scroll_margin
+ && (pos.vpos >= this_scroll_margin || startp == BEGV))
{
/* Ok, point is still on frame */
if (w == XWINDOW (FRAME_SELECTED_WINDOW (f)))
@@ -4474,6 +4490,12 @@ If this is zero, point is always centered after it moves off frame.");
"*Scroll up to this many lines, to bring point back on screen.");
scroll_conservatively = 0;
+ DEFVAR_INT ("scroll-margin", &scroll_margin,
+ "*Number of lines of margin at the top and bottom of a window.\n\
+Recenter the window whenever point gets within this many lines\n\
+of the top or bottom of the window.");
+ scroll_margin = 0;
+
DEFVAR_INT ("debug-end-pos", &debug_end_pos, "Don't ask");
DEFVAR_BOOL ("truncate-partial-width-windows",