branch: main commit 93a415c4537228ad5f9757244611e9eb8f57727d Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Replace $...$ depending on major-mode * NEWS.org (Changed): Announce the change. * doc/auctex.texi (Quotes): Adjust accordingly. * tex.el (TeX-insert-dollar-electric-region): Replace $...$ by $$...$$ in `plain-TeX-mode' and by \[...\] in `LaTeX-mode' and `docTeX-mode'. (bug#78006) --- NEWS.org | 2 ++ doc/auctex.texi | 3 ++- tex.el | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS.org b/NEWS.org index a2ca10d3..8917727b 100644 --- a/NEWS.org +++ b/NEWS.org @@ -16,6 +16,8 @@ ** Changed - AUCTeX now requires GNU Emacs 28.1 or higher. +- Replace $..$ with \[..\] in ~LaTeX-mode~ and any derived mode when + hitting =$= repeatedly where ~TeX-electric-math~ is non-~nil~. ** Fixed diff --git a/doc/auctex.texi b/doc/auctex.texi index 7cca6f8b..46ed6f95 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -447,7 +447,8 @@ symbols for opening and closing inline equation and keep the region active, leaving point after the closing symbol. By pressing repeatedly @kbd{$} while the region is active you can toggle between an inline equation, a display equation, and no equation. To be precise, -@samp{$...$} is replaced by @samp{$$...$$}, whereas @samp{\(...\)} is +@samp{$...$} is replaced by @samp{$$...$$} in plain-TeX-mode or +@samp{\[...\]} in LaTeX-mode and docTeX-mode, whereas @samp{\(...\)} is replaced by @samp{\[...\]}. @end defopt diff --git a/tex.el b/tex.el index 3d28b2c6..e90252d8 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) + "\\\\[\\1\\\\]" + "$$\\1$$") + t) (set-mark (match-beginning 0))) ;; \(...\) to \[...\] ((and (eq last-command #'TeX-insert-dollar)