unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Syntax-ppss flush should happen in after-change hook
@ 2019-03-16 15:01 Vitalie Spinu
  2019-03-16 15:53 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Vitalie Spinu @ 2019-03-16 15:01 UTC (permalink / raw)
  To: emacs-devel


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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-03-16 22:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2019-03-16 18:09     ` Stefan Monnier
2019-03-16 19:56       ` Vitalie Spinu
2019-03-16 22:41         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).