From: Vitalie Spinu <spinuvit@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Syntax-ppss flush should happen in after-change hook
Date: Sat, 16 Mar 2019 16:01:43 +0100 [thread overview]
Message-ID: <87sgvm50dk.fsf@gmail.com> (raw)
Hi,
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). Second is when the actual function responsible for a change invokes
`syntax-propertize`.
Here is a real case of uncomment-region in markdown-mode:
markdown-syntax-propertize(63 823)
syntax-propertize(823)
internal--syntax-propertize(64)
parse-partial-sexp(63 #<marker at 77 in test.tmd> nil nil nil t)
comment-search-forward(#<marker at 77 in test.tmd> t)
uncomment-region-default-1(63 77 nil)
#f(compiled-function () #<bytecode 0x280781d>)()
combine-change-calls-1(63 77 #f(compiled-function () #<bytecode 0x280781d>))
uncomment-region-default(63 77 nil)
uncomment-region(63 77 nil)
As markdown mode caches its syntax properties during syntax-propertize which are
subsequently used by font-lock, the font-lock eventually uses "pre-change"
properties during the fortification. This results in all sort of hard to trace
bugs (mostly end of buffer errors).
I think placing the flush in after-change-functions would solve most of core of
the issue leaving the negligible possibility that there will be a hook before
the flush which would break on outdated properties.
Vitalie
next reply other threads:[~2019-03-16 15:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-16 15:01 Vitalie Spinu [this message]
2019-03-16 15:53 ` Syntax-ppss flush should happen in after-change hook Stefan Monnier
2019-03-16 17:35 ` Vitalie Spinu
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=87sgvm50dk.fsf@gmail.com \
--to=spinuvit@gmail.com \
--cc=emacs-devel@gnu.org \
/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.