[Top][All Lists]

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

Re: Problems with syntax-ppss

From: Lennart Borgman (gmail)
Subject: Re: Problems with syntax-ppss
Date: Fri, 04 Apr 2008 19:29:48 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

Alan Mackenzie wrote:
Hi, Emacs!

I've just encountered a rather knotty problem in CC Mode for which
syntax-ppss ought to be a solution; I need to find out, RAPIDLY, whether
a particular buffer position is inside a string or comment.
Unfortunately (for me), ......

syntax-ppss does it's parsing from (point-min), not from BOB.

So if the buffer is currently narrowed, this function will return an
meaningless value for the envisaged use.

But if I widen the buffer first, what happens to syntax-ppss's cache?
Is this just discarded, or are perhaps two caches maintained (one from
BOB, the other from the current (or most recent) (point-min)?

I believe nothing happens to the cache. The cache is just a list of position + state. There is no reason to change this when widening the buffer.

The cache is flushed in before-change-hook. All entries after first changed position are removed.

Advice, please!

Forgive me at this point for not reading the fine source code - it's
over 150 lines and looks rather forbidding.

It would be nice if the the Elisp manual could be more explicit on such
points.  (Hey, tell me how it is, and I'll expand the manual!)

I think the doc-string for the function is inadequate - it fails to
state that parsing starts at (point-min) rather than BOB.

Thanks in advance!

reply via email to

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