Info Node: (lispref.info)Horizontal Scrolling

lispref.info: Horizontal Scrolling
Windows
Size of Window
Vertical Scrolling
Back to Software Index
Horizontal Scrolling
====================
Because we read English first from top to bottom and second from left
to right, horizontal scrolling is not like vertical scrolling. Vertical
scrolling involves selection of a contiguous portion of text to display.
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.
- Command: scroll-left COUNT
This function scrolls the selected window COUNT columns to the
left (or to the right if COUNT is negative). The return value is
the total amount of leftward horizontal scrolling in effect after
the change--just like the value returned by `window-hscroll'
(below).
- Command: scroll-right COUNT
This function scrolls the selected window COUNT columns to the
right (or to the left if COUNT is negative). The return value is
the total amount of leftward horizontal scrolling in effect after
the change--just like the value returned by `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.
- Function: window-hscroll &optional WINDOW
This function returns the total leftward horizontal scrolling of
WINDOW--the number of columns by which the text in WINDOW is
scrolled left past the left margin.
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
- Function: set-window-hscroll WINDOW COLUMNS
This function sets the number of columns from the left margin that
WINDOW is scrolled to the value of COLUMNS. The argument COLUMNS
should be zero or positive; if not, it is taken as zero.
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)))))
automatically generated by info2www version 1.2