I frequently have color-bleed issues in emacs, most often with AUCTeX: all of a sudden and for no apparent reason, the line I'm writing will be fontified as math.

First things first: no, I do not have any lone $ character in a verbatim context. ;)

When it happens, I have a couple workarounds: I use font-lock-fontify-buffer (I have now hooked it into various commands such as save-file), or I scroll back up and back down. Occasionally, when it does not help, I can locate a line at which the font-issue starts, and sometimes there is a visible problem in that line (e.g. $a[b$).

The problem is not related to AUCTeX's syntactic parser, for example texmathp returns the correct answer, regardless of the font.

Given the lack of results from google about it, I'm pretty sure it is a problem in my configuration. But I can't reproduce the bleeding consistently, so proceeding on a dichotomy search in my init files looks like a daunting task.

Is it possible to examine font-lock's mechanic in vivo, so that I can investigate the bug when I see it?

  • font-latex.el parser doesn't use texmathp (which in turn doesn't rely on font-locking) so there may well be a bug in font-latex.el. To be honest, it happened to me a couple of times that a large part of Elisp code was fontified like if it were all a single string, which wasn't. I'm also very interested in advice about how to debug font-locking.
    – giordano
    Commented Feb 23, 2016 at 12:15
  • I have similar problems. Did you solve the issue?
    – student
    Commented Apr 8, 2021 at 20:15
  • @student I did not personally make any progress, but the problem is not as noticeable as it used to be. I seem to recall seeing some mentions of it on the auctex-devel mailing list, so it could be that a somewhat recent update improved the situation.
    – T. Verron
    Commented Apr 9, 2021 at 17:18
  • font-lock-studio is not helping in your case because of the randomness of the error, is it?
    – Tobias
    Commented Apr 12, 2021 at 6:48
  • Could it be that it is a multi-line issue? Does that happen for inline math expressions that span several lines?
    – Tobias
    Commented Apr 12, 2021 at 6:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.