From: Vitalie Spinu <spinuvit@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Syntax-ppss flush should happen in after-change hook
Date: Sat, 16 Mar 2019 18:35:09 +0100 [thread overview]
Message-ID: <87lg1e4t9u.fsf@gmail.com> (raw)
In-Reply-To: <jwvpnqq7sd3.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 16 Mar 2019 11:53:53 -0400")
>> On Sat, Mar 16 2019 11:53, Stefan Monnier wrote:
>> Currently ppss flush happens in before-change hook. This leads to a real
>> possibility that syntax-propertize is called before the actual change and not
>> refreshed after the change. This could occur in at least two scenarios.
>>
>> First, when a hook placed after syntax-ppss-flush-cache in
>> before-change-functions invokes `syntax-propertize` (for example with a
>> search).
> If syntax-ppss-flush-cache is on after-change-functions then the risk is
> when a hook function is placed before it.
So it's inconsistent state for the hooks vs inconsistent state for all the emacs
functions after the change.
> Given the fact that add-hook defaults to placing functions at the head and
> that after-change-functions are much more commonly used than
> before-change-functions
One simple solution is to add a sentinel to the before-change-functions to
explicitly check for syntax-ppss-flush-chache being the first hook:
(unless (eq (car after-change-functions) 'syntax-ppss-flush-cache)
(delq 'syntax-ppss-flush-cache after-change-functions)
(add-hook 'after-change-functions 'syntax-ppss-flush-cache nil t))
> A crude solution could be the ad-hoc hack below. We could make it less
> ad-hoc by adding a way for any hook function (on b-c-f and a-c-f) to
> indicate whether it should stay active within combine-change-calls,
> e.g. with a symbol property `do-not-combine-change-function`.
AFAICS this will not help with the main part of the problem (second scenario in
OP). The problem is not that some inconsistent state happens during the
combine-change-calls but that after the change ppss is left in inconsistent
state. Combine-change-calls happened in my example, but currently any buffer
change results in inconsistent syntax state.
As far as I understand, just before the actual change the cache is in consistent
state, so currently, if the changing function requires syntax properties then
before-change flush enforces extra syntax-propertize for nothing. In my example
that search need not have had triggered syntax-propertize would the flush not
have had happened.
Vitalie
next prev parent reply other threads:[~2019-03-16 17:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-16 15:01 Syntax-ppss flush should happen in after-change hook Vitalie Spinu
2019-03-16 15:53 ` Stefan Monnier
2019-03-16 17:35 ` Vitalie Spinu [this message]
2019-03-16 18:09 ` Stefan Monnier
2019-03-16 19:56 ` Vitalie Spinu
2019-03-16 22:41 ` 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=87lg1e4t9u.fsf@gmail.com \
--to=spinuvit@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.