Porting Paredit to LispWorks
I asked this question earlier, but I figured that a little more
information (and a more attention-grabbing subject line :-) might be
more helpful.
I'd like to port Taylor Campbell's paredit-mode from GNU Emacs to the
LispWorks IDE. The port looks to be fairly straightforward, except
for one function: parse-partial-sexp. It is a C function in GNU
Emacs, but I can't turn up anything similar to it in LispWorks. I
could go ahead and translate this function (and the functions it
calls) from C to Lisp, but I'd like to see if there's anything
already available in LispWorks, since I'm very lazy. It returns a
nine-element list describing the state of the s-expression parser in
some region between FROM and TO. The C source is fairly hairy (to
put it mildly), so I'd love it if I could avoid making sense of it.
Once the Paredit port is working, I'll be sure to post the source here.
Thanks,
Bill Atkins
Here's the documentation for the function from GNU Emacs:
parse-partial-sexp is a built-in function in `C source code'.
(parse-partial-sexp from to &optional targetdepth stopbefore oldstate
commentstop)
Parse Lisp syntax starting at from until to; return status of parse
at to.
Parsing stops at to or when certain criteria are met;
point is set to where parsing stops.
If fifth arg oldstate is omitted or nil,
parsing assumes that from is the beginning of a function.
Value is a list of elements describing final state of parsing:
0. depth in parens.
1. character address of start of innermost containing list; nil if none.
2. character address of start of last complete sexp terminated.
3. non-nil if inside a string.
(it is the character that will terminate the string,
or t if the string should be terminated by a generic string
delimiter.)
4. nil if outside a comment, t if inside a non-nestable comment,
else an integer (the current comment nesting).
5. t if following a quote character.
6. the minimum paren-depth encountered during this scan.
7. t if in a comment of style b; symbol `syntax-table' if the comment
should be terminated by a generic comment delimiter.
8. character address of start of comment or string; nil if not in one.
9. Intermediate data for continuation of parsing (subject to change).
If third arg targetdepth is non-nil, parsing stops if the depth
in parentheses becomes equal to targetdepth.
Fourth arg stopbefore non-nil means stop when come to
any character that starts a sexp.
Fifth arg oldstate is a list like what this function returns.
It is used to initialize the state of the parse. Elements number 1,
2, 6
and 8 are ignored; you can leave off element 8 (the last) entirely.
Sixth arg commentstop non-nil means stop at the start of a comment.
If it is symbol `syntax-table', stop after the start of a comment or a
string, or after end of a comment or a string.