emacs-devel
[Top][All Lists]
Advanced

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

Bug in font-lock-syntactic-keywords handling?


From: immerrr again
Subject: Bug in font-lock-syntactic-keywords handling?
Date: Mon, 6 Oct 2014 15:42:19 +0400

Hi all

I've run into an interesting issue with syntactic fontification with
lua-mode: it uses font-lock-syntactic-keywords to mark up long-strings
and long-comments as advised earlier in this list [1] and there has
been a report that this approach failed on a certain file [2]. It
looks like that initial fontification indeed fails on that
"connection.lua", but after-change refontification works fine.

In a nutshell, the problem is that font-lock-syntactically-fontified
is only moved forward when font-lock-syntactically-fontified < start.
Which means that when you first propertize [s0; s1) and then
propertize [s1, s2), font-lock-syntactically-fontified will still be
at s1 which is clearly inconsistent. Let's look at the initial
fontification of the file I've referenced above that exhibits that
behaviour (messages are annotated with their respective line numbers
according to [3]):

===========
1212: unfontify-region: [1; 520]
1217: font-lock-syntactically-fontified: 0
1217: start: 1
1218: moving start to 1
1219: set font-lock-syntactically-fontified: 520
1220: font-lock-fontify-syntactic-keywords-region: [1; 520]
============
1212: unfontify-region: [520; 1082]
1217: font-lock-syntactically-fontified: 520
1217: start: 520
1220: font-lock-fontify-syntactic-keywords-region: [520; 1082]
============
1212: unfontify-region: [1082; 1583]
1217: font-lock-syntactically-fontified: 520
1217: start: 1082
1218: moving start to 520
1219: set font-lock-syntactically-fontified: 1583
1220: font-lock-fontify-syntactic-keywords-region: [520; 1583]

As you can see, for the third iteration start moves back to the
beginning of the second chunk and it tries to re-propertize it without
unfontifying which causes an bug in lua-mode's syntactic keyword
handling. I do know that I (ab-)used a deprecated variable to maintain
compatibility with Emacs23 and using `syntax-propertize-function`
should fix that for Emacs24, but I'd be grateful if anyone pointed me
to a simple fix for Emacs23.

Cheers,
immerrr

1. http://comments.gmane.org/gmane.emacs.devel/153447
2. https://github.com/immerrr/lua-mode/issues/78
3. http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/font-lock.el#n1212



reply via email to

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