Hi Arash, hi Ikumi,
I ran your suggestion through the same test set I had used before (31 cases,
emacs -Q, AUCTeX 14.1.0). It behaves correctly: the original “$a$\$b$” case
and the tabular variants are fixed, Ikumi’s “\$“ counterexample stays off,
backslash runs of length 0 to 8 before a “$” toggle with the right
parity, and
the base cases (“$x+y$”, “$$a+b$$”, “$5”, an escaped “$“ inside math, math
environments) are unchanged.
On the performance concern: 2000 calls over a 40-line buffer with inline
math
and a tabular took 3.21 s with the current code and 3.43 s with your
version,
i.e. some 7%. That doesn’t look like a problem for font-lock.
Please consider my own proposal withdrawn, and not merely because of the LLM
policy: yours is simply better. `regexp-opt’ produces the greedy “($$?)“,
so in “$$x$” a single match swallows both dollars; my backslash-parity check
then rejects the whole match and loses the genuine opening “$”. “$$x$”,
“$a$$ …” and “\$$x$” come out wrong with my formulation and right with
yours. They may be worth keeping as test cases, whichever way the fix
ends up
being written.
Two things I noticed while testing:
*
|texmathp-onoff-regexp' carries the same defective prefix
"\(?:[^\]\|\|)“,
so the problem is not confined to the togglers. With unmodified 14.1.0,
“\(x)“ and “foo\[x]“ return nil, while “(x)“ returns t. The switches
may deserve the same treatment.
*
|(TeX-escaped-p (1- (point)))' examines the last character of the
match, which is exactly right for "$" and "$$". Is it meant to be
correct as well for a multi-character toggler added by a user via
|texmathp-tex-commands’
with type `sw-toggle’?
Ikumi: for the record, “(`|)“ is not mine – my proposal was “(\*)“.
To be explicit about provenance: the tests above were designed and run by an
AI
assistant (Claude Code) driving a real emacs -Q with AUCTeX 14.1.0 loaded. I
have not re-checked the please take them as a
report of observed behaviour and reproduce them on your side before
relying on
them.
Best,
Gabriele
Il 01/08/26 13:09, Ikumi Keita ha scritto:
Hi Arash,
Arash Esbati<[email protected]> writes:
texmathp-toggle-regexp
;; Next line changed:
;; (concat "\\([^\\$]\\|\\`\\)"
(concat "\\(\\`\\|\\)"
so I really didn't touch that regexp (I was in a hurry anyways).
Hmm, I'm not sure whether I understand. Do you mean that the regexp
"\\(\\`\\|\\)" was proposed by Gabriele? But as far as I can see, this
regexp first appeared in your message
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=81327#14
in this thread, so I thought you invented it.
So should we do this, WDYT? If so, I can prepare a better patch you
can review.
Anyway, I agree the basic idea to use `TeX-escaped-p'. I expect it would
work without much overhead.
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopGenocide #CeasefireNOW
#IProtestAgainstTrumpAndNetanyahu'sAttackOnIran,WhichViolatesInternationalLaw
--
SISSA Medialab
* Publishing *
*Gabriele Nicolardi*
*Production specialist*
*[email protected]*
------------------------------------------------------------------------
*Via Bonomea, 265 - 34136 Trieste, Italy - medialab.sissa.it
<http://medialab.sissa.it/en>*<http://medialab.sissa.it/en>
​
_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex