Because we read English from left to right in the "inner loop", and
from top to bottom in the "outer loop", horizontal scrolling is not
like vertical scrolling. Vertical scrolling involves selection of a
contiguous portion of text to display, but horizontal scrolling causes
part of each line to go off screen. The amount of horizontal scrolling
is therefore specified as a number of columns rather than as a position
in the buffer. It has nothing to do with the display-start position
returned by window-start
.
Usually, no horizontal scrolling is in effect; then the leftmost column is at the left edge of the window. In this state, scrolling to the right is meaningless, since there is no data to the left of the screen to be revealed by it; so this is not allowed. Scrolling to the left is allowed; it scrolls the first columns of text off the edge of the window and can reveal additional columns on the right that were truncated before. Once a window has a nonzero amount of leftward horizontal scrolling, you can scroll it back to the right, but only so far as to reduce the net horizontal scroll to zero. There is no limit to how far left you can scroll, but eventually all the text will disappear off the left edge.
window-hscroll
(below).
window-hscroll
(below).
Once you scroll a window as far right as it can go, back to its normal position where the total leftward scrolling is zero, attempts to scroll any farther right have no effect.
The value is never negative. It is zero when no horizontal scrolling has been done in window (which is usually the case).
If window is nil
, the selected window is used.
(window-hscroll) => 0 (scroll-left 5) => 5 (window-hscroll) => 5
The value returned is columns.
(set-window-hscroll (selected-window) 10) => 10
Here is how you can determine whether a given position position is off the screen due to horizontal scrolling:
(defun hscroll-on-screen (window position) (save-excursion (goto-char position) (and (>= (- (current-column) (window-hscroll window)) 0) (< (- (current-column) (window-hscroll window)) (window-width window)))))
Go to the first, previous, next, last section, table of contents.