Subject: bug#57626: 13.1.4; cases* environment doesn't let me use $

From: Arash Esbati <[email-masked]>
Date: Fri, 09 Sep 2022 11:43:48 +0200

Hi Keita,

Ikumi Keita <[email-masked]> writes:

> Ah, it's the same as
> https://tex.stackexchange.com/questions/578900/auctex-math-mode-started-with-cannot-be-closed-with-dollar-in-cases
> ...
> As written there, temporal workaround is to type C-u $ or C-q $ to
> insert "$" in such a case.

Ah, thanks for reminding me.  The question sounded familiar to me :-)

>>>>>> Arash Esbati <[email-masked]> writes:
>> I think this a corner case where half of a environment is math and the
>> other half text.  AUCTeX thinks that the entire environment is math and
>> hence throws an error.  I don't have a strong opinion about this, we can
>> add some entries like this to `texmathp-tex-commands-default':
>
>>     ("cases*"   env-off)
>>     ("dcases*"  env-off)
>>     ("rcases*"  env-off) 
>>     ("drcases*" env-off)
>
>> What do others think?
>
> In my opinion, `TeX-insert-dollar' is too patriarchal in this case. The
> intention of `texmathp' is apparently to be "practical enough", not
> "precise". It sometimes by design gives false positives and false
> negatives, which we should anticipate.
>
> How about to allow insertion of "$" (or anything according to
> `TeX-electric-math') when `last-command' is `TeX-insert-dollar' in a
> case like this issue? I suppose that most users would type "$" again
> before seeing "Math mode started with `...' cannot be closed with
> dollar" when "$" is refused unexpectedly.

You mean in case a user says: "Dammit AUCTeX, I know what I'm doing,
insert what I type!"  Checking `last-command' might be a solution, but
is it worth to introduce it where 'C-q <char>' is already available?
Now one could argue that " does the same in terms of insert `` first and
upon second invocation replace that with ", but I'm not sure $ should do
the same.  But I don't have a strong opinion on this, if you think we
should change this, please go ahead :-)

Regardless of this, I think adding the cases entries above to
`texmathp-tex-commands-default' would make sense and cures the issue at
hand.  WDYT?

Best, Arash