summaryrefslogtreecommitdiff
path: root/devdocs/elisp/abstract-display.html
blob: f14f543c5c608bd4de7ba8bc409cfd7f9b482d98 (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
 <h3 class="section">Abstract Display</h3>      <p>The Ewoc package constructs buffer text that represents a structure of Lisp objects, and updates the text to follow changes in that structure. This is like the “view” component in the “model–view–controller” design paradigm. Ewoc means “Emacs’s Widget for Object Collections”. </p> <p>An <em>ewoc</em> is a structure that organizes information required to construct buffer text that represents certain Lisp data. The buffer text of the ewoc has three parts, in order: first, fixed <em>header</em> text; next, textual descriptions of a series of data elements (Lisp objects that you specify); and last, fixed <em>footer</em> text. Specifically, an ewoc contains information on: </p> <ul> <li> The buffer which its text is generated in. </li>
<li> The text’s start position in the buffer. </li>
<li> The header and footer strings. </li>
<li>  A doubly-linked chain of <em>nodes</em>, each of which contains: <ul> <li> A <em>data element</em>, a single Lisp object. </li>
<li> Links to the preceding and following nodes in the chain. </li>
</ul> </li>
<li> A <em>pretty-printer</em> function which is responsible for inserting the textual representation of a data element value into the current buffer. </li>
</ul> <p>Typically, you define an ewoc with <code>ewoc-create</code>, and then pass the resulting ewoc structure to other functions in the Ewoc package to build nodes within it, and display it in the buffer. Once it is displayed in the buffer, other functions determine the correspondence between buffer positions and nodes, move point from one node’s textual representation to another, and so forth. See <a href="abstract-display-functions">Abstract Display Functions</a>. </p>  <p>A node <em>encapsulates</em> a data element much the way a variable holds a value. Normally, encapsulation occurs as a part of adding a node to the ewoc. You can retrieve the data element value and place a new value in its place, like so: </p> <div class="lisp"> <pre class="lisp">(ewoc-data <var>node</var>)
⇒ value

(ewoc-set-data <var>node</var> <var>new-value</var>)
⇒ <var>new-value</var>
</pre>
</div> <p>You can also use, as the data element value, a Lisp object (list or vector) that is a container for the real value, or an index into some other structure. The example (see <a href="abstract-display-example">Abstract Display Example</a>) uses the latter approach. </p> <p>When the data changes, you will want to update the text in the buffer. You can update all nodes by calling <code>ewoc-refresh</code>, or just specific nodes using <code>ewoc-invalidate</code>, or all nodes satisfying a predicate using <code>ewoc-map</code>. Alternatively, you can delete invalid nodes using <code>ewoc-delete</code> or <code>ewoc-filter</code>, and add new nodes in their place. Deleting a node from an ewoc deletes its associated textual description from buffer, as well. </p> <table class="menu" border="0" cellspacing="0"> <tr>
<td align="left" valign="top">• <a href="abstract-display-functions" accesskey="1">Abstract Display Functions</a>
</td>
<td> </td>
<td align="left" valign="top">Functions in the Ewoc package. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="abstract-display-example" accesskey="2">Abstract Display Example</a>
</td>
<td> </td>
<td align="left" valign="top">Example of using Ewoc. </td>
</tr> </table><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/Abstract-Display.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Abstract-Display.html</a>
  </p>
</div>