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. [annotate]
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. [annotate]
| pre-command-parse-check | mark for-sure | [Function] |
| Parse Start Function | (initial value start-of-parse-block) | [Variable] |
| Parse End Function | (initial value end-of-parse-block) | [Variable] |
| Minimum Lines Parsed | (initial value 50) | [Variable] |
| Maximum Lines Parsed | (initial value 500) | [Variable] |
| Defun Parse Goal | (initial value 2) | [Variable] |
| | 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. [annotate] 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.
[annotate] [annotate] |
| form-offset | mark count | [Function] |
| |
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.
[annotate] [annotate] |
| top-level-offset | mark count | [Function] |
| |
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.
[annotate] [annotate] |
| mark-top-level-form | mark1 mark2 | [Function] |
| |
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.
[annotate] [annotate] |
| defun-region | mark | [Function] |
| |
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.
[annotate] [annotate] |
| inside-defun-p | mark | [Function] |
| start-defun-p | mark | [Function] |
| |
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 9.5) value is :opening-paren.
[annotate] [annotate] |
| forward-up-list | mark | [Function] |
| backward-up-list | mark | [Function] |
| |
Respectively, these move mark immediately past a character whose Lisp
Syntax (see section 9.5) value is :closing-paren or
immediately before a character whose Lisp Syntax value is
:opening-paren.
[annotate] [annotate] |
| valid-spot | mark forwardp | [Function] |
| |
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.
[annotate] [annotate] |
| defindent | name count | [Function] |
| |
This defines the function with name to have count special arguments.
indent-for-lisp, the value of Indent Function (see section
15.1) 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".
[annotate] [annotate] |