[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 42150568f1 06/48: Allow user to insert "$" (bug#
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 42150568f1 06/48: Allow user to insert "$" (bug#57626) |
Date: |
Fri, 18 Nov 2022 14:27:42 -0500 (EST) |
branch: externals/auctex
commit 42150568f1d8ef9a556ecdc3f107e7f4cb02e7a9
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Allow user to insert "$" (bug#57626)
* tex.el (TeX-insert-dollar): Let user to insert "$" when `texmathp'
thinks that the math mode didn't start with dollar, considering it
isn't actually in math mode.
Fix doc string along with the above change.
* texmathp.el: Add cases* env issue in BUGS section of header
comments.
---
tex.el | 92 +++++++++++++++++++++++++++++++------------------------------
texmathp.el | 17 ++++++++----
2 files changed, 58 insertions(+), 51 deletions(-)
diff --git a/tex.el b/tex.el
index a52bf3cbf3..9a57d45895 100644
--- a/tex.el
+++ b/tex.el
@@ -5942,9 +5942,8 @@ point. You can choose between \"$...$\" and
\"\\(...\\)\"."
(defun TeX-insert-dollar (&optional arg)
"Insert dollar sign.
-If current math mode was not entered with a dollar, refuse to
-insert one. Show matching dollar sign if this dollar sign ends
-the TeX math mode and `blink-matching-paren' is non-nil.
+Show matching dollar sign if this dollar sign ends the TeX math
+mode and `blink-matching-paren' is non-nil.
When outside math mode, the behavior is controlled by the variable
`TeX-electric-math'.
@@ -5996,51 +5995,54 @@ With optional ARG, insert that many dollar signs."
(buffer-substring
(point) (progn (end-of-line) (point))))))))
(t
- ;; Math mode was not entered with dollar - we cannot finish it
- ;; with one.
- (message "Math mode started with `%s' cannot be closed with dollar"
- (car texmathp-why)))))
+ ;; Math mode was not entered with dollar - we assume that
+ ;; `texmathp' was wrong and behave as if not in math
+ ;; mode. (bug#57626)
+ (TeX--insert-dollar-1))))
(t
;; Just somewhere in the text.
+ (TeX--insert-dollar-1))))
+
+(defun TeX--insert-dollar-1 ()
+ "Do the job of `TeX-insert-dollar' in non-math mode."
+ (cond
+ ((and TeX-electric-math (TeX-active-mark)
+ (/= (point) (mark)))
+ (if (> (point) (mark))
+ (exchange-point-and-mark))
(cond
- ((and TeX-electric-math (TeX-active-mark)
- (/= (point) (mark)))
- (if (> (point) (mark))
- (exchange-point-and-mark))
- (cond
- ;; $...$ to $$...$$
- ((and (eq last-command #'TeX-insert-dollar)
- (re-search-forward "\\=\\$\\([^$][^z-a]*[^$]\\)\\$" (mark) t))
- (replace-match "$$\\1$$" t)
- (set-mark (match-beginning 0)))
- ;; \(...\) to \[...\]
- ((and (eq last-command #'TeX-insert-dollar)
- (re-search-forward "\\=\\\\(\\([^z-a]*\\)\\\\)" (mark) t))
- (replace-match "\\\\[\\1\\\\]" t)
- (set-mark (match-beginning 0)))
- ;; Strip \[...\] or $$...$$
- ((and (eq last-command #'TeX-insert-dollar)
- (or (re-search-forward "\\=\\\\\\[\\([^z-a]*\\)\\\\\\]" (mark) t)
- (re-search-forward "\\=\\$\\$\\([^z-a]*\\)\\$\\$" (mark) t)))
- (replace-match "\\1" t)
- (set-mark (match-beginning 0)))
- (t
- ;; We use `save-excursion' because point must be situated
- ;; before opening symbol.
- (save-excursion (insert (car TeX-electric-math)))
- (exchange-point-and-mark)
- (insert (cdr TeX-electric-math))))
- ;; Keep the region active.
- (TeX-activate-region))
- (TeX-electric-math
- (insert (car TeX-electric-math))
- (save-excursion (insert (cdr TeX-electric-math)))
- (if blink-matching-paren
- (save-excursion
- (backward-char)
- (sit-for blink-matching-delay))))
- ;; In any other case just insert a single $.
- ((insert "$")))))
+ ;; $...$ to $$...$$
+ ((and (eq last-command #'TeX-insert-dollar)
+ (re-search-forward "\\=\\$\\([^$][^z-a]*[^$]\\)\\$" (mark) t))
+ (replace-match "$$\\1$$" t)
+ (set-mark (match-beginning 0)))
+ ;; \(...\) to \[...\]
+ ((and (eq last-command #'TeX-insert-dollar)
+ (re-search-forward "\\=\\\\(\\([^z-a]*\\)\\\\)" (mark) t))
+ (replace-match "\\\\[\\1\\\\]" t)
+ (set-mark (match-beginning 0)))
+ ;; Strip \[...\] or $$...$$
+ ((and (eq last-command #'TeX-insert-dollar)
+ (or (re-search-forward "\\=\\\\\\[\\([^z-a]*\\)\\\\\\]" (mark) t)
+ (re-search-forward "\\=\\$\\$\\([^z-a]*\\)\\$\\$" (mark) t)))
+ (replace-match "\\1" t)
+ (set-mark (match-beginning 0)))
+ (t
+ ;; We use `save-excursion' because point must be situated
+ ;; before opening symbol.
+ (save-excursion (insert (car TeX-electric-math)))
+ (exchange-point-and-mark)
+ (insert (cdr TeX-electric-math))))
+ (TeX-activate-region))
+ (TeX-electric-math
+ (insert (car TeX-electric-math))
+ (save-excursion (insert (cdr TeX-electric-math)))
+ (if blink-matching-paren
+ (save-excursion
+ (backward-char)
+ (sit-for blink-matching-delay))))
+ ;; In any other case just insert a single $.
+ ((insert "$")))
(TeX-math-input-method-off))
(defcustom TeX-math-input-method-off-regexp
diff --git a/texmathp.el b/texmathp.el
index f02824cec1..ad0089863a 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -1,6 +1,6 @@
;;; texmathp.el -- Code to check if point is inside LaTeX math environment
-*- lexical-binding: t; -*-
-;; Copyright (C) 1998-2021 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2022 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -85,14 +85,19 @@
;;
;; BUGS:
;;
-;; If any of the the special macros like \mbox or \ensuremath has optional
-;; arguments, math mode inside these optional arguments is *not* influenced
-;; by the macro.
+;; o If any of the the special macros like \mbox or \ensuremath has
+;; optional arguments, math mode inside these optional arguments is
+;; *not* influenced by the macro.
;;
-;; Nested \(\) and \[\] can confuse texmathp. It returns nil at AAA
-;; in the following examples:
+;; o Nested \(\) and \[\] can confuse texmathp. It returns nil at AAA
+;; in the following examples:
;; \[ x=y \mbox{abc \(\alpha\) cba} AAA \]
;; \[ x=y \begin{minipage}{3cm} abc \[\alpha\] cba \end{minipage} AAA \]
+;;
+;; o In the "text column" of cases* environment, texmathp doesn't
+;; consider it's non-math mode. The same applies for variants of
+;; cases* environents, both provided by mathtools package.
+;;
;;--------------------------------------------------------------------------
;;; Code:
- [elpa] externals/auctex 52a7f4050f 27/48: ; * doc/auctex.texi (Adding Environments): Adjust indentation., (continued)
- [elpa] externals/auctex 52a7f4050f 27/48: ; * doc/auctex.texi (Adding Environments): Adjust indentation., Tassilo Horn, 2022/11/18
- [elpa] externals/auctex c0c9556338 30/48: Don't insert empty node name, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex e53bb19a90 37/48: ; Recognize large arguments with many lines, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 52738d11b2 39/48: Remove entry in `LaTeX-completion-function-map-alist-keyval', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex d5ff42e0bd 34/48: Simplify implementation of style/enumitem.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex cb7b44227d 31/48: Improve fontification of indexing macros, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex c8d638ac9d 40/48: Use `functionp' to recognize a function, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 47f9ead1c6 44/48: Respect `TeX-exit-mark' when inserting enviroments, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 04a3138c81 45/48: Simplify implementation of style/theorem.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 487c91fddb 04/48: ; Pacify compiler warning: Unused lexical argument `ignored', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 42150568f1 06/48: Allow user to insert "$" (bug#57626),
Tassilo Horn <=
- [elpa] externals/auctex 978ebea1e8 16/48: Simplify implementation of style/thmtools.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 9b365b7419 18/48: Simplify implementation of style/textpos.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex c6c7c3f024 22/48: ; Use #' to quote function, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 8e3137f641 15/48: Simplify implementation of style/titlesec.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 1f6e9e7e58 10/48: Update style/XCharter.el to package version 1.24, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 748449959c 21/48: New option `TeX-refuse-unmatched-dollar', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex ff5a83f345 17/48: Simplify implementation of style/thm-restate.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex ce15e3fd87 24/48: Extend Japanese TeX support, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 20cabef81f 20/48: ; Delete unnecessary `TeX-arg-string', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 21e624026a 28/48: Improve support for TikZ, Tassilo Horn, 2022/11/18