41.3 Truncation

When a line of text extends beyond the right edge of a window, Emacs can continue the line (make it wrap to the next screen line), or truncate the line (limit it to one screen line). The additional screen lines used to display a long text line are called continuation lines. Continuation is not the same as filling; continuation happens on the screen only, not in the buffer contents, and it breaks a line precisely at the right margin, not at a word boundary. See Filling.

On a graphical display, tiny arrow images in the window fringes indicate truncated and continued lines (see Fringes). On a text terminal, a ‘$’ in the rightmost column of the window indicates truncation; a ‘\’ on the rightmost column indicates a line that wraps. (The display table can specify alternate characters to use for this; see Display Tables).

Since wrapping and truncation of text contradict each other, Emacs turns off line truncation when wrapping is requested, and vice versa.

User Option: truncate-lines

If this buffer-local variable is non-nil, lines that extend beyond the right edge of the window are truncated; otherwise, they are continued. As a special exception, the variable truncate-partial-width-windows takes precedence in partial-width windows (i.e., windows that do not occupy the entire frame width).

User Option: truncate-partial-width-windows

This variable controls line truncation in partial-width windows. A partial-width window is one that does not occupy the entire frame width (see Splitting Windows). If the value is nil, line truncation is determined by the variable truncate-lines (see above). If the value is an integer n, lines are truncated if the partial-width window has fewer than n columns, regardless of the value of truncate-lines; if the partial-width window has n or more columns, line truncation is determined by truncate-lines. For any other non-nil value, lines are truncated in every partial-width window, regardless of the value of truncate-lines.

When horizontal scrolling (see Horizontal Scrolling) is in use in a window, that forces truncation.

Variable: wrap-prefix

If this buffer-local variable is non-nil, it defines a wrap prefix which Emacs displays at the start of every continuation line. (If lines are truncated, wrap-prefix is never used.) Its value may be a string or an image (see Other Display Specifications), or a stretch of whitespace such as specified by the :width or :align-to display properties (see Specified Spaces). The value is interpreted in the same way as a display text property. See The display Property.

A wrap prefix may also be specified for regions of text, using the wrap-prefix text or overlay property. This takes precedence over the wrap-prefix variable. See Properties with Special Meanings.

Variable: line-prefix

If this buffer-local variable is non-nil, it defines a line prefix which Emacs displays at the start of every non-continuation line. Its value may be a string or an image (see Other Display Specifications), or a stretch of whitespace such as specified by the :width or :align-to display properties (see Specified Spaces). The value is interpreted in the same way as a display text property. See The display Property.

A line prefix may also be specified for regions of text using the line-prefix text or overlay property. This takes precedence over the line-prefix variable. See Properties with Special Meanings.