summaryrefslogtreecommitdiff
path: root/devdocs/elisp/display-tables.html
blob: cc04b654e5197053d5ac991f6f3c9ce28acd122a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 <h4 class="subsection">Display Tables</h4>  <p>A display table is a special-purpose char-table (see <a href="char_002dtables">Char-Tables</a>), with <code>display-table</code> as its subtype, which is used to override the usual character display conventions. This section describes how to make, inspect, and assign elements to a display table object. The next section (see <a href="active-display-table">Active Display Table</a>) describes the various standard display tables and their precedence. </p> <dl> <dt id="make-display-table">Function: <strong>make-display-table</strong>
</dt> <dd><p>This creates and returns a display table. The table initially has <code>nil</code> in all elements. </p></dd>
</dl> <p>The ordinary elements of the display table are indexed by character codes; the element at index <var>c</var> says how to display the character code <var>c</var>. The value should be <code>nil</code> (which means to display the character <var>c</var> according to the usual display conventions; see <a href="usual-display">Usual Display</a>), or a vector of glyph codes (which means to display the character <var>c</var> as those glyphs; see <a href="glyphs">Glyphs</a>). </p> <p><strong>Warning:</strong> if you use the display table to change the display of newline characters, the whole buffer will be displayed as one long line. </p> <p>The display table also has six <em>extra slots</em> which serve special purposes. Here is a table of their meanings; <code>nil</code> in any slot means to use the default for that slot, as stated below. </p> <dl compact> <dt>0</dt> <dd>
<p>The glyph for the end of a truncated screen line (the default for this is ‘<samp>$</samp>’). See <a href="glyphs">Glyphs</a>. On graphical terminals, Emacs by default uses arrows in the fringes to indicate truncation, so the display table has no effect, unless you disable the fringes (see <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Fringes.html#Fringes">Window Fringes</a> in <cite>the GNU Emacs Manual</cite>). </p> </dd> <dt>1</dt> <dd>
<p>The glyph for the end of a continued line (the default is ‘<samp>\</samp>’). On graphical terminals, Emacs by default uses curved arrows in the fringes to indicate continuation, so the display table has no effect, unless you disable the fringes. </p> </dd> <dt>2</dt> <dd>
<p>The glyph for indicating a character displayed as an octal character code (the default is ‘<samp>\</samp>’). </p> </dd> <dt>3</dt> <dd>
<p>The glyph for indicating a control character (the default is ‘<samp>^</samp>’). </p> </dd> <dt>4</dt> <dd>
<p>A vector of glyphs for indicating the presence of invisible lines (the default is ‘<samp>...</samp>’). See <a href="selective-display">Selective Display</a>. </p> </dd> <dt>5</dt> <dd><p>The glyph used to draw the border between side-by-side windows (the default is ‘<samp>|</samp>’). See <a href="splitting-windows">Splitting Windows</a>. This currently has effect only on text terminals; on graphical terminals, if vertical scroll bars are supported and in use, a scroll bar separates the two windows, and if there are no vertical scroll bars and no dividers (see <a href="window-dividers">Window Dividers</a>), Emacs uses a thin line to indicate the border. </p></dd> </dl> <p>For example, here is how to construct a display table that mimics the effect of setting <code>ctl-arrow</code> to a non-<code>nil</code> value (see <a href="glyphs">Glyphs</a>, for the function <code>make-glyph-code</code>): </p> <div class="example"> <pre class="example">(setq disptab (make-display-table))
(dotimes (i 32)
  (or (= i ?\t)
      (= i ?\n)
      (aset disptab i
            (vector (make-glyph-code ?^ 'escape-glyph)
                    (make-glyph-code (+ i 64) 'escape-glyph)))))
(aset disptab 127
      (vector (make-glyph-code ?^ 'escape-glyph)
              (make-glyph-code ?? 'escape-glyph)))))
</pre>
</div> <dl> <dt id="display-table-slot">Function: <strong>display-table-slot</strong> <em>display-table slot</em>
</dt> <dd><p>This function returns the value of the extra slot <var>slot</var> of <var>display-table</var>. The argument <var>slot</var> may be a number from 0 to 5 inclusive, or a slot name (symbol). Valid symbols are <code>truncation</code>, <code>wrap</code>, <code>escape</code>, <code>control</code>, <code>selective-display</code>, and <code>vertical-border</code>. </p></dd>
</dl> <dl> <dt id="set-display-table-slot">Function: <strong>set-display-table-slot</strong> <em>display-table slot value</em>
</dt> <dd><p>This function stores <var>value</var> in the extra slot <var>slot</var> of <var>display-table</var>. The argument <var>slot</var> may be a number from 0 to 5 inclusive, or a slot name (symbol). Valid symbols are <code>truncation</code>, <code>wrap</code>, <code>escape</code>, <code>control</code>, <code>selective-display</code>, and <code>vertical-border</code>. </p></dd>
</dl> <dl> <dt id="describe-display-table">Function: <strong>describe-display-table</strong> <em>display-table</em>
</dt> <dd><p>This function displays a description of the display table <var>display-table</var> in a help buffer. </p></dd>
</dl> <dl> <dt id="describe-current-display-table">Command: <strong>describe-current-display-table</strong>
</dt> <dd><p>This command displays a description of the current display table in a help buffer. </p></dd>
</dl><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Tables.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Tables.html</a>
  </p>
</div>