Gunnar Evermann <ge204(a)eng.cam.ac.uk> writes:
I intend to forward some of the more useful bug reports from our BTS
to xemacs-beta in the future, so that more people can have a go at
fixing them.
[...]
Quite often it seems to happen (at least for me) that the LaTeX mode
font-lock loses sync between math and non-math. The primary cause
appears to be when fairly complex inline math expressions are split
across line boundaries.
The following file excerpt exhibits this problem:
[...]
{\bf y}$ will be real, as required.
^
Here is the problem. For certain reasons, XEmacs' C support for
font-locking strings and comments gets confused when it encounters an
open paren at the beginning of line in a multi-line string or comment.
The problem is shared in basically all modes that use the
`buffer-syntactic-context' interface, i.e. all modes that use
font-locking.
If you rewrite the text so that { is no longer at the beginning of
line, or quote it with however you quote things in TeX, you'll see
that the problem goes away. You'll note that docstrings with lines
starting with parens invariable have the parens quoted.
The reason behind the bug is efficiency: font-lock.c scans the buffer
backwards to determine where it should start the analysis from. If it
encounters a paren at the beginning of line, it assumes it's safe to
start there. Without that optimization, it would have to scan the
whole buffer every time.
I don't know if a fix is possible, other than rewriting the whole
thing to use a different algorithm.