emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

syntax-ppss-flush-cache


From: martin rudalics
Subject: syntax-ppss-flush-cache
Date: Thu, 20 Oct 2005 10:50:27 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Consider the following stretch of elisp code:

(defvar foo
   "string ..
.............
............."
( "doc ..
.........
.........
..........")

Suppose I change some text on the line below "doc.  `syntax-ppss' using
`syntax-begin-function' will record something like (1 X ... (X)) where X
is the position of the left paren preceding "doc.  `parse-partial-sexp'
run from point-min would produce a value like (2 X ... (.. X)) instead.
Assume `syntax-ppss' stores the recorded state in `syntax-ppss-last'.

I next delete the paren preceding "doc.  `syntax-ppss-flush-cache' will
now set the car of `syntax-ppss-last' to nil since BEG is not less than
(car (nth 10 syntax-ppss-last)) equalling X.  After this `syntax-ppss'
will execute

           ((and (not old-pos) old-ppss
                 (setq pt-min (or (car (nth 9 old-ppss))
                 ...

setting `pt-min' to X.  In the sequel `syntax-ppss' for any position
following X may produce a value as if the paren were still there.

Replacing

    (if (< beg (or (car (nth 10 syntax-ppss-last))

by

    (if (<= beg (or (car (nth 10 syntax-ppss-last))

in `syntax-ppss-flush-cache' resolves this for me.  I'm not sure whether

  (while (and syntax-ppss-cache (> (caar syntax-ppss-cache) beg))

should become

  (while (and syntax-ppss-cache (>= (caar syntax-ppss-cache) beg))

as well.


A related question:  Shouldn't

                   (nth 2 syntax-ppss-last)

become

                   (nth 3 syntax-ppss-last)

in `syntax-ppss-flush-cache'?  After all (nth 2 syntax-ppss-last) can be
non-nil iff (car (nth 10 ...) is non-nil.  With other words, if and when
this gets evaluated it always returns nil.  On the other hand you need a
valid third field of `syntax-ppss-last' with

                 (setq pt-min (or (car (nth 9 old-ppss))
                                  (nth 8 old-ppss)
                                  (nth 2 old-ppss)))

in `syntax-ppss' provided the ninth and tenth fields are nil.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]