changeset 29485:362c61b5411b

(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.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 07 Jun 2000 12:30:22 +0000
parents 59d0015683a5
children 033cf607b908
files src/window.c
diffstat 1 files changed, 34 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Wed Jun 07 12:00:23 2000 +0000
+++ b/src/window.c	Wed Jun 07 12:30:22 2000 +0000
@@ -4216,6 +4216,25 @@
 
   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 @@
 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 @@
   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);
 }