]> code.delx.au - gnu-emacs/blobdiff - src/window.c
(Fmove_to_window_line): Undo last change.
[gnu-emacs] / src / window.c
index 28500c405d0ad42d1c265d83ac48e17b9fee5f18..61c4d3c83b8d203436fbcdc1451c59e61597a56e 100644 (file)
@@ -2626,8 +2626,8 @@ set_window_buffer (window, buffer, run_hooks_p)
   XSETFASTINT (w->window_end_vpos, 0);
   bzero (&w->last_cursor, sizeof w->last_cursor);
   w->window_end_valid = Qnil;
-  XSETFASTINT (w->hscroll, 0);
-  XSETFASTINT (w->min_hscroll, 0);
+  w->hscroll = w->min_hscroll = make_number (0);
+  w->vscroll = make_number (0);
   set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b));
   set_marker_restricted (w->start,
                         make_number (b->last_window_start),
@@ -4495,25 +4495,18 @@ displayed_window_lines (w)
   SET_TEXT_POS_FROM_MARKER (start, w->start);
   start_display (&it, w, start);
   move_it_vertically (&it, height);
-
-  if (old_buffer)
-    set_buffer_internal (old_buffer);
-
-  bottom_y = it.current_y + it.max_ascent + it.max_descent;
-
-  if (bottom_y > it.current_y && bottom_y <= it.last_visible_y)
-    /* Hit a line without a terminating newline.  */
-    it.vpos++;
+  bottom_y = line_bottom_y (&it);
 
   /* Add in empty lines at the bottom of the window.  */
   if (bottom_y < height)
     {
-      struct frame *f = XFRAME (w->frame);
-      int rest = height - bottom_y;
-      int lines = rest / CANON_Y_UNIT (f);
-      it.vpos += lines;
+      int uy = CANON_Y_UNIT (it.f);
+      it.vpos += (height - bottom_y + uy - 1) / uy;
     }
 
+  if (old_buffer)
+    set_buffer_internal (old_buffer);
+
   return it.vpos;
 }
 
@@ -4659,13 +4652,9 @@ zero means top of window, negative means relative to bottom of window.")
        XSETINT (arg, XINT (arg) + lines);
     }
 
-#if 0 /* I don't understand why this is done.  Among other things,
-         it means that C-u 0 M-r moves to line 1, and C-u -1 M-r
-         moves to the line below the window end.  2000-02-05, gerd */
+  /* Skip past a partially visible first line.  */
   if (w->vscroll)
-    /* Skip past a partially visible first line.  */
     XSETINT (arg, XINT (arg) + 1);
-#endif
 
   return Fvertical_motion (arg, window);
 }