Previous: Do not with tree-buffer, Up: tree-buffer [Contents][Index]

#### 11.3.8 How to deal with certain programming-requirements

This chapter describes in detail how to solve certain programming-challenges with tree-buffers.

#### 11.3.8.1 Caching the current tree-buffer display

Sometimes it can be useful or important to cache the current display of a tree-buffer and display later exactly this cached display-state. Here is how to do this:

1. Caching the display: You have to do two tasks: First store the current internal structure of the tree-buffer; you must do this with the function `tree-buffer-displayed-nodes-copy`. Then store the buffer-contents of that tree-buffer you want to cache; you can do this for example with `buffer-substring`. For both tasks you must make the tree-buffer the current-buffer.
2. Displaying a previous tree-buffer-cache: Make the tree-buffer the current buffer, call `tree-buffer-update` and pass as second argument CONTENT the data you have stored in step 1. See the documentation of `tree-buffer-update` for details.

   Here is an example:

       (tree-buffer-update
         nil
         (cons (nth 2 cache-elem) ;; the stored buffer-string
               (nth 1 cache-elem) ;; the stored tree-structure
         )))