All Manuals > Editor User Guide > 4 Editing Lisp Programs

4.14 Definition folding

Definition folding means making the body of the definition invisible, as well as the preceding lines up to the previous definition. Currently the implementation applies only to Lisp definitions. A line starting with an left parenthesis is regarded as the begining of a Lisp definition, and the matching right parenthesis is its end.

Definition folding is done by folds. Each fold hides the body of a definition and the preceding lines, which are referred to as the comment for this definition. The first line of the definition remains visible, and also the right parenthesis. The body is invisible, and instead three dots (...) are displayed. The comment is also made invisible. By default, nothing is displayed for the comment, but that can be configured by Preferences... > Editor > Editor Options > Hidden Comment String (see in 12.7.3 Other Editor options in the LispWorks IDE User Guide).

There are three commands to manipulate definition folding:

When an incremental search matches inside a folded definition, the definition is unfolded temporarily. Unless the incremental search is ended by the abort gesture (Ctrl+G, or Esc in Microsoft Windows editor emulation), the definition in which the last match occurred is left unfolded, while all the other definitions that were temporarily unfolded are refolded. If the search is ended by the abort gesture, all temporarily unfolded defintions are refolded.

Folding hides most of the newlines in the buffer and displays the first line of the definition and its right parenthesis on the same display line on the screen. Thus each display line on the screen contains text from two different lines in the full text of the buffer. That causes line-based editor commands such as Next Line and Previous Line to behave in a somewhat non-intuitive way. However, they still do the right thing, which is moving between those lines in the full text that are visible on the screen (which may be in the same display line).

The folds affect only the way the text in the buffer is displayed on the screen, and have no effect on the buffer's contents. If you re-read the buffer from its file, for example by reverting using either Revert Buffer or from the menu, then the folds are eliminated.

Fold Buffer Definitions Editor Command

Arguments: None
Key sequence: None

Folds the definitions in the current buffer. See 4.14 Definition folding above for the description of definition folding.

Fold Buffer Definitions goes through the whole buffer from the beginning, and adds a fold for each definition.

If an unclosed definition is found (that is a line starting with an left parenthesis which does not have a matching right parenthesis) then Fold Buffer Definitions assumes that all following lines starting with a space or tab are part of the unclosed defintion. It then skips the unclosed definition without trying to fold it.

Unfold Buffer Definitions Editor Command

Arguments: None
Key sequence: None

Unfolds all the definitions in the current buffer. See 4.14 Definition folding above for the description of definition folding.

Toggle Current Definition Folding Editor Command

Arguments: None
Key sequence: None

Changes the folding state of the current definition (the definition where the cursor is).

Without a prefix argument, Toggle Current Definition Folding unfolds the current definition if it is folded, otherwise the command folds the current definition. This is the default behavior.

With any prefix argument except 0, Toggle Current Definition Folding ensures that the current definition is folded.

With prefix 0, Toggle Current Definition Folding ensures that the current definition is unfolded.


Editor User Guide (Windows version) - 01 Dec 2021 19:35:27