|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 4338 (0x10f2)
Types: TextFile
Names: »sexps.texinfo«
└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
└─⟦c06c473ab⟧ »./UNRELEASED/lispref.tar.Z«
└─⟦1b57a2ffe⟧
└─⟦this⟧ »sexps.texinfo«
@setfilename ../info/sexps
@node Lisp Expressions, Abbreviations, Syntax Tables, Top
@chapter Lisp Expressions
Here are several functions for parsing and scanning Lisp expressions.
@defun parse-partial-sexp start limit &optional target-depth stop-before state
This function parses Lisp syntax in the current buffer starting at
@var{start} and not reading past @var{limit}. It returns the status of
the parse at @var{limit}. Parsing stops at @var{limit} or when certain
criteria are met described below; point is set to where parsing stops.
@cindex top-level form
Normally, @var{start} is assumed to be the top level of a form to be
parsed, such as the beginning of a function definition. If you wish to
continue a previous parse, you must provide a @var{state} argument,
which describes the initial status of parsing. If @var{state} is
omitted (or @code{nil}), parsing assumes that @var{start} is the
beginning of a new parse at level 0.
@cindex parenthesis depth
If the third argument @var{target-depth} is non-@code{nil}, parsing
stops if the depth in parentheses becomes equal to @var{target-depth}.
The depth starts at 0, or at whatever is given in @var{state}.
@cindex sexp start
If the fourth argument @var{stop-before} is non-@code{nil}, parsing
stops when it comes to any character that starts a sexp.
@cindex parse state
The fifth argument @var{state} is a seven-element list in the same
form as this function returns, described below. the return value of one
call may be used to initialize the state of the parse on another call to
@code{parse-partial-sexp}.
The result is a list of seven elements describing the final state of
the parse:
@enumerate
@item
Depth in parens, starting at 0.
@item
@cindex innermost list
Character position of the start of the innermost containing list;
@code{nil} if none.
@item
@cindex complete sexp
Character position of the start of the last complete sexp terminated;
@code{nil} if none.
@item
@cindex inside string
Non-@code{nil} if inside a string.
(It is the character that will terminate the string.)
@item
@cindex inside comment
@code{t} if inside a comment.
@item
@cindex quote character
@code{t} if point is just after a quote character.
@item
The minimum paren-depth encountered during this scan.
@end enumerate
Elements 1, 4, 5, and 6 are significant in the argument @var{state}.
@cindex indenting lists
This function is used to determine how to indent lines of programs
that have nested lists.
@end defun
@defun scan-lists from count depth
This function scals from character number @var{from} by @var{count} lists.
It returns the character number of the position thus found.
@cindex parenthesis depth
If @var{depth} is nonzero, parenthesis depth counting begins from that
value. Only places where the depth in parentheses becomes zero are
candidates for stopping; @var{count} such places are counted. Thus, a
positive value for @var{depth} means go out levels of parenthesis.
Comments are ignored if @code{parse-sexp-ignore-comments} is non-@code{nil}.
@cindex end-of-file error
If the beginning or end of (the accessiblepart of) the buffer is
reached and the depth is not zero, an @code{end-of-file} error is
signaled. If the depth is zerobut the count is not used up, @code{nil}
is returned.@refill
@end defun
@defun scan-sexps from count
Scan from character number @var{from} by @var{count} balanced
expressions. Returns the character number of the position thus found.
Comments are ignored if @code{parse-sexp-ignore-comments} is non-@code{nil}.
@cindex end-of-file error
If the beginning or end of (the accessible part of) the buffer is
reached in the middle of a parenthetical grouping, an @code{end-of-file}
error is signaled. If the beginning or end is reached between groupings
but before count is used up, @code{nil} is returned.
@end defun
@defvar parse-sexp-ignore-comments
@cindex skipping comments
Non-@code{nil} means @code{forward-sexp}, etc., should treat comments
as whitespace. Non-@code{nil} works only when the comment terminator is
something like @samp{*/}, and appears only when it ends a comment. If
comments are terminated by newlines, you must make this variable
@code{nil}, since not every newline is the end of a comment. (In
version 19, this limitation is removed.)
@end defvar