aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman2005-07-06 22:06:15 +0000
committerRichard M. Stallman2005-07-06 22:06:15 +0000
commitf6b434405bb0406f43e64e46cb38af5528a5b9af (patch)
tree1cc365ecf6f11e15df2108fcdcd544d79c64c175 /src
parent47bdd3050055afd1db8e9a4755bcd0c30d174727 (diff)
downloademacs-f6b434405bb0406f43e64e46cb38af5528a5b9af.tar.gz
emacs-f6b434405bb0406f43e64e46cb38af5528a5b9af.zip
(Frecenter): When arg is inside the scroll margin, move it out of the margin.
Diffstat (limited to 'src')
-rw-r--r--src/window.c62
1 files changed, 53 insertions, 9 deletions
diff --git a/src/window.c b/src/window.c
index 6155aeddc6b..74ef819c0e1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5333,6 +5333,8 @@ and redisplay normally--don't erase and redraw the frame. */)
5333 struct buffer *obuf = current_buffer; 5333 struct buffer *obuf = current_buffer;
5334 int center_p = 0; 5334 int center_p = 0;
5335 int charpos, bytepos; 5335 int charpos, bytepos;
5336 int iarg;
5337 int this_scroll_margin;
5336 5338
5337 /* If redisplay is suppressed due to an error, try again. */ 5339 /* If redisplay is suppressed due to an error, try again. */
5338 obuf->display_error_modiff = 0; 5340 obuf->display_error_modiff = 0;
@@ -5359,6 +5361,12 @@ and redisplay normally--don't erase and redraw the frame. */)
5359 5361
5360 set_buffer_internal (buf); 5362 set_buffer_internal (buf);
5361 5363
5364 /* Do this after making BUF current
5365 in case scroll_margin is buffer-local. */
5366 this_scroll_margin = max (0, scroll_margin);
5367 this_scroll_margin = min (this_scroll_margin,
5368 XFASTINT (w->total_lines) / 4);
5369
5362 /* Handle centering on a graphical frame specially. Such frames can 5370 /* Handle centering on a graphical frame specially. Such frames can
5363 have variable-height lines and centering point on the basis of 5371 have variable-height lines and centering point on the basis of
5364 line counts would lead to strange effects. */ 5372 line counts would lead to strange effects. */
@@ -5375,14 +5383,17 @@ and redisplay normally--don't erase and redraw the frame. */)
5375 charpos = IT_CHARPOS (it); 5383 charpos = IT_CHARPOS (it);
5376 bytepos = IT_BYTEPOS (it); 5384 bytepos = IT_BYTEPOS (it);
5377 } 5385 }
5378 else if (XINT (arg) < 0) 5386 else if (iarg < 0)
5379 { 5387 {
5380 struct it it; 5388 struct it it;
5381 struct text_pos pt; 5389 struct text_pos pt;
5382 int nlines = - XINT (arg); 5390 int nlines = -iarg;
5383 int extra_line_spacing; 5391 int extra_line_spacing;
5384 int h = window_box_height (w); 5392 int h = window_box_height (w);
5385 5393
5394 iarg = XINT (arg);
5395 iarg = - max (-iarg, this_scroll_margin);
5396
5386 SET_TEXT_POS (pt, PT, PT_BYTE); 5397 SET_TEXT_POS (pt, PT, PT_BYTE);
5387 start_display (&it, w, pt); 5398 start_display (&it, w, pt);
5388 5399
@@ -5441,7 +5452,11 @@ and redisplay normally--don't erase and redraw the frame. */)
5441 else 5452 else
5442 { 5453 {
5443 struct position pos; 5454 struct position pos;
5444 pos = *vmotion (PT, - XINT (arg), w); 5455
5456 iarg = XINT (arg);
5457 iarg = max (iarg, this_scroll_margin);
5458
5459 pos = *vmotion (PT, -iarg, w);
5445 charpos = pos.bufpos; 5460 charpos = pos.bufpos;
5446 bytepos = pos.bytepos; 5461 bytepos = pos.bytepos;
5447 } 5462 }
@@ -5452,11 +5467,17 @@ and redisplay normally--don't erase and redraw the frame. */)
5452 int ht = window_internal_height (w); 5467 int ht = window_internal_height (w);
5453 5468
5454 if (center_p) 5469 if (center_p)
5455 arg = make_number (ht / 2); 5470 iarg = make_number (ht / 2);
5456 else if (XINT (arg) < 0) 5471 else if (XINT (arg) < 0)
5457 arg = make_number (XINT (arg) + ht); 5472 iarg = XINT (arg) + ht;
5473 else
5474 iarg = XINT (arg);
5475
5476 /* Don't let it get into the margin at either top or bottom. */
5477 iarg = max (iarg, this_scroll_margin);
5478 iarg = min (iarg, ht - this_scroll_margin - 1);
5458 5479
5459 pos = *vmotion (PT, - XINT (arg), w); 5480 pos = *vmotion (PT, - iarg, w);
5460 charpos = pos.bufpos; 5481 charpos = pos.bufpos;
5461 bytepos = pos.bytepos; 5482 bytepos = pos.bytepos;
5462 } 5483 }
@@ -5505,6 +5526,9 @@ zero means top of window, negative means relative to bottom of window. */)
5505 struct window *w = XWINDOW (selected_window); 5526 struct window *w = XWINDOW (selected_window);
5506 int lines, start; 5527 int lines, start;
5507 Lisp_Object window; 5528 Lisp_Object window;
5529#if 0
5530 int this_scroll_margin;
5531#endif
5508 5532
5509 window = selected_window; 5533 window = selected_window;
5510 start = marker_position (w->start); 5534 start = marker_position (w->start);
@@ -5520,13 +5544,33 @@ zero means top of window, negative means relative to bottom of window. */)
5520 Fgoto_char (w->start); 5544 Fgoto_char (w->start);
5521 5545
5522 lines = displayed_window_lines (w); 5546 lines = displayed_window_lines (w);
5547
5548#if 0
5549 this_scroll_margin = max (0, scroll_margin);
5550 this_scroll_margin = min (this_scroll_margin, lines / 4);
5551#endif
5552
5523 if (NILP (arg)) 5553 if (NILP (arg))
5524 XSETFASTINT (arg, lines / 2); 5554 XSETFASTINT (arg, lines / 2);
5525 else 5555 else
5526 { 5556 {
5527 arg = Fprefix_numeric_value (arg); 5557 int iarg = XINT (Fprefix_numeric_value (arg));
5528 if (XINT (arg) < 0) 5558
5529 XSETINT (arg, XINT (arg) + lines); 5559 if (iarg < 0)
5560 iarg = iarg + lines;
5561
5562#if 0 /* This code would prevent move-to-window-line from moving point
5563 to a place inside the scroll margins (which would cause the
5564 next redisplay to scroll). I wrote this code, but then concluded
5565 it is probably better not to install it. However, it is here
5566 inside #if 0 so as not to lose it. -- rms. */
5567
5568 /* Don't let it get into the margin at either top or bottom. */
5569 iarg = max (iarg, this_scroll_margin);
5570 iarg = min (iarg, lines - this_scroll_margin - 1);
5571#endif
5572
5573 arg = make_number (iarg);
5530 } 5574 }
5531 5575
5532 /* Skip past a partially visible first line. */ 5576 /* Skip past a partially visible first line. */