[Top][All Lists]

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

Re: New hook before-region-change-functions wanted

From: Stefan Monnier
Subject: Re: New hook before-region-change-functions wanted
Date: Sat, 09 Sep 2017 09:44:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

> The reason I want it is as part of the solution to bug #22983
> (syntax-ppss returns wrong result).  I envisage two (or possibly more)
> mutually independent caches, and a switch being made to the appropriate
> cache when the region is changed.  This switch would be made inside a
> function on before-change-region-functions.

Regarding a hook placed on narrow-to-region (from where I stand, `widen`
is just a special call to narrow-to-region):
- As discussed in the past, narrow-to-region needs to be
  extended/adjusted/complemented with some way to distinguish "hard
  narrowing" (as is used in Info-mode, and might be used in cases of
  multiple-major-modes) from "soft narrowing", so there's a risk such
  changes would impact the desired behavior of this hook.
- syntax-ppss doesn't need this hook, and even if it were added it
  probably wouldn't benefit from it: you can just as easily change
  syntax-ppss to compare (point-min) with its last value in order to
  detect calls to narrow-to-region.  There are minor advantages to using
  your hooks, but there are also similarly minor advantages to
  performing the detection dynamically in syntax-ppss, and I think
  overall neither approach would be noticeably better than the other.

> While it is true that this hook is not absolutely necessary, in that the
> cache switch could be made by the first call to syntax-ppss after the
> region change, it makes the cache switch clean.  In particular, the
> cache will always be in synch with the region, and any functions which
> examine the cache at an arbitrary time (for example, jit-lock
> functions), will get the right cache.

AFAIK noone ever looks at syntax-ppss's cache except for syntax-ppss.
jit-lock definitely doesn't.


reply via email to

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