all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug in font-lock-syntactic-keywords handling?
@ 2014-10-06 11:42 immerrr again
  2014-10-06 13:14 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: immerrr again @ 2014-10-06 11:42 UTC (permalink / raw
  To: emacs-devel

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



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

end of thread, other threads:[~2014-10-06 23:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-06 11:42 Bug in font-lock-syntactic-keywords handling? immerrr again
2014-10-06 13:14 ` Stefan Monnier
2014-10-06 14:21   ` immerrr again
2014-10-06 16:28     ` Stefan Monnier
2014-10-06 23:27       ` immerrr again

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.