GNU bug report logs -
#78006
Improving `TeX-electric-math' behavior
Previous Next
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
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#78006: Improving `TeX-electric-math' behavior
which was filed against the auctex package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 78006 <at> debbugs.gnu.org.
--
78006: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78006
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Keita Ikumi <ikumikeita <at> jcom.home.ne.jp> writes:
> Well, since docTeX-mode is already derived from
> LaTeX-mode, we can just do
> (derived-mode-p 'LaTeX-mode)
> :-)
Ah, thanks. I installed that change and therefore closing this report.
Thanks to you all for your comments.
Best, Arash
[Message part 3 (message/rfc822, inline)]
Hi all,
currently, we have this in AUCTeX manual[1]:
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':
--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index 3d28b2c6..5d184942 100644
--- a/tex.el
+++ b/tex.el
@@ -6188,10 +6188,13 @@ See `TeX-electric-math'."
(re-search-forward "\\=\\$\\$\\([^z-a]*\\)\\$\\$" (mark) t)))
(replace-match "\\1" t)
(set-mark (match-beginning 0)))
- ;; $...$ to $$...$$
+ ;; $...$ to $$...$$ or \[...\] dep. on mode:
((and (eq last-command #'TeX-insert-dollar)
(re-search-forward "\\=\\$\\([^z-a]*\\)\\$" (mark) t))
- (replace-match "$$\\1$$" t)
+ (replace-match (if (memq major-mode '(LaTeX-mode docTeX-mode))
+ "\\\\[\\1\\\\]"
+ "$$\\1$$")
+ t)
(set-mark (match-beginning 0)))
;; \(...\) to \[...\]
((and (eq last-command #'TeX-insert-dollar)
--8<---------------cut here---------------end--------------->8---
I think this needs some more massaging in order to make it work for
ConTeXt users as well, but this should get us going for other modes.
What do people think? If Ok, I would install it and update the manual
accordingly.
Best, Arash
Footnotes:
[1] https://elpa.gnu.org/packages/doc/auctex.html#index-TeX_002delectric_002dmath
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.