1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-13 09:32:47 +00:00

(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.
This commit is contained in:
Gerd Moellmann 2000-06-07 12:30:22 +00:00
parent b1376368e2
commit b7617575cd

View File

@ -4216,6 +4216,25 @@ redraws with point in the center of the current window.")
return Qnil;
}
/* Value is the number of lines actually displayed in window W,
as opposed to its height. */
static int
displayed_window_lines (w)
struct window *w;
{
struct it it;
struct text_pos start;
SET_TEXT_POS_FROM_MARKER (start, w->start);
start_display (&it, w, start);
move_it_vertically (&it, window_box_height (w));
return it.vpos;
}
DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line,
1, 1, "P",
@ -4224,26 +4243,17 @@ With no argument, position point at center of window.\n\
An argument specifies vertical position within the window;\n\
zero means top of window, negative means relative to bottom of window.")
(arg)
register Lisp_Object arg;
Lisp_Object arg;
{
register struct window *w = XWINDOW (selected_window);
register int height = window_internal_height (w);
register int start;
struct window *w = XWINDOW (selected_window);
int lines, start;
Lisp_Object window;
if (NILP (arg))
XSETFASTINT (arg, height / 2);
else
{
arg = Fprefix_numeric_value (arg);
if (XINT (arg) < 0)
XSETINT (arg, XINT (arg) + height);
}
window = selected_window;
start = marker_position (w->start);
XSETWINDOW (window, w);
if (start < BEGV || start > ZV)
{
int height = window_internal_height (w);
Fvertical_motion (make_number (- (height / 2)), window);
set_marker_both (w->start, w->buffer, PT, PT_BYTE);
w->start_at_line_beg = Fbolp ();
@ -4252,6 +4262,16 @@ zero means top of window, negative means relative to bottom of window.")
else
Fgoto_char (w->start);
lines = displayed_window_lines (w);
if (NILP (arg))
XSETFASTINT (arg, lines / 2);
else
{
arg = Fprefix_numeric_value (arg);
if (XINT (arg) < 0)
XSETINT (arg, XINT (arg) + lines);
}
return Fvertical_motion (arg, window);
}