TutorialText Buffers




Prev | Up | Next | Back | Forward | Online Documentation Home Page

Text Buffers

Each buffer has a syntactic category that determines its language-sensitivity. Syntactic category TEXT corresponds to an arbitrary sequence of uninterpreted characters. Hence, editing such a buffer is just like using a standard text editor.

Syntactic categories other than TEXT impose syntactic restrictions on their contents. If the entire object is syntactically correct, it may be completely analyzed and prettyprinted according to its syntactic structure. In general, however, the object may contain substrings of unanalyzed text whose syntactic correctness is in doubt. Each such region of unanalyzed text (within the full buffer) is known as a text buffer. Text buffers are typically distinguished from analyzed text via a typographical convention (e.g., with a different font, size, weight, slant, color etc.) customizable by the user.

Text buffers come into existence implicitly as a side effect of text editing. The first text editing operation within an analyzed region of an object turns a small surrounding phrase into a text buffer. Some editing operations (e.g., deleting neighboring characters) cause the text buffer to expand and encompass a larger portion of the object. In the process of expansion, several text buffers may merge into one larger text buffer. In the limit, the entire object becomes a single text buffer.

Placeholders have the special property that the first text-editing operation within them immediately replaces the entire placeholder by the null string. Thus, for example, typing a character when the insertion cursor is positioned within a placeholder replaces the placeholder with the character typed.

A text buffer can be created explicitly by invoking text-capture. Repeated invocations of text-capture with the structural selection already positioned at a text buffer expands the text buffer to larger and larger phrases.

The syntactic correctness of a text buffer can be checked by invoking a built-in parser. Suppose the syntactic context of a text buffer, as provided by the enclosing analyzed part of the object, is syntactic category p; then the goal of parsing is to verify that the text buffer is an instance of category p.

The old, fully analyzed portion of an object corresponding to a text buffer is preserved until the text buffer is successfully parsed. undo discards the text buffer and restores the corresponding analyzed portion of the object.

A buffer of syntactic category TEXT is, in its entirety, one big text buffer. Such buffers can be syntax checked and formatted, but they always remain text buffers.

Commands for text buffers are:


Forward