Next: , Previous: , Up: High-Level Text Primitives   [Contents][Index]


15.2 Lisp Text Buffers

Hemlock bases its Lisp primitives on parsing a block of the buffer and annotating lines as to what kind of Lisp syntax occurs on the line or what kind of form a mark might be in (for example, string, comment, list, etc.). These do not work well if the block of parsed forms is exceeded when moving marks around these forms, but the block that gets parsed is somewhat programmable.

There is also a notion of a top level form which this documentation often uses synonymously with defun, meaning a Lisp form occurring in a source file delimited by parentheses with the opening parenthesis at the beginning of some line. The names of the functions include this inconsistency.

Hemlock Variable: Parse Start Function (initial value start-of-parse-block)
Hemlock Variable: Parse End Function (initial value end-of-parse-block)
Hemlock Variable: Minimum Lines Parsed (initial value 50)
Hemlock Variable: Maximum Lines Parsed (initial value 500)
Hemlock Variable: Defun Parse Goal (initial value 2)
Function: pre-command-parse-check mark for-sure

pre-command-parse-check calls Parse Start Function and Parse End Function on mark to get two marks. It then parses all the lines between the marks including the complete lines they point into. When for-sure is non-nil, this parses the area regardless of any cached information about the lines. Every command that uses the following routines calls this before doing so.

The default values of the start and end variables use Minimum Lines Parsed, Maximum Lines Parsed, and Defun Parse Goal to determine how big a region to parse. These two functions always include at least the minimum number of lines before and after the mark passed to them. They try to include Defun Parse Goal number of top level forms before and after the mark passed them, but these functions never return marks that include more than the maximum number of lines before or after the mark passed to them.

Function: form-offset mark count

This tries to move mark count forms forward if positive or -count forms backwards if negative. Mark is always moved. If there were enough forms in the appropriate direction, this returns mark, otherwise nil.

Function: top-level-offset mark count

This tries to move mark count top level forms forward if positive or -count top level forms backwards if negative. If there were enough top level forms in the appropriate direction, this returns mark, otherwise nil. Mark is moved only if this is successful.

Function: mark-top-level-form mark1 mark2

This moves mark1 and mark2 to the beginning and end, respectively, of the current or next top level form. Mark1 is used as a reference to start looking. The marks may be altered even if unsuccessful. If successful, return mark2, else nil. Mark2 is left at the beginning of the line following the top level form if possible, but if the last line has text after the closing parenthesis, this leaves the mark immediately after the form.

Function: defun-region mark

This returns a region around the current or next defun with respect to mark. Mark is not used to form the region. If there is no appropriate top level form, this signals an editor-error. This calls pre-command-parse-check first.

Function: inside-defun-p mark
Function: start-defun-p mark

These return, respectively, whether mark is inside a top level form or at the beginning of a line immediately before a character whose Lisp Syntax (see section sys-def-chars) value is :opening-paren.

Function: forward-up-list mark
Function: backward-up-list mark

Respectively, these move mark immediately past a character whose Lisp Syntax (see section sys-def-chars) value is :closing-paren or immediately before a character whose Lisp Syntax value is :opening-paren.

Function: valid-spot mark forwardp

This returns t or nil depending on whether the character indicated by mark is a valid spot. When forwardp is set, use the character after mark and vice versa. Valid spots exclude commented text, inside strings, and character quoting.

Function: defindent name count

This defines the function with name to have count special arguments. indent-for-lisp, the value of Indent Function (see section indenting) in Lisp mode, uses this to specially indent these arguments. For example, do has two, with-open-file has one, etc. There are many of these defined by the system including definitions for special Hemlock forms. Name is a simple-string, case insensitive and purely textual (that is, not read by the Lisp reader); therefore, "with-a-mumble" is distinct from "mumble:with-a-mumble".


Next: English Text Buffers, Previous: Indenting Text, Up: High-Level Text Primitives   [Contents][Index]