Subject: bug#22983: syntax-ppss returns wrong result.

From: Alan Mackenzie <[email-masked]>
Date: Sun, 10 Sep 2017 18:26:13 +0000

Hello, Andreas.

On Fri, Sep 08, 2017 at 18:04:37 +0200, Andreas Röhler wrote:

> On 07.09.2017 22:45, Alan Mackenzie wrote:

> > The solution I propose is to introduce a second cache into syntax-ppss,
> > and this cache would be used whenever (not (eq (point-min) 1)).
> > Whenever point-min changes, and isn't 1, this second cached would be
> > calculated again from scratch.

> > This proposal has these advantages:

> > (i) It would make the function deliver what its unchanged doc string
> > says.  This is important, given that syntax-ppss has been very widely
> > used within Emacs, and likely by external packages too; these will
> > typically have assumed the advertised behaviour of the function, without
> > having tested it in narrowed buffers.

> > (i) In the case which currently works, namely a non-narrowed buffer,
> > there would be only a minute slow-down (basically, there would be extra
> > code to check point-min and select the cache to use).

> > (ii) The cache for use in a narrowed buffer might well be sufficiently
> > fast in normal use.  If it is not, it could be enhanced readily.

> Hi Alan and all,

> assume a complex matter behind, a bunch of bugs resp. design issues, not 
> a single one.

I don't think this bug is _that_ complex, and even if it has associated
bugs, I think we can fix it on its own.

> Fixing this would affect syntax-propertize, parse-partial-sexp, 
> syntax-ppss and font-lock stuff at once.

I'll give you one out of four.  ;-)  syntax-ppss will definitely be
affected, parse-partial-sexp definitely not, and the other two possibly
in corner cases, but hopefully not.

> http://lists.gnu.org/archive/html/emacs-devel/2016-03/msg01576.html
> points at some spot. There should be more.

I think, at least I hope, that is an orthoganol issue.

> As a first step listing referential tests including benchmarks should be 
> helpful.

-- 
Alan Mackenzie (Nuremberg, Germany).