Each window contains a marker used to keep track of a buffer position that specifies where in the buffer display should start. This position is called the display-start position of the window (or just the start). The character after this position is the one that appears at the upper left corner of the window. It is usually, but not inevitably, at the beginning of a text line.
This function returns the display-start position of window window. If window is
nil, the selected window is used. For example,(window-start) ⇒ 7058When you create a window, or display a different buffer in it, the display-start position is set to a display-start position recently used for the same buffer, or 1 if the buffer doesn't have any.
For a realistic example, see the description of
count-linesin Text Lines.
This function returns the position of the end of the display in window window. If window is
nil, the selected window is used.Simply changing the buffer text or setting
window-startdoes not update the value thatwindow-endreturns. The value is updated only when SXEmacs redisplays and redisplay actually finishes.If the last redisplay of window was preempted, and did not finish, SXEmacs does not know the position of the end of display in that window. In that case, this function returns a value that is not correct. In a future version,
window-endwill returnnilin that case.If optional arg guarantee is non-
nil, the return value is guaranteed to be the same aswindow-endwould return at the end of the next full redisplay assuming nothing else changes in the meantime. This function is potentially much slower with this flag set.
This function sets the display-start position of window to position in window's buffer. It returns position.
The display routines insist that the position of point be visible when a buffer is displayed. Normally, they change the display-start position (that is, scroll the window) whenever necessary to make point visible. However, if you specify the start position with this function using
nilfor noforce, it means you want display to start at position even if that would put the location of point off the screen. If this does place point off screen, the display routines move point to the left margin on the middle line in the window.For example, if point is 1 and you set the start of the window to 2, then point would be “above” the top of the window. The display routines will automatically move point if it is still 1 when redisplay occurs. Here is an example:
;; Here is what ‘foo’ looks like before executing ;; theset-window-startexpression. ---------- Buffer: foo ---------- -!-This is the contents of buffer foo. 2 3 4 5 6 ---------- Buffer: foo ---------- (set-window-start (selected-window) (1+ (window-start))) ⇒ 2 ;; Here is what ‘foo’ looks like after executing ;; theset-window-startexpression. ---------- Buffer: foo ---------- his is the contents of buffer foo. 2 3 -!-4 5 6 ---------- Buffer: foo ----------If noforce is non-
nil, and position would place point off screen at the next redisplay, then redisplay computes a new window-start position that works well with point, and thus position is not used.
This function returns
tif position is within the range of text currently visible on the screen in window. It returnsnilif position is scrolled vertically out of view. The argument position defaults to the current position of point; window, to the selected window. Here is an example:(or (pos-visible-in-window-p (point) (selected-window)) (recenter 0))The
pos-visible-in-window-pfunction considers only vertical scrolling. If position is out of view only because window has been scrolled horizontally,pos-visible-in-window-preturnst. See Horizontal Scrolling.