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


View this message in rfc822 format

From: Arash Esbati <arash <at> gnu.org>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 78006 <at> debbugs.gnu.org
Subject: bug#78006: Improving `TeX-electric-math' behavior
Date: Sat, 03 May 2025 10:37:47 +0200
Hi Keita,

Ikumi Keita <ikumi <at> ikumi.que.jp> writes:

> I think we should use `derived-mode-p' here instead of comparing
> `major-mode' directly.

Thanks for your response.  Something like this?

--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index 3d28b2c6..0d47988c 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 (derived-mode-p '(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---

Best, Arash




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.