all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
Subject: syntax-ppss-flush-cache
Date: Thu, 20 Oct 2005 10:50:27 +0200	[thread overview]
Message-ID: <43575A53.5080207@gmx.at> (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.

             reply	other threads:[~2005-10-20  8:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-20  8:50 martin rudalics [this message]
2005-10-20 16:21 ` syntax-ppss-flush-cache Stefan Monnier
2005-10-21  6:05 ` syntax-ppss-flush-cache Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43575A53.5080207@gmx.at \
    --to=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.