41.23.5 Glyphless Character Display

Glyphless characters are characters which are displayed in a special way, e.g., as a box containing a hexadecimal code, instead of being displayed literally. These include characters which are explicitly defined to be glyphless, as well as characters for which there is no available font (on a graphical display), and characters which cannot be encoded by the terminal’s coding system (on a text terminal).

The glyphless-display-mode minor mode can be used to toggle displaying glyphless characters in a convenient manner in the current buffer. If this mode is enabled, all the glyphless characters are displayed as boxes that display acronyms of their character names.

Variable: glyphless-char-display

For more fine-grained (and global) control, this variable can be used. The value of this variable is a char-table which defines glyphless characters and how they are displayed. Each entry must be one of the following display methods:

nil

Display the character in the usual way.

zero-width

Don’t display the character.

thin-space

Display a thin space, 1-pixel wide on graphical displays, or 1-character wide on text terminals.

empty-box

Display an empty box.

hex-code

Display a box containing the Unicode codepoint of the character, in hexadecimal notation.

an ASCII string

Display a box containing that string. The string should contain at most 6 ASCII characters. As an exception, if the string includes just one character, on text-mode terminals that character will be displayed without a box; this allows to handle such “acronyms” as a replacement character for characters that cannot be displayed by the terminal.

a cons cell (graphical . text)

Display with graphical on graphical displays, and with text on text terminals. Both graphical and text must be one of the display methods described above.

The thin-space, empty-box, hex-code, and ASCII string display methods are drawn with the glyphless-char face. On text terminals, a box is emulated by square brackets, ‘[]’.

The char-table has one extra slot, which determines how to display any character that cannot be displayed with any available font, or cannot be encoded by the terminal’s coding system. Its value should be one of the above display methods, except zero-width.

If a character has a non-nil entry in an active display table, the display table takes effect; in this case, Emacs does not consult glyphless-char-display at all.

User Option: glyphless-char-display-control

This user option provides a convenient way to set glyphless-char-display for groups of similar characters. Do not set its value directly from Lisp code; the value takes effect only via a custom :set function (see Defining Customization Variables), which updates glyphless-char-display.

Its value should be an alist of elements (group . method), where group is a symbol specifying a group of characters, and method is a symbol specifying how to display them.

group should be one of the following:

c0-control

ASCII control characters U+0000 to U+001F, excluding the newline and tab characters (normally displayed as escape sequences like ‘^A’; see How Text Is Displayed in The GNU Emacs Manual).

c1-control

Non-ASCII, non-printing characters U+0080 to U+009F (normally displayed as octal escape sequences like ‘\230’).

format-control

Characters of Unicode General Category [Cf], such as U+200E LEFT-TO-RIGHT MARK, but excluding characters that have graphic images, such as U+00AD SOFT HYPHEN.

bidi-control

This is a subset of format-control, but only includes characters that are related to bidirectional formatting control, like U+2069 POP DIRECTIONAL ISOLATE and U+202A LEFT-TO-RIGHT EMBEDDING. See Bidirectional Display.

Characters of Unicode General Category [Cf], such as U+200E LEFT-TO-RIGHT MARK, but excluding characters that have graphic images, such as U+00AD SOFT HYPHEN.

variation-selectors

Unicode VS-1 through VS-256 (U+FE00 through U+FE0F and U+E0100 through U+E01EF), which are used to select between different glyphs for the same codepoints (typically emojis).

no-font

Characters for which there is no suitable font, or which cannot be encoded by the terminal’s coding system, or those for which the text-mode terminal has no glyphs.

The method symbol should be one of zero-width, thin-space, empty-box, or hex-code. These have the same meanings as in glyphless-char-display, above.