all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* syntax-ppss-flush-cache
@ 2005-10-20  8:50 martin rudalics
  2005-10-20 16:21 ` syntax-ppss-flush-cache Stefan Monnier
  2005-10-21  6:05 ` syntax-ppss-flush-cache Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: martin rudalics @ 2005-10-20  8:50 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-21  6:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-20  8:50 syntax-ppss-flush-cache martin rudalics
2005-10-20 16:21 ` syntax-ppss-flush-cache Stefan Monnier
2005-10-21  6:05 ` syntax-ppss-flush-cache Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.