XEmacs 21.2.20 "Yoko".
[chise/xemacs-chise.git.1] / src / window.c
index 26193ca..a63fe35 100644 (file)
@@ -36,10 +36,12 @@ Boston, MA 02111-1307, USA.  */
 #include "glyphs.h"
 #include "redisplay.h"
 #include "window.h"
+#include "elhash.h"
 #include "commands.h"
+#include "gutter.h"
 
 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configurationp;
-Lisp_Object Qscroll_up, Qscroll_down, Qdisplay_buffer;
+Lisp_Object Qdisplay_buffer;
 
 #ifdef MEMORY_USAGE_STATS
 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qother_redisplay;
@@ -83,6 +85,9 @@ Lisp_Object Vvertical_divider_line_width;
 /* Spacing between outer egde of divider border and window edge */
 Lisp_Object Vvertical_divider_spacing;
 
+/* How much to scroll by per-line. */
+Lisp_Object Vwindow_pixel_scroll_increment;
+
 /* Scroll if point lands on the bottom line and that line is partially
    clipped. */
 int scroll_on_clipped_lines;
@@ -116,7 +121,7 @@ Lisp_Object Qtemp_buffer_show_hook;
 int next_screen_context_lines;
 
 /* List of freed window configurations with 1 - 10 windows. */
-Lisp_Object Vwindow_configuration_free_list[10];
+static Lisp_Object Vwindow_configuration_free_list[10];
 
 #define SET_LAST_MODIFIED(w, cache_too)                \
 do {                                           \
@@ -136,36 +141,38 @@ do {                                              \
 
 \f
 #define MARK_DISP_VARIABLE(field)              \
-  ((markobj) (window->field[CURRENT_DISP]));   \
-  ((markobj) (window->field[DESIRED_DISP]));   \
-  ((markobj) (window->field[CMOTION_DISP]));
+  mark_object (window->field[CURRENT_DISP]);   \
+  mark_object (window->field[DESIRED_DISP]);   \
+  mark_object (window->field[CMOTION_DISP]);
 
 static Lisp_Object
-mark_window (Lisp_Object obj, void (*markobj) (Lisp_Object))
+mark_window (Lisp_Object obj)
 {
   struct window *window = XWINDOW (obj);
-  ((markobj) (window->frame));
-  ((markobj) (window->mini_p));
-  ((markobj) (window->next));
-  ((markobj) (window->prev));
-  ((markobj) (window->hchild));
-  ((markobj) (window->vchild));
-  ((markobj) (window->parent));
-  ((markobj) (window->buffer));
+  mark_object (window->frame);
+  mark_object (window->mini_p);
+  mark_object (window->next);
+  mark_object (window->prev);
+  mark_object (window->hchild);
+  mark_object (window->vchild);
+  mark_object (window->parent);
+  mark_object (window->buffer);
   MARK_DISP_VARIABLE (start);
   MARK_DISP_VARIABLE (pointm);
-  ((markobj) (window->sb_point));      /* #### move to scrollbar.c? */
-  ((markobj) (window->use_time));
+  mark_object (window->sb_point);      /* #### move to scrollbar.c? */
+  mark_object (window->use_time);
   MARK_DISP_VARIABLE (last_modified);
   MARK_DISP_VARIABLE (last_point);
   MARK_DISP_VARIABLE (last_start);
   MARK_DISP_VARIABLE (last_facechange);
-  ((markobj) (window->line_cache_last_updated));
-  ((markobj) (window->redisplay_end_trigger));
-  mark_face_cachels (window->face_cachels, markobj);
-  mark_glyph_cachels (window->glyph_cachels, markobj);
+  mark_object (window->line_cache_last_updated);
+  mark_object (window->redisplay_end_trigger);
+  mark_object (window->subwindow_instance_cache);
+
+  mark_face_cachels (window->face_cachels);
+  mark_glyph_cachels (window->glyph_cachels);
 
-#define WINDOW_SLOT(slot, compare) ((markobj) (window->slot))
+#define WINDOW_SLOT(slot, compare) mark_object (window->slot)
 #include "winslots.h"
 
   return Qnil;
@@ -228,7 +235,7 @@ finalize_window (void *header, int for_disksave)
 
 DEFINE_LRECORD_IMPLEMENTATION ("window", window,
                                mark_window, print_window, finalize_window,
-                              0, 0, struct window);
+                              0, 0, 0, struct window);
 
 
 #define INIT_DISP_VARIABLE(field, initialization)      \
@@ -249,7 +256,7 @@ Lisp_Object
 allocate_window (void)
 {
   Lisp_Object val;
-  struct window *p = alloc_lcrecord_type (struct window, lrecord_window);
+  struct window *p = alloc_lcrecord_type (struct window, &lrecord_window);
 
   zero_lcrecord (p);
   XSETWINDOW (val, p);
@@ -274,6 +281,9 @@ allocate_window (void)
   p->face_cachels     = Dynarr_new (face_cachel);
   p->glyph_cachels    = Dynarr_new (glyph_cachel);
   p->line_start_cache = Dynarr_new (line_start_cache);
+  p->subwindow_instance_cache = make_lisp_hash_table (10,
+                                                     HASH_TABLE_KEY_WEAK,
+                                                     HASH_TABLE_EQ);
   p->line_cache_last_updated = Qzero;
   INIT_DISP_VARIABLE (last_point_x, 0);
   INIT_DISP_VARIABLE (last_point_y, 0);
@@ -385,23 +395,21 @@ static Lisp_Object
 real_window_internal (Lisp_Object win, struct window_mirror *rmir,
                      struct window_mirror *mir)
 {
-  Lisp_Object retval;
-
   for (; !NILP (win) && rmir ; win = XWINDOW (win)->next, rmir = rmir->next)
     {
       if (mir == rmir)
        return win;
       if (!NILP (XWINDOW (win)->vchild))
        {
-         retval = real_window_internal (XWINDOW (win)->vchild, rmir->vchild,
-                                        mir);
+         Lisp_Object retval =
+           real_window_internal (XWINDOW (win)->vchild, rmir->vchild, mir);
          if (!NILP (retval))
            return retval;
        }
       if (!NILP (XWINDOW (win)->hchild))
        {
-         retval = real_window_internal (XWINDOW (win)->hchild, rmir->hchild,
-                                        mir);
+         Lisp_Object retval =
+           real_window_internal (XWINDOW (win)->hchild, rmir->hchild, mir);
          if (!NILP (retval))
            return retval;
        }
@@ -637,7 +645,7 @@ window_full_width_p (struct window *w)
   return window_is_leftmost (w) && window_is_rightmost (w);
 }
 
-static int
+int
 window_is_highest (struct window *w)
 {
   Lisp_Object parent, current_ancestor, window;
@@ -665,7 +673,7 @@ window_is_highest (struct window *w)
     return 0;
 }
 
-static int
+int
 window_is_lowest (struct window *w)
 {
   Lisp_Object parent, current_ancestor, window;
@@ -701,6 +709,11 @@ window_full_height_p (struct window *w)
 int
 window_truncation_on (struct window *w)
 {
+    /* Minibuffer windows are never truncated.
+       ### is this the right way ? */
+  if (MINI_WINDOW_P (w))
+    return 0;
+
   /* Horizontally scrolled windows are truncated. */
   if (w->hscroll)
     return 1;
@@ -719,6 +732,17 @@ window_truncation_on (struct window *w)
   return 0;
 }
 
+DEFUN ("window-truncated-p", Fwindow_truncated_p, 0, 1, 0, /*
+Returns Non-Nil iff the window is truncated.
+*/
+       (window))
+{
+  struct window *w = decode_window (window);
+
+  return window_truncation_on (w) ? Qt : Qnil;
+}
+
+
 static int
 have_undivided_common_edge (struct window *w_right, void *closure)
 {
@@ -746,7 +770,7 @@ window_needs_vertical_divider_1 (struct window *w)
     return 1;
 
 #ifdef HAVE_SCROLLBARS
-  /* Our right scrollabr is enough to separate us at the right */
+  /* Our right scrollbar is enough to separate us at the right */
   if (NILP (w->scrollbar_on_left_p)
       && !NILP (w->vertical_scrollbar_visible_p)
       && !ZEROP (w->scrollbar_width))
@@ -785,7 +809,7 @@ invalidate_vertical_divider_cache_in_window (struct window *w,
 /* Calculate width of vertical divider, including its shadows
    and spacing. The returned value is effectively the distance
    between adjacent window edges. This function does not check
-   whether a windows needs vertival divider, so the returned 
+   whether a window needs a vertical divider, so the returned
    value is a "theoretical" one */
 int
 window_divider_width (struct window *w)
@@ -794,7 +818,7 @@ window_divider_width (struct window *w)
      will have a depressed look */
 
   if (FRAME_WIN_P (XFRAME (WINDOW_FRAME (w))))
-    return 
+    return
       XINT (w->vertical_divider_line_width)
       + 2 * XINT (w->vertical_divider_spacing)
       + 2 * abs (XINT (w->vertical_divider_shadow_thickness));
@@ -893,7 +917,7 @@ window_modeline_height (struct window *w)
                /* This should be an abort except I'm not yet 100%
                    confident that it won't ever get hit (though I
                    haven't been able to trigger it).  It is extremely
-                   unlikely to cause any noticable problem and even if
+                   unlikely to cause any noticeable problem and even if
                    it does it will be a minor display glitch. */
                /* #### Bullshit alert.  It does get hit and it causes
                    noticeable glitches.  real_current_modeline_height
@@ -968,32 +992,6 @@ window_right_margin_width (struct window *w)
   return margin_width_internal (w, 0);
 }
 
-static int
-window_top_toolbar_height (struct window *w)
-{
-  /* #### implement this shit. */
-  return 0;
-}
-
-/* #### Currently used in scrollbar.c.  Does it actually need to be? */
-int
-window_bottom_toolbar_height (struct window *w)
-{
-  return 0;
-}
-
-static int
-window_left_toolbar_width (struct window *w)
-{
-  return 0;
-}
-
-static int
-window_right_toolbar_width (struct window *w)
-{
-  return 0;
-}
-
 /*****************************************************************************
  Window Gutters
 
@@ -1015,47 +1013,45 @@ window_right_toolbar_width (struct window *w)
 int
 window_top_gutter_height (struct window *w)
 {
-  int toolbar_height = window_top_toolbar_height (w);
+  int gutter = WINDOW_REAL_TOP_GUTTER_BOUNDS (w);
 
   if (!NILP (w->hchild) || !NILP (w->vchild))
     return 0;
 
 #ifdef HAVE_SCROLLBARS
   if (!NILP (w->scrollbar_on_top_p))
-    return window_scrollbar_height (w) + toolbar_height;
+    return window_scrollbar_height (w) + gutter;
   else
 #endif
-    return toolbar_height;
+    return gutter;
 }
 
 int
 window_bottom_gutter_height (struct window *w)
 {
-  int other_height;
+  int gutter = WINDOW_REAL_BOTTOM_GUTTER_BOUNDS (w);
 
   if (!NILP (w->hchild) || !NILP (w->vchild))
     return 0;
-  else
-    other_height =
-      window_modeline_height (w) + window_bottom_toolbar_height (w);
+
+  gutter += window_modeline_height (w);
 
 #ifdef HAVE_SCROLLBARS
   if (NILP (w->scrollbar_on_top_p))
-    return window_scrollbar_height (w) + other_height;
+    return window_scrollbar_height (w) + gutter;
   else
 #endif
-    return other_height;
+    return gutter;
 }
 
 int
 window_left_gutter_width (struct window *w, int modeline)
 {
-  int gutter = window_left_toolbar_width (w);
-  
+  int gutter = WINDOW_REAL_LEFT_GUTTER_BOUNDS (w);
+
   if (!NILP (w->hchild) || !NILP (w->vchild))
     return 0;
 
-
 #ifdef HAVE_SCROLLBARS
   if (!modeline && !NILP (w->scrollbar_on_left_p))
     gutter += window_scrollbar_width (w);
@@ -1067,8 +1063,8 @@ window_left_gutter_width (struct window *w, int modeline)
 int
 window_right_gutter_width (struct window *w, int modeline)
 {
-  int gutter = window_left_toolbar_width (w);
-  
+  int gutter = WINDOW_REAL_RIGHT_GUTTER_BOUNDS (w);
+
   if (!NILP (w->hchild) || !NILP (w->vchild))
     return 0;
 
@@ -1119,6 +1115,26 @@ be used.  Otherwise, the selected frame is used.
   }
 }
 
+DEFUN ("last-nonminibuf-window", Flast_nonminibuf_window, 0, 1, 0, /*
+Return the last selected window that is not a minibuffer window.
+If the optional argument CON-DEV-OR-FRAME is specified and is a frame,
+return the last non-minibuffer window used by that frame.  If
+CON-DEV-OR-FRAME is a device, then the selected frame on that device
+will be used.  If CON-DEV-OR-FRAME is a console, the selected frame on
+that console's selected device will be used.  Otherwise, the selected
+frame is used.
+*/
+       (con_dev_or_frame))
+{
+  if (NILP (con_dev_or_frame) && NILP (Fselected_device (Qnil)))
+    return Qnil; /* happens at startup */
+
+  {
+    struct frame *f = decode_frame_or_selected (con_dev_or_frame);
+    return FRAME_LAST_NONMINIBUF_WINDOW (f);
+  }
+}
+
 DEFUN ("minibuffer-window", Fminibuffer_window, 0, 1, 0, /*
 Return the window used now for minibuffers.
 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, return
@@ -1341,7 +1357,7 @@ is non-nil, do not include space occupied by clipped lines.
   if (NILP (window))
     window = Fselected_window (Qnil);
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   w = XWINDOW (window);
 
   start  = marker_position (w->start[CURRENT_DISP]);
@@ -1404,7 +1420,7 @@ DEFUN ("window-text-area-pixel-width",
        Fwindow_text_area_pixel_width, 0, 1, 0, /*
 Return the width in pixels of the text-displaying portion of WINDOW.
 Unlike `window-pixel-width', the space occupied by the vertical
-scrollbar or divider, if any, is not counted.  
+scrollbar or divider, if any, is not counted.
 */
      (window))
 {
@@ -3168,7 +3184,7 @@ BUFFER can be a buffer or buffer name.
   Fset_marker (w->sb_point, w->start[CURRENT_DISP], buffer);
   /* set start_at_line_beg correctly. GE */
   w->start_at_line_beg = beginning_of_line_p (XBUFFER (buffer),
-                                             marker_position (w->start[CURRENT_DISP]));  
+                                             marker_position (w->start[CURRENT_DISP]));
   w->force_start = 0;           /* Lucid fix */
   SET_LAST_MODIFIED (w, 1);
   SET_LAST_FACECHANGE (w);
@@ -3315,7 +3331,7 @@ make_dummy_parent (Lisp_Object window)
 {
   Lisp_Object new;
   struct window *o = XWINDOW (window);
-  struct window *p = alloc_lcrecord_type (struct window, lrecord_window);
+  struct window *p = alloc_lcrecord_type (struct window, &lrecord_window);
 
   XSETWINDOW (new, p);
   copy_lcrecord (p, o);
@@ -3362,7 +3378,7 @@ and put SIZE columns in the first of the pair.
   if (NILP (window))
     window = Fselected_window (Qnil);
   else
-    CHECK_WINDOW (window);
+    CHECK_LIVE_WINDOW (window);
 
   o = XWINDOW (window);
   f = XFRAME (WINDOW_FRAME (o));
@@ -3484,9 +3500,9 @@ and put SIZE columns in the first of the pair.
 \f
 
 DEFUN ("enlarge-window", Fenlarge_window, 1, 3, "_p", /*
-Make the selected window ARG lines bigger.
-From program, optional second arg non-nil means grow sideways ARG columns,
-and optional third ARG specifies the window to change instead of the
+Make the selected window N lines bigger.
+From program, optional second arg SIDE non-nil means grow sideways N columns,
+and optional third arg WINDOW specifies the window to change instead of the
 selected window.
 */
        (n, side, window))
@@ -3498,9 +3514,9 @@ selected window.
 }
 
 DEFUN ("enlarge-window-pixels", Fenlarge_window_pixels, 1, 3, "_p", /*
-Make the selected window ARG pixels bigger.
-From program, optional second arg non-nil means grow sideways ARG pixels,
-and optional third ARG specifies the window to change instead of the
+Make the selected window N pixels bigger.
+From program, optional second arg SIDE non-nil means grow sideways N pixels,
+and optional third arg WINDOW specifies the window to change instead of the
 selected window.
 */
        (n, side, window))
@@ -3512,9 +3528,9 @@ selected window.
 }
 
 DEFUN ("shrink-window", Fshrink_window, 1, 3, "_p", /*
-Make the selected window ARG lines smaller.
-From program, optional second arg non-nil means shrink sideways ARG columns,
-and optional third ARG specifies the window to change instead of the
+Make the selected window N lines smaller.
+From program, optional second arg SIDE non-nil means shrink sideways N columns,
+and optional third arg WINDOW specifies the window to change instead of the
 selected window.
 */
        (n, side, window))
@@ -3526,9 +3542,9 @@ selected window.
 }
 
 DEFUN ("shrink-window-pixels", Fshrink_window_pixels, 1, 3, "_p", /*
-Make the selected window ARG pixels smaller.
-From program, optional second arg non-nil means shrink sideways ARG pixels,
-and optional third ARG specifies the window to change instead of the
+Make the selected window N pixels smaller.
+From program, optional second arg SIDE non-nil means shrink sideways N pixels,
+and optional third arg WINDOW specifies the window to change instead of the
 selected window.
 */
        (n, side, window))
@@ -3912,7 +3928,7 @@ change_window_height (struct window *win, int delta, int widthflag,
       (*setsizefun) (window, *sizep + delta1, 0);
 
       /* Squeeze out delta1 lines or columns from our parent,
-        shriking this window and siblings proportionately.
+        shrinking this window and siblings proportionately.
         This brings parent back to correct size.
         Delta1 was calculated so this makes this window the desired size,
         taking it all out of the siblings.  */
@@ -3922,6 +3938,8 @@ change_window_height (struct window *win, int delta, int widthflag,
   SET_LAST_MODIFIED (w, 0);
   SET_LAST_FACECHANGE (w);
   MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
+  /* overkill maybe, but better to be correct */
+  MARK_FRAME_GUTTERS_CHANGED (f);
 }
 #undef MINSIZE
 #undef CURBEG
@@ -3931,7 +3949,8 @@ change_window_height (struct window *win, int delta, int widthflag,
 
 \f
 
-/* Scroll contents of window WINDOW up N lines.  */
+/* Scroll contents of window WINDOW up N lines. If N < (top line height /
+   average line height) then we just adjust the top clip.  */
 void
 window_scroll (Lisp_Object window, Lisp_Object n, int direction,
               Error_behavior errb)
@@ -3941,6 +3960,9 @@ window_scroll (Lisp_Object window, Lisp_Object n, int direction,
   int selected = EQ (window, Fselected_window (Qnil));
   int value = 0;
   Lisp_Object point, tem;
+  display_line_dynarr *dla;
+  int fheight, fwidth, modeline = 0;
+  struct display_line* dl;
 
   if (selected)
     point = make_int (BUF_PT (b));
@@ -3957,7 +3979,7 @@ window_scroll (Lisp_Object window, Lisp_Object n, int direction,
     }
 
   /* Always set force_start so that redisplay_window will run
-     thw window-scroll-functions.  */
+     the window-scroll-functions.  */
   w->force_start = 1;
 
   /* #### When the fuck does this happen?  I'm so glad that history has
@@ -3970,6 +3992,7 @@ window_scroll (Lisp_Object window, Lisp_Object n, int direction,
                         window, Qnil);
       Fset_marker (w->start[CURRENT_DISP], point, w->buffer);
       w->start_at_line_beg = beginning_of_line_p (b, XINT (point));
+      WINDOW_TEXT_TOP_CLIP (w) = 0;
       MARK_WINDOWS_CHANGED (w);
     }
 
@@ -4013,82 +4036,146 @@ window_scroll (Lisp_Object window, Lisp_Object n, int direction,
     {
       return;
     }
-  else if (value > 0)
-    {
-      int vtarget;
-      Bufpos startp, old_start;
 
-      old_start = marker_position (w->start[CURRENT_DISP]);
-      startp = vmotion (w, old_start, value, &vtarget);
+  /* Determine parameters to test for partial line scrolling with. */
+  dla = window_display_lines (w, CURRENT_DISP);
 
-      if (vtarget < value &&
-         (w->window_end_pos[CURRENT_DISP] == -1
-          || (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b))))
+  if (INTP (Vwindow_pixel_scroll_increment))
+    fheight = XINT (Vwindow_pixel_scroll_increment);
+  else if (!NILP (Vwindow_pixel_scroll_increment));
+    default_face_height_and_width (window, &fheight, &fwidth);
+  
+  if (Dynarr_length (dla) >= 1)
+    modeline = Dynarr_atp (dla, 0)->modeline;
+
+  dl = Dynarr_atp (dla, modeline);
+    
+  if (value > 0)
+    {
+      /* Go for partial display line scrolling. This just means bumping
+        the clip by a reasonable amount and redisplaying, everything else
+        remains unchanged. */
+      if (!NILP (Vwindow_pixel_scroll_increment)
+         &&
+         Dynarr_length (dla) >= (1 + modeline)
+         &&
+         (dl->ascent - dl->top_clip) - fheight * value > 0)
        {
-         maybe_signal_error (Qend_of_buffer, Qnil, Qwindow, errb);
-         return;
+         WINDOW_TEXT_TOP_CLIP (w) += value * fheight;
+         MARK_WINDOWS_CHANGED (w);
        }
       else
        {
-         set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
-                                w->buffer);
-         w->force_start = 1;
-         w->start_at_line_beg = beginning_of_line_p (b, startp);
-         MARK_WINDOWS_CHANGED (w);
+         int vtarget;
+         Bufpos startp, old_start;
+         
+         if (WINDOW_TEXT_TOP_CLIP (w))
+           {
+             WINDOW_TEXT_TOP_CLIP (w) = 0;
+             MARK_WINDOWS_CHANGED (w);
+           }
 
-         if (!point_would_be_visible (w, startp, XINT (point)))
+         old_start = marker_position (w->start[CURRENT_DISP]);
+         startp = vmotion (w, old_start, value, &vtarget);
+         
+         if (vtarget < value &&
+             (w->window_end_pos[CURRENT_DISP] == -1
+              || (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b))))
            {
-             if (selected)
-               BUF_SET_PT (b, startp);
-             else
-               set_marker_restricted (w->pointm[CURRENT_DISP],
-                                      make_int (startp),
-                                      w->buffer);
+             maybe_signal_error (Qend_of_buffer, Qnil, Qwindow, errb);
+             return;
+           }
+         else
+           {
+             set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
+                                    w->buffer);
+             w->force_start = 1;
+             w->start_at_line_beg = beginning_of_line_p (b, startp);
+             MARK_WINDOWS_CHANGED (w);
+             
+             if (!point_would_be_visible (w, startp, XINT (point)))
+               {
+                 if (selected)
+                   BUF_SET_PT (b, startp);
+                 else
+                   set_marker_restricted (w->pointm[CURRENT_DISP],
+                                          make_int (startp),
+                                          w->buffer);
+               }
            }
        }
     }
   else if (value < 0)
     {
-      int vtarget;
-      Bufpos startp, old_start;
-
-      old_start = marker_position (w->start[CURRENT_DISP]);
-      startp = vmotion (w, old_start, value, &vtarget);
-
-      if (vtarget > value
-         && marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b))
+      /* Go for partial display line scrolling. This just means bumping
+        the clip by a reasonable amount and redisplaying, everything else
+        remains unchanged. */
+      if (!NILP (Vwindow_pixel_scroll_increment)
+         &&
+         Dynarr_length (dla) >= (1 + modeline)
+         &&
+         (dl->ascent - dl->top_clip) - fheight * value <
+         (dl->ascent + dl->descent - dl->clip)
+         &&
+         WINDOW_TEXT_TOP_CLIP (w) + value * fheight > 0)
        {
-         maybe_signal_error (Qbeginning_of_buffer, Qnil, Qwindow, errb);
-         return;
+         WINDOW_TEXT_TOP_CLIP (w) += value * fheight;
+         MARK_WINDOWS_CHANGED (w);
        }
       else
        {
-         set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
-                                w->buffer);
-         w->force_start = 1;
-         w->start_at_line_beg = beginning_of_line_p (b, startp);
-         MARK_WINDOWS_CHANGED (w);
-
-         if (!point_would_be_visible (w, startp, XINT (point)))
+         int vtarget;
+         Bufpos startp, old_start;
+         
+         if (WINDOW_TEXT_TOP_CLIP (w))
            {
-             Bufpos new_point;
-
-             if (MINI_WINDOW_P (w))
-               new_point = startp;
-             else
-               new_point = start_of_last_line (w, startp);
-
-             if (selected)
-               BUF_SET_PT (b, new_point);
-             else
-               set_marker_restricted (w->pointm[CURRENT_DISP],
-                                      make_int (new_point),
-                                      w->buffer);
+             WINDOW_TEXT_TOP_CLIP (w) = 0;
+             MARK_WINDOWS_CHANGED (w);
+           }
+             
+         old_start = marker_position (w->start[CURRENT_DISP]);
+         startp = vmotion (w, old_start, value, &vtarget);
+         
+         if (vtarget > value
+             && marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b))
+           {
+             maybe_signal_error (Qbeginning_of_buffer, Qnil, Qwindow, errb);
+             return;
+           }
+         else
+           {
+             set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
+                                    w->buffer);
+             w->force_start = 1;
+             w->start_at_line_beg = beginning_of_line_p (b, startp);
+             MARK_WINDOWS_CHANGED (w);
+             
+             if (!point_would_be_visible (w, startp, XINT (point)))
+               {
+                 Bufpos new_point;
+                 
+                 if (MINI_WINDOW_P (w))
+                   new_point = startp;
+                 else
+                   new_point = start_of_last_line (w, startp);
+                 
+                 if (selected)
+                   BUF_SET_PT (b, new_point);
+                 else
+                   set_marker_restricted (w->pointm[CURRENT_DISP],
+                                          make_int (new_point),
+                                          w->buffer);
+               }
            }
        }
     }
   else /* value == 0 && direction == -1 */
     {
+      if (WINDOW_TEXT_TOP_CLIP (w))
+       {
+         WINDOW_TEXT_TOP_CLIP (w) = 0;
+         MARK_WINDOWS_CHANGED (w);
+       }
       if (marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b))
        {
          maybe_signal_error (Qbeginning_of_buffer, Qnil, Qwindow, errb);
@@ -4126,14 +4213,13 @@ window_scroll (Lisp_Object window, Lisp_Object n, int direction,
            }
        }
     }
-
 }
 \f
 DEFUN ("scroll-up", Fscroll_up, 0, 1, "_P", /*
-Scroll text of current window upward ARG lines; or near full screen if no ARG.
+Scroll text of current window upward N lines; or near full screen if no arg.
 A near full screen is `next-screen-context-lines' less than a full screen.
-Negative ARG means scroll downward.
-When calling from a program, supply a number as argument or nil.
+Negative N means scroll downward.
+When calling from a program, supply an integer as argument or nil.
 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
 signaled.
@@ -4145,9 +4231,9 @@ signaled.
 }
 
 DEFUN ("scroll-down", Fscroll_down, 0, 1, "_P", /*
-Scroll text of current window downward ARG lines; or near full screen if no ARG.
+Scroll text of current window downward N lines; or near full screen if no arg.
 A near full screen is `next-screen-context-lines' less than a full screen.
-Negative ARG means scroll upward.
+Negative N means scroll upward.
 When calling from a program, supply a number as argument or nil.
 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
@@ -4205,9 +4291,9 @@ showing that buffer is used.
  }
 
 DEFUN ("scroll-other-window", Fscroll_other_window, 0, 1, "_P", /*
-Scroll next window upward ARG lines; or near full frame if no ARG.
+Scroll next window upward N lines; or near full frame if no arg.
 The next window is the one below the current one; or the one at the top
-if the current one is at the bottom.  Negative ARG means scroll downward.
+if the current one is at the bottom.  Negative N means scroll downward.
 When calling from a program, supply a number as argument or nil.
 
 If in the minibuffer, `minibuffer-scroll-window' if non-nil
@@ -4222,37 +4308,33 @@ showing that buffer, popping the buffer up if necessary.
 }
 \f
 DEFUN ("scroll-left", Fscroll_left, 0, 1, "_P", /*
-Scroll selected window display ARG columns left.
-Default for ARG is window width minus 2.
+Scroll selected window display N columns left.
+Default for N is window width minus 2.
 */
-       (arg))
+       (n))
 {
   Lisp_Object window = Fselected_window (Qnil);
   struct window *w = XWINDOW (window);
+  int count = (NILP (n) ?
+              window_char_width (w, 0) - 2 :
+              XINT (Fprefix_numeric_value (n)));
 
-  if (NILP (arg))
-    arg = make_int (window_char_width (w, 0) - 2);
-  else
-    arg = Fprefix_numeric_value (arg);
-
-  return Fset_window_hscroll (window, make_int (w->hscroll + XINT (arg)));
+  return Fset_window_hscroll (window, make_int (w->hscroll + count));
 }
 
 DEFUN ("scroll-right", Fscroll_right, 0, 1, "_P", /*
-Scroll selected window display ARG columns right.
-Default for ARG is window width minus 2.
+Scroll selected window display N columns right.
+Default for N is window width minus 2.
 */
-       (arg))
+       (n))
 {
   Lisp_Object window = Fselected_window (Qnil);
   struct window *w = XWINDOW (window);
+  int count = (NILP (n) ?
+              window_char_width (w, 0) - 2 :
+              XINT (Fprefix_numeric_value (n)));
 
-  if (NILP (arg))
-    arg = make_int (window_char_width (w, 0) - 2);
-  else
-    arg = Fprefix_numeric_value (arg);
-
-  return Fset_window_hscroll (window, make_int (w->hscroll - XINT (arg)));
+  return Fset_window_hscroll (window, make_int (w->hscroll - count));
 }
 \f
 DEFUN ("center-to-window-line", Fcenter_to_window_line, 0, 2, "_P", /*
@@ -4304,7 +4386,7 @@ If WINDOW is nil, the selected window is used.
   if (NILP (window))
     window = Fselected_window (Qnil);
   else
-    CHECK_WINDOW (window);
+    CHECK_LIVE_WINDOW (window);
   w = XWINDOW (window);
   b = XBUFFER (w->buffer);
 
@@ -4431,7 +4513,7 @@ map_windows_1 (Lisp_Object window,
    non-zero, the mapping is halted.  Otherwise, map_windows() maps
    over all windows in F.
 
-   If MAPFUN creates or deletes windows, the behaviour is undefined.  */
+   If MAPFUN creates or deletes windows, the behavior is undefined.  */
 
 int
 map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure),
@@ -4447,7 +4529,7 @@ map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure),
        {
          int v = map_windows_1 (FRAME_ROOT_WINDOW (XFRAME (XCAR (frmcons))),
                                 mapfun, closure);
-         if (v)     
+         if (v)
            return v;
        }
     }
@@ -4465,8 +4547,8 @@ modeline_shadow_thickness_changed (Lisp_Object specifier, struct window *w,
 }
 
 static void
-vertical_divider_changed_in_window (Lisp_Object specifier, 
-                                   struct window *w, 
+vertical_divider_changed_in_window (Lisp_Object specifier,
+                                   struct window *w,
                                    Lisp_Object oldval)
 {
   MARK_WINDOWS_CHANGED (w);
@@ -4621,8 +4703,8 @@ struct saved_window
 struct window_config
 {
   struct lcrecord_header header;
-  int frame_width;
-  int frame_height;
+  /*  int frame_width; No longer needed, JV
+      int frame_height; */
 #if 0 /* FSFmacs */
   Lisp_Object selected_frame;
 #endif
@@ -4630,6 +4712,7 @@ struct window_config
   Lisp_Object current_buffer;
   Lisp_Object minibuffer_scroll_window;
   Lisp_Object root_window;
+  int minibuf_height; /* 0 = no minibuffer, <0, size in lines, >0 in pixels */
   /* Record the values of window-min-width and window-min-height
      so that window sizes remain consistent with them.  */
   int min_width, min_height;
@@ -4646,32 +4729,32 @@ struct window_config
 #define CHECK_WINDOW_CONFIGURATION(x) CHECK_RECORD (x, window_configuration)
 
 static Lisp_Object
-mark_window_config (Lisp_Object obj, void (*markobj) (Lisp_Object))
+mark_window_config (Lisp_Object obj)
 {
   struct window_config *config = XWINDOW_CONFIGURATION (obj);
   int i;
-  ((markobj) (config->current_window));
-  ((markobj) (config->current_buffer));
-  ((markobj) (config->minibuffer_scroll_window));
-  ((markobj) (config->root_window));
+  mark_object (config->current_window);
+  mark_object (config->current_buffer);
+  mark_object (config->minibuffer_scroll_window);
+  mark_object (config->root_window);
 
   for (i = 0; i < config->saved_windows_count; i++)
     {
       struct saved_window *s = SAVED_WINDOW_N (config, i);
-      ((markobj) (s->window));
-      ((markobj) (s->buffer));
-      ((markobj) (s->start));
-      ((markobj) (s->pointm));
-      ((markobj) (s->sb_point));
-      ((markobj) (s->mark));
+      mark_object (s->window);
+      mark_object (s->buffer);
+      mark_object (s->start);
+      mark_object (s->pointm);
+      mark_object (s->sb_point);
+      mark_object (s->mark);
 #if 0
       /* #### This looked like this. I do not see why specifier cached
         values should not be marked, as such specifiers as toolbars
         might have GC-able instances. Freed configs are not marked,
         aren't they?  -- kkm */
-      ((markobj) (s->dedicated));
+      mark_object (s->dedicated);
 #else
-#define WINDOW_SLOT(slot, compare) ((markobj) (s->slot))
+#define WINDOW_SLOT(slot, compare) mark_object (s->slot)
 #include "winslots.h"
 #endif
     }
@@ -4710,7 +4793,7 @@ DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("window-configuration",
                                        window_configuration,
                                        mark_window_config,
                                        print_window_config,
-                                       0, 0, 0, sizeof_window_config,
+                                       0, 0, 0, 0, sizeof_window_config,
                                        struct window_config);
 
 
@@ -4761,9 +4844,10 @@ window_config_equal (Lisp_Object conf1, Lisp_Object conf2)
        EQ (fig1->current_window,           fig2->current_window) &&
        EQ (fig1->current_buffer,           fig2->current_buffer) &&
        EQ (fig1->root_window,              fig2->root_window) &&
-       EQ (fig1->minibuffer_scroll_window, fig2->minibuffer_scroll_window) &&
+       EQ (fig1->minibuffer_scroll_window, fig2->minibuffer_scroll_window)))
+       /* &&
        fig1->frame_width  == fig2->frame_width &&
-       fig1->frame_height == fig2->frame_height))
+       fig1->frame_height == fig2->frame_height)) */
     return 0;
 
   for (i = 0; i < fig1->saved_windows_count; i++)
@@ -4859,8 +4943,15 @@ by `current-window-configuration' (which see).
   struct frame *f;
   struct gcpro gcpro1;
   Lisp_Object old_window_config;
-  int previous_frame_height;
-  int previous_frame_width;
+  /*  int previous_frame_height;
+      int previous_frame_width;*/
+  int previous_pixel_top;
+  int previous_pixel_height;
+  int previous_pixel_left;
+  int previous_pixel_width;
+  int previous_minibuf_height, previous_minibuf_top,previous_minibuf_width;
+  int real_font_height;
+  int converted_minibuf_height,target_minibuf_height; 
   int specpdl_count = specpdl_depth ();
 
   GCPRO1 (configuration);
@@ -4925,6 +5016,20 @@ by `current-window-configuration' (which see).
 
       mark_windows_in_use (f, 1);
 
+#if 0
+      /* JV: This is bogus,
+        First of all, the units are inconsistent. The frame sizes are measured
+        in characters but the window sizes are stored in pixels. So if a 
+        font size change happened between saving and restoring, the
+        frame "sizes" maybe equal but the windows still should be
+        resized. This is tickled alot by the new "character size
+        stays constant" policy in 21.0. It leads to very wierd
+        glitches (and possibly craches when asserts are tickled).
+
+        Just changing the units doens't help because changing the
+        toolbar configuration can also change the pixel positions.
+        Luckily there is a much simpler way of doing this, see below.
+       */
       previous_frame_width = FRAME_WIDTH (f);
       previous_frame_height = FRAME_HEIGHT (f);
       /* If the frame has been resized since this window configuration was
@@ -4934,7 +5039,37 @@ by `current-window-configuration' (which see).
       if (config->frame_height != FRAME_HEIGHT (f)
          || config->frame_width != FRAME_WIDTH (f))
        change_frame_size (f, config->frame_height, config->frame_width, 0);
+#endif
+      
+      previous_pixel_top = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top;
+      previous_pixel_height = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_height;
+      previous_pixel_left = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left;
+      previous_pixel_width = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_width;
+
+      /* remember some properties of the minibuffer */
 
+      default_face_height_and_width (frame, &real_font_height, 0);
+      assert(real_font_height > 0);
+  
+      if (FRAME_HAS_MINIBUF_P (f) && ! FRAME_MINIBUF_ONLY_P (f))
+       {
+         previous_minibuf_height
+           = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height;
+         previous_minibuf_top
+           = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_top;
+         previous_minibuf_width
+           = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_width;
+       }
+      else
+       {
+         previous_minibuf_height = 0;
+         previous_minibuf_width = 0;
+       }
+      converted_minibuf_height =
+       (previous_minibuf_height % real_font_height) == 0 ?
+       - (previous_minibuf_height / real_font_height ) :    /* lines */
+           previous_minibuf_height;   /* pixels */
+           
       /* Temporarily avoid any problems with windows that are smaller
         than they are supposed to be.  */
       window_min_height = 1;
@@ -5022,7 +5157,7 @@ by `current-window-configuration' (which see).
          SET_LAST_FACECHANGE (w);
          w->config_mark = 0;
 
-#define WINDOW_SLOT(slot, compare) w->slot = p->slot;
+#define WINDOW_SLOT(slot, compare) w->slot = p->slot
 #include "winslots.h"
 
          /* Reinstall the saved buffer and pointers into it.  */
@@ -5100,11 +5235,61 @@ by `current-window-configuration' (which see).
         currently selected, or just set the selected window of the
         window config's frame. */
 
+#if 0
       /* Set the frame height to the value it had before this function.  */
       if (previous_frame_height != FRAME_HEIGHT (f)
          || previous_frame_width != FRAME_WIDTH (f))
        change_frame_size (f, previous_frame_height, previous_frame_width, 0);
-
+#endif
+      /* We just reset the size and position of the minibuffer, to its old
+        value, which needn't be valid. So we do some magic to see which value
+        to actually take. Then we set it.
+
+        The magic:
+        We take the old value if is in the same units but differs from the
+        current value.
+
+         #### Now we get more cases correct then ever before, but
+        are we treating all? For instance what if the frames minibuf window
+        is no longer the same one? 
+      */
+      target_minibuf_height = previous_minibuf_height;
+      if (converted_minibuf_height &&
+         (converted_minibuf_height * config->minibuf_height) > 0 &&
+         (converted_minibuf_height !=  config->minibuf_height))
+       {
+         target_minibuf_height = config->minibuf_height < 0 ?
+           - (config->minibuf_height * real_font_height) :
+           config->minibuf_height;
+         target_minibuf_height =
+           max(target_minibuf_height,real_font_height);
+       }
+      if (previous_minibuf_height)
+       {
+         XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top
+           = previous_minibuf_top -
+                 (target_minibuf_height - previous_minibuf_height);
+         set_window_pixheight (FRAME_MINIBUF_WINDOW (f),
+                               target_minibuf_height, 0);
+         set_window_pixwidth  (FRAME_MINIBUF_WINDOW (f),
+                           previous_minibuf_width, 0);
+       }
+       
+      /* This is a better way to deal with frame resizing, etc.
+        What we _actually_ want is for the old (just restored)
+        root window to fit
+        into the place of the new one. So we just do that. Simple! */
+      XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top = previous_pixel_top;
+      /* Note that this function also updates the subwindow
+        "pixel_top"s */
+      set_window_pixheight (FRAME_ROOT_WINDOW (f),
+         previous_pixel_height -
+                 (target_minibuf_height - previous_minibuf_height), 0);
+      XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = previous_pixel_left;
+      /* Note that this function also updates the subwindow
+        "pixel_left"s */
+      set_window_pixwidth (FRAME_ROOT_WINDOW (f), previous_pixel_width, 0);
+      
       /* If restoring in the current frame make the window current,
         otherwise just update the frame selected_window slot to be
         the restored current_window. */
@@ -5246,7 +5431,7 @@ save_window_save (Lisp_Object window, struct window_config *config, int i)
       p->hscroll = w->hscroll;
       p->modeline_hscroll = w->modeline_hscroll;
 
-#define WINDOW_SLOT(slot, compare) p->slot = w->slot;
+#define WINDOW_SLOT(slot, compare) p->slot = w->slot
 #include "winslots.h"
 
       if (!NILP (w->buffer))
@@ -5319,6 +5504,8 @@ its value is -not- saved.
   struct frame *f = decode_frame (frame);
   struct window_config *config;
   int n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
+  int minibuf_height;
+  int real_font_height;
 
   if (n_windows <= countof (Vwindow_configuration_free_list))
     config = XWINDOW_CONFIGURATION (allocate_managed_lcrecord
@@ -5328,11 +5515,11 @@ its value is -not- saved.
     /* More than ten windows; just allocate directly */
     config = (struct window_config *)
       alloc_lcrecord (sizeof_window_config_for_n_windows (n_windows),
-                     lrecord_window_configuration);
+                     &lrecord_window_configuration);
   XSETWINDOW_CONFIGURATION (result, config);
-
+  /*
   config->frame_width = FRAME_WIDTH (f);
-  config->frame_height = FRAME_HEIGHT (f);
+  config->frame_height = FRAME_HEIGHT (f); */
   config->current_window = FRAME_SELECTED_WINDOW (f);
   XSETBUFFER (config->current_buffer, current_buffer);
   config->minibuffer_scroll_window = Vminibuffer_scroll_window;
@@ -5341,6 +5528,22 @@ its value is -not- saved.
   config->min_width = window_min_width;
   config->saved_windows_count = n_windows;
   save_window_save (FRAME_ROOT_WINDOW (f), config, 0);
+
+  /* save the minibuffer height using the heuristics from
+     change_frame_size_1 */
+  
+  XSETFRAME (frame, f); /* frame could have been nil ! */
+  default_face_height_and_width (frame, &real_font_height, 0);
+  assert(real_font_height > 0);
+  
+  if (FRAME_HAS_MINIBUF_P (f) && ! FRAME_MINIBUF_ONLY_P (f))
+    minibuf_height = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height;
+  else
+    minibuf_height = 0;
+  config->minibuf_height = (minibuf_height % real_font_height) == 0 ?
+    - (minibuf_height / real_font_height ) :    /* lines */
+    minibuf_height;   /* pixels */
+
   return result;
 }
 
@@ -5370,6 +5573,78 @@ Does not restore the value of point in current buffer.
   return unbind_to (speccount, val);
 }
 
+DEFUN ("current-pixel-column", Fcurrent_pixel_column, 0, 2, 0, /*
+Return the horizontal pixel position of POS in window.
+Beginning of line is column 0. This is calculated using the redisplay
+display tables.  If WINDOW is nil, the current window is assumed.
+If POS is nil, point is assumed. Note that POS must be visible for
+a non-nil result to be returned.
+*/
+       (window, pos))
+{
+  struct window* w = decode_window (window);
+  display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
+
+  struct display_line *dl = 0;
+  struct display_block *db = 0;
+  struct rune* rb = 0;
+  int y = w->last_point_y[CURRENT_DISP];
+  int x = w->last_point_x[CURRENT_DISP];
+
+  if (MINI_WINDOW_P (w))
+    return Qnil;
+
+  if (y<0 || x<0 || y >= Dynarr_length (dla) || !NILP (pos))
+    {
+      int first_line, i;
+      Bufpos point;
+
+      if (NILP (pos))
+       pos = Fwindow_point (window);
+      
+      CHECK_INT (pos);
+      point = XINT (pos);
+
+      if (Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline)
+       first_line = 1;
+      else
+       first_line = 0;
+
+      for (i = first_line; i < Dynarr_length (dla); i++)
+       {
+         dl = Dynarr_atp (dla, i);
+         /* find the vertical location first */
+         if (point >= dl->bufpos && point <= dl->end_bufpos)
+           {
+             db = get_display_block_from_line (dl, TEXT);
+             for (i = 0; i < Dynarr_length (db->runes); i++)
+               {
+                 rb = Dynarr_atp (db->runes, i);
+                 if (point <= rb->bufpos)
+                   goto found_bufpos;
+               }
+             return Qnil;
+           }
+       }
+      return Qnil;
+    found_bufpos:
+      ;
+    }
+  else
+    {
+      /* optimised case */
+      dl = Dynarr_atp (dla, y);
+      db = get_display_block_from_line (dl, TEXT);
+
+      if (x >= Dynarr_length (db->runes))
+       return Qnil;
+
+      rb = Dynarr_atp (db->runes, x);
+    }
+
+  return make_int (rb->xpos - WINDOW_LEFT (w));
+}
+
 \f
 #ifdef DEBUG_XEMACS
 /* This is short and simple in elisp, but... it was written to debug
@@ -5422,8 +5697,6 @@ syms_of_window (void)
   defsymbol (&Qwindowp, "windowp");
   defsymbol (&Qwindow_live_p, "window-live-p");
   defsymbol (&Qwindow_configurationp, "window-configuration-p");
-  defsymbol (&Qscroll_up, "scroll-up");
-  defsymbol (&Qscroll_down, "scroll-down");
   defsymbol (&Qtemp_buffer_show_hook, "temp-buffer-show-hook");
   defsymbol (&Qdisplay_buffer, "display-buffer");
 
@@ -5439,6 +5712,7 @@ syms_of_window (void)
 #endif
 
   DEFSUBR (Fselected_window);
+  DEFSUBR (Flast_nonminibuf_window);
   DEFSUBR (Fminibuffer_window);
   DEFSUBR (Fwindow_minibuffer_p);
   DEFSUBR (Fwindowp);
@@ -5449,6 +5723,7 @@ syms_of_window (void)
   DEFSUBR (Fwindow_previous_child);
   DEFSUBR (Fwindow_parent);
   DEFSUBR (Fwindow_lowest_p);
+  DEFSUBR (Fwindow_truncated_p);
   DEFSUBR (Fwindow_highest_p);
   DEFSUBR (Fwindow_leftmost_p);
   DEFSUBR (Fwindow_rightmost_p);
@@ -5517,14 +5792,30 @@ syms_of_window (void)
   DEFSUBR (Fset_window_configuration);
   DEFSUBR (Fcurrent_window_configuration);
   DEFSUBR (Fsave_window_excursion);
+  DEFSUBR (Fcurrent_pixel_column);
 }
 
 void
-vars_of_window (void)
+reinit_vars_of_window (void)
 {
+  int i;
   /* Make sure all windows get marked */
   minibuf_window = Qnil;
-  staticpro (&minibuf_window);
+  staticpro_nodump (&minibuf_window);
+
+  for (i = 0; i < countof (Vwindow_configuration_free_list); i++)
+    {
+      Vwindow_configuration_free_list[i] =
+       make_lcrecord_list (sizeof_window_config_for_n_windows (i + 1),
+                           &lrecord_window_configuration);
+      staticpro_nodump (&Vwindow_configuration_free_list[i]);
+    }
+}
+
+void
+vars_of_window (void)
+{
+  reinit_vars_of_window ();
 
   DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /*
 *Non-nil means to scroll if point lands on a line which is clipped.
@@ -5555,6 +5846,13 @@ If non-nil, this is a buffer and \\[scroll-other-window] should scroll its windo
 */ );
   Vother_window_scroll_buffer = Qnil;
 
+  DEFVAR_LISP ("window-pixel-scroll-increment", &Vwindow_pixel_scroll_increment /*
+*Number of pixels to scroll by per requested line.
+If nil then normal line scrolling occurs regardless of line height.
+If t then scrolling is done in increments equal to the height of the default face.
+*/ );
+  Vwindow_pixel_scroll_increment = Qt;
+
   DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines /*
 *Number of lines of continuity when scrolling by screenfuls.
 */ );
@@ -5569,18 +5867,6 @@ If non-nil, this is a buffer and \\[scroll-other-window] should scroll its windo
 *Delete any window less than this wide.
 */ );
   window_min_width = 10;
-
-  {
-    int i;
-
-    for (i = 0; i < countof (Vwindow_configuration_free_list); i++)
-      {
-       Vwindow_configuration_free_list[i] =
-         make_lcrecord_list (sizeof_window_config_for_n_windows (i + 1),
-                             lrecord_window_configuration);
-       staticpro (&Vwindow_configuration_free_list[i]);
-      }
-  }
 }
 
 void
@@ -5605,7 +5891,7 @@ This is a specifier; use `set-specifier' to change it.
                                      modeline_shadow_thickness),
                         modeline_shadow_thickness_changed,
                         0, 0);
-  
+
   DEFVAR_SPECIFIER ("has-modeline-p", &Vhas_modeline_p /*
 *Whether the modeline should be displayed.
 This is a specifier; use `set-specifier' to change it.
@@ -5643,7 +5929,7 @@ This is a specifier; use `set-specifier' to change it.
                         0, 0);
 
   DEFVAR_SPECIFIER ("vertical-divider-shadow-thickness", &Vvertical_divider_shadow_thickness /*
-*How thick to draw 3D shadows around vertical dividers. 
+*How thick to draw 3D shadows around vertical dividers.
 This is a specifier; use `set-specifier' to change it.
 */ );
   Vvertical_divider_shadow_thickness = Fmake_specifier (Qinteger);