Function: set-window-start
set-window-start is a function defined in window.c.
Signature
(set-window-start WINDOW POS &optional NOFORCE)
Documentation
Make display in WINDOW start at position POS in WINDOW's buffer.
WINDOW must be a live window and defaults to the selected one. Return POS.
Optional third arg NOFORCE non-nil prevents next redisplay from moving point if displaying the window at POS makes point invisible; redisplay will then choose the WINDOW's start position by itself in that case, i.e. it will disregard POS if adhering to it will make point not visible in the window.
For reliable setting of WINDOW start position, make sure point is at a position that will be visible when that start is in effect, otherwise there's a chance POS will be disregarded, e.g., if point winds up in a partially-visible line.
The setting of the WINDOW's start position takes effect during the
next redisplay cycle, not immediately. If NOFORCE is nil or
omitted, forcing the display of WINDOW to start at POS cancels
any setting of WINDOW's vertical scroll ("vscroll") amount
set by set-window-vscroll and by scrolling functions.
Probably introduced at or before Emacs version 16.
Source Code
// Defined in /usr/src/emacs/src/window.c
{
register struct window *w = decode_live_window (window);
set_marker_restricted (w->start, pos, w->contents);
/* This is not right, but much easier than doing what is right. */
w->start_at_line_beg = false;
if (NILP (noforce))
w->force_start = true;
wset_update_mode_line (w);
/* Bug#15957. */
w->window_end_valid = false;
wset_redisplay (w);
return pos;
}