Function: set-window-vscroll

set-window-vscroll is a function defined in window.c.

Signature

(set-window-vscroll WINDOW VSCROLL &optional PIXELS-P PRESERVE-VSCROLL-P)

Documentation

Set amount by which WINDOW should be scrolled vertically to VSCROLL.

This takes effect when displaying tall lines or images.

WINDOW nil means use the selected window. Normally, VSCROLL is a non-negative multiple of the canonical character height of WINDOW; optional third arg PIXELS-P non-nil means that VSCROLL is in pixels. If PIXELS-P is nil, VSCROLL may have to be rounded so that it corresponds to an integral number of pixels. The return value is the result of this rounding. If PIXELS-P is non-nil, the return value is VSCROLL.

PRESERVE-VSCROLL-P makes setting the start of WINDOW preserve the vscroll if its start is "frozen" due to a resized mini-window.

View in manual

Probably introduced at or before Emacs version 21.1.

Source Code

// Defined in /usr/src/emacs/src/window.c
{
  struct window *w = decode_live_window (window);
  struct frame *f = XFRAME (w->frame);

  CHECK_NUMBER (vscroll);

  if (FRAME_WINDOW_P (f))
    {
      int old_dy = w->vscroll;

      w->vscroll = - (NILP (pixels_p)
		      ? FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll)
		      : XFLOATINT (vscroll));
      w->vscroll = min (w->vscroll, 0);

      if (w->vscroll != old_dy)
	{
	  /* Adjust glyph matrix of the frame if the virtual display
	     area becomes larger than before.  */
	  if (w->vscroll < 0 && w->vscroll < old_dy)
	    adjust_frame_glyphs (f);

	  /* Prevent redisplay shortcuts.  */
	  XBUFFER (w->contents)->prevent_redisplay_optimizations_p = true;

	  /* Mark W for redisplay.  (bug#55299) */
	  wset_redisplay (w);
	}

      w->preserve_vscroll_p = !NILP (preserve_vscroll_p);
    }

  return Fwindow_vscroll (window, pixels_p);
}