emacs-devel
[Top][All Lists]
Advanced

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

Syntax-ppss flush should happen in after-change hook


From: Vitalie Spinu
Subject: Syntax-ppss flush should happen in after-change hook
Date: Sat, 16 Mar 2019 16:01:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

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



reply via email to

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