10

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?

T. Verron
  • 4,233
  • 1
  • 22
  • 55
  • `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 Feb 23 '16 at 12:15
  • I have similar problems. Did you solve the issue? – student Apr 08 '21 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 Apr 09 '21 at 17:18
  • [`font-lock-studio`](https://github.com/Lindydancer/font-lock-studio) is not helping in your case because of the randomness of the error, is it? – Tobias Apr 12 '21 at 06:48
  • Could it be that it is a multi-line issue? Does that happen for inline math expressions that span several lines? – Tobias Apr 12 '21 at 06:51
  • As far as I remember I found out about font-lock-studio after the situation improved and/or at a time when I had more pressing issues to deal with. That could hovewer be helpful to @student if they still have the problem. As for multi-line maths, that definitely seemed connected to the problem, yes: frequently, when scrolling back up to find the "starting point" for the bleeding, it would be in a very long inline maths expression. Also more often, it would be spanning multiple-lines because of soft-wrapping, and forcing line breaks at sensible points would fix the problem temporarily. – T. Verron Apr 12 '21 at 10:29
  • But it was not reliable enough to create a reproducible recipe or a viable fix. – T. Verron Apr 12 '21 at 10:30
  • I have no suggestions, but this plagues me too, in org mode and markdown mode buffers with including code blocks. Not infrequently, Emacs will fontify an entire block as if it were a quoted string. Adding a space in the header may temporarily correct this (i.e., the correct fontification returns), but once it starts, the problem returns frequently. – Tyler Apr 14 '21 at 20:16
  • @Tobias: I will try it, if the error occurs again. What really sucks is that you cannot say that you do this or that to reproduce the error and then try different things to investigate it. Mostly the error occurs, when I don't have time to investigate it, and If I have time I cannot reproduce it in most cases :-(. – student Apr 17 '21 at 08:37

0 Answers0