Next: , Previous: Optional Mode Line, Up: Display

14.19 How Text Is Displayed

Most characters are printing characters: when they appear in a buffer, they are displayed literally on the screen. Printing characters include ASCII numbers, letters, and punctuation characters, as well as many non-ASCII characters.

The ASCII character set contains non-printing control characters. Two of these are displayed specially: the newline character (Unicode code point U+000A) is displayed by starting a new line, while the tab character (U+0009) is displayed as a space that extends to the next tab stop column (normally every 8 columns). The number of spaces per tab is controlled by the buffer-local variable tab-width, which must have an integer value between 1 and 1000, inclusive. Note that how the tab character in the buffer is displayed has nothing to do with the definition of <TAB> as a command.

Other ASCII control characters, whose codes are below U+0020 (octal 40, decimal 32), are displayed as a caret (‘^’) followed by the non-control version of the character, with the escape-glyph face. For instance, the ‘control-A’ character, U+0001, is displayed as ‘^A’.

The raw bytes with codes U+0080 (octal 200) through U+009F (octal 237) are displayed as octal escape sequences, with the escape-glyph face. For instance, character code U+0098 (octal 230) is displayed as ‘\230’. If you change the buffer-local variable ctl-arrow to nil, the ASCII control characters are also displayed as octal escape sequences instead of caret escape sequences.

Some non-ASCII characters have the same appearance as an ASCII space or hyphen (minus) character. Such characters can cause problems if they are entered into a buffer without your realization, e.g., by yanking; for instance, source code compilers typically do not treat non-ASCII spaces as whitespace characters. To deal with this problem, Emacs displays such characters specially: it displays U+00A0 (no-break space) with the nobreak-space face, and it displays U+00AD (soft hyphen), U+2010 (hyphen), and U+2011 (non-breaking hyphen) with the escape-glyph face. To disable this, change the variable nobreak-char-display to nil. If you give this variable a non-nil and non-t value, Emacs instead displays such characters as a highlighted backslash followed by a space or hyphen.

You can customize the way any particular character code is displayed by means of a display table. See Display Tables.

On graphical displays, some characters may have no glyphs in any of the fonts available to Emacs. These glyphless characters are normally displayed as boxes containing the hexadecimal character code. Similarly, on text terminals, characters that cannot be displayed using the terminal encoding (see Terminal Coding) are normally displayed as question signs. You can control the display method by customizing the variable glyphless-char-display-control. You can also customize the glyphless-char face to make these characters more prominent on display. See Glyphless Character Display, for details.

If the curved quotes ‘’, ‘’, ‘’, and ‘’ are known to look just like ASCII characters, they are shown with the escape-glyph face. Curved quotes that cannot be displayed are shown as their ASCII approximations ‘`’, ‘'’, and ‘"’ with the escape-glyph face.