For syntactic analysis, such as in indentation, often the useful thing is to compute the syntactic state corresponding to a given buffer position. This function does that conveniently.
This function returns the parser state (see next section) that the parser would reach at position pos starting from the beginning of the buffer. This is equivalent to
(parse-partial-sexp (point-min)pos), except thatsyntax-ppssuses a cache to speed up the computation. Due to this optimization, the 2nd value (previous complete subexpression) and 6th value (minimum parenthesis depth) of the returned parser state are not meaningful.
syntax-ppss automatically hooks itself to
before-change-functions to keep its cache consistent. But
updating can fail if syntax-ppss is called while
before-change-functions is temporarily let-bound, or if the
buffer is modified without obeying the hook, such as when using
inhibit-modification-hooks. For this reason, it is sometimes
necessary to flush the cache manually.
This function flushes the cache used by
syntax-ppss, starting at position beg. The remaining arguments, ignored-args, are ignored; this function accepts them so that it can be directly used on hooks such asbefore-change-functions(see Change Hooks).
Major modes can make syntax-ppss run faster by specifying
where it needs to start parsing.
If this is non-
nil, it should be a function that moves to an earlier buffer position where the parser state is equivalent tonil—in other words, a position outside of any comment, string, or parenthesis.syntax-ppssuses it to further optimize its computations, when the cache gives no help.