From: immerrr again <immerrr+lua@gmail.com>
To: emacs-devel@gnu.org
Subject: Bug in font-lock-syntactic-keywords handling?
Date: Mon, 6 Oct 2014 15:42:19 +0400 [thread overview]
Message-ID: <CAERznn8OWJZNumUYx8OVMDTs8bjLCF9svFn6P9N69dzQ3TZ+FA@mail.gmail.com> (raw)
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
next reply other threads:[~2014-10-06 11:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-06 11:42 immerrr again [this message]
2014-10-06 13:14 ` Bug in font-lock-syntactic-keywords handling? Stefan Monnier
2014-10-06 14:21 ` immerrr again
2014-10-06 16:28 ` Stefan Monnier
2014-10-06 23:27 ` immerrr again
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=CAERznn8OWJZNumUYx8OVMDTs8bjLCF9svFn6P9N69dzQ3TZ+FA@mail.gmail.com \
--to=immerrr+lua@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.