Subject: bug#50202: bibtex-mode: unescaped dollar sign in file field leads to wrong highlighting

From: Roland Winkler <[email-masked]>
Date: Fri, 26 Aug 2022 10:52:55 -0500

On Thu, Aug 25 2022, Stefan Monnier wrote:
> The downside of treating $ as punctuation is that $^2$ won't be
> highlighted specially, but the upside is that "foo$bar" won't be
> mishighlighted in a url.
>
> To me the highlighting of math formulas is sufficiently secondary that
> I'd err on the safe side (i.e. avoid mishighlighting).

For me, the situation is opposite: in my BibTeX files (with quite many
entries that have accumulated over the years), many entries contain
LaTeX constructs like $^2$ so that I appreciate proper highlighting.
But I never encountered the opposite problem when a field should contain
a single $.

> The other option is to try and make this choice on a field-by-field
> basis, which seems like a lot of work for fairly little benefit.

I agree it doesn't make sense to (try to) highlight different fields
differently.  That's why I suggest that bibtex-mode continues to use
only one syntax table.  But make it customizable how this syntax table
treats $: You and the OP can make it a punctuation character (also fine
with me as default, it doesn't cause harm), while it remains possible to
keep the current behavior.

Roland