emacs-devel
[Top][All Lists]
Advanced

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

Re: Problems with syntax-ppss


From: Stefan Monnier
Subject: Re: Problems with syntax-ppss
Date: Mon, 07 Apr 2008 10:57:08 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> > Will calling s-ppss on a narrowed buffer corrupt the cache at all,
>> > for example?
>> Yes it can.  Similarly the cache does not keep track of the
>> syntax-table so if you switch syntax-table between calls you may get
>> unexpected results.

> That's also not good.

> Would it not be a good idea to (i) redefine syntax-ppss as calculating
> the syntax from BOB (as opposed to (point-min));

That's already what it does, when it can.  Maybe it could be improved as
follows: signal an error if it needs to recompute from (point-min) and
(point-min) is not the beginning of the buffer, unless the caller sets
a `syntax-ppss-narrowed-is-ok' variable (for use in modes like Info and
Rmail).  Maybe that variable should be shared with font-lock-dont-widen.

> (ii) have several caches, each associated with a particular syntax
> table (how many modes are going to use more than 2 or, perhaps, 3?);

This may incur a significant cost.  I much prefer to let the caller
decide when a change of syntax-table requires flushing the cache.

Another approach might be to introduce a `syntax-ppss-syntax-table'.

> (iii) put a `save-match-data' round the function?

This is a definite "no": it is much better to let the caller do it in
the very few cases where it's needed, than to pay the cost needlessly
for all the other cases.


        Stefan




reply via email to

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