GNU bug report logs - #78006
Improving `TeX-electric-math' behavior

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Wed, 23 Apr 2025 07:27:01 UTC

Severity: normal

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 78006 <at> debbugs.gnu.org (full text, mbox):

From: "Paul D. Nelson" <ultrono <at> gmail.com>
To: Arash Esbati <arash <at> gnu.org>
Cc: 78006 <at> debbugs.gnu.org
Subject: Re: bug#78006: Improving `TeX-electric-math' behavior
Date: Thu, 24 Apr 2025 11:55:44 +0200
>   User Option: TeX-electric-math
>
>   In addition, when the variable is non-nil and there is an active
>   region outside math mode, typing $ will put around the active region
>   symbols for opening and closing inline equation and keep the region
>   active, leaving point after the closing symbol.  By pressing
>   repeatedly $ while the region is active you can toggle between an
>   inline equation, a display equation, and no equation.  To be precise,
>   ‘$...$’ is replaced by ‘$$...$$’, whereas ‘\(...\)’ is replaced by
>   ‘\[...\]’.
>
> Using $$...$$ in LaTeX is discouraged, so I think AUCTeX shouldn't
> promote this as well, so I suggest this change to
> `TeX-insert-dollar-electric-region':

Looks good to me overall.

One counterintuitive edge case: if I mark x and hit $ repeatedly, then I
get $x$ -> \[x\] -> x -> etc.  On the other hand, if I mark $x$ and hit
$, then I get $$x$$ -> $x$ -> etc.

I also wonder then whether TeX-insert-dollar (x2) should then similarly
insert $$|$$ or \[|\] according to mode?

Tangentially, I wonder whether this feature might be more useful if it
worked not just when operating on a region for the first time, but more
generally on any math region, as a way to cycle between inline and
displayed math.  I've had "make-inline" and "make-displayed" functions
in my config for a long time now that I've tried unsuccessfully to think
of an elegant way to package and contribute.




This bug report was last modified 19 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.