aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-06-07 12:30:22 +0000
committerGerd Moellmann2000-06-07 12:30:22 +0000
commitb7617575cd3074eae8bf7fe57c86e957d7c29690 (patch)
tree61bfbfeedf532f1f1397a22563f24ddb444f5628
parentb1376368e2a5e612c53b9a9de24d8c228af89b88 (diff)
downloademacs-b7617575cd3074eae8bf7fe57c86e957d7c29690.tar.gz
emacs-b7617575cd3074eae8bf7fe57c86e957d7c29690.zip
(displayed_window_lines): New function.
(Fmove_to_window_line): Use displayed_window_lines to determine the number of lines to move, instead of using the window's height.
-rw-r--r--src/window.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/window.c b/src/window.c
index 136c21da377..a5ce48813b8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4216,6 +4216,25 @@ redraws with point in the center of the current window.")
4216 4216
4217 return Qnil; 4217 return Qnil;
4218} 4218}
4219
4220
4221/* Value is the number of lines actually displayed in window W,
4222 as opposed to its height. */
4223
4224static int
4225displayed_window_lines (w)
4226 struct window *w;
4227{
4228 struct it it;
4229 struct text_pos start;
4230
4231 SET_TEXT_POS_FROM_MARKER (start, w->start);
4232 start_display (&it, w, start);
4233 move_it_vertically (&it, window_box_height (w));
4234 return it.vpos;
4235}
4236
4237
4219 4238
4220DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line, 4239DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line,
4221 1, 1, "P", 4240 1, 1, "P",
@@ -4224,26 +4243,17 @@ With no argument, position point at center of window.\n\
4224An argument specifies vertical position within the window;\n\ 4243An argument specifies vertical position within the window;\n\
4225zero means top of window, negative means relative to bottom of window.") 4244zero means top of window, negative means relative to bottom of window.")
4226 (arg) 4245 (arg)
4227 register Lisp_Object arg; 4246 Lisp_Object arg;
4228{ 4247{
4229 register struct window *w = XWINDOW (selected_window); 4248 struct window *w = XWINDOW (selected_window);
4230 register int height = window_internal_height (w); 4249 int lines, start;
4231 register int start;
4232 Lisp_Object window; 4250 Lisp_Object window;
4233 4251
4234 if (NILP (arg)) 4252 window = selected_window;
4235 XSETFASTINT (arg, height / 2);
4236 else
4237 {
4238 arg = Fprefix_numeric_value (arg);
4239 if (XINT (arg) < 0)
4240 XSETINT (arg, XINT (arg) + height);
4241 }
4242
4243 start = marker_position (w->start); 4253 start = marker_position (w->start);
4244 XSETWINDOW (window, w);
4245 if (start < BEGV || start > ZV) 4254 if (start < BEGV || start > ZV)
4246 { 4255 {
4256 int height = window_internal_height (w);
4247 Fvertical_motion (make_number (- (height / 2)), window); 4257 Fvertical_motion (make_number (- (height / 2)), window);
4248 set_marker_both (w->start, w->buffer, PT, PT_BYTE); 4258 set_marker_both (w->start, w->buffer, PT, PT_BYTE);
4249 w->start_at_line_beg = Fbolp (); 4259 w->start_at_line_beg = Fbolp ();
@@ -4252,6 +4262,16 @@ zero means top of window, negative means relative to bottom of window.")
4252 else 4262 else
4253 Fgoto_char (w->start); 4263 Fgoto_char (w->start);
4254 4264
4265 lines = displayed_window_lines (w);
4266 if (NILP (arg))
4267 XSETFASTINT (arg, lines / 2);
4268 else
4269 {
4270 arg = Fprefix_numeric_value (arg);
4271 if (XINT (arg) < 0)
4272 XSETINT (arg, XINT (arg) + lines);
4273 }
4274
4255 return Fvertical_motion (arg, window); 4275 return Fvertical_motion (arg, window);
4256} 4276}
4257 4277