[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex de6aa05d74 05/13: Make `texmathp' aware of verba
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex de6aa05d74 05/13: Make `texmathp' aware of verbatim macros/environments |
Date: |
Sun, 5 Mar 2023 03:25:39 -0500 (EST) |
branch: externals/auctex
commit de6aa05d741d393d020f9fa46a0fd2ad050992b6
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Make `texmathp' aware of verbatim macros/environments
* tests/latex/texmathp-test.el (texmathp-verbatim): New test.
* texmathp.el (texmathp): Use `LaTeX-verbatim-p' to check if the
math command is inside a verbatim construct. (bug#61410)
---
tests/latex/texmathp-test.el | 22 ++++++++++++++++++++++
texmathp.el | 27 ++++++++++++++++++++-------
2 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/tests/latex/texmathp-test.el b/tests/latex/texmathp-test.el
index 3fb6f5497c..121af22c7f 100644
--- a/tests/latex/texmathp-test.el
+++ b/tests/latex/texmathp-test.el
@@ -48,4 +48,26 @@
(LaTeX-mode)
(texmathp))))
+;; bug#61410
+(ert-deftest texmathp-verbatim ()
+ "Test for math command inside verbatim which is ignored."
+ (let ((TeX-install-font-lock #'font-latex-setup))
+ (should-not (with-temp-buffer
+ (insert "a $b$ \\verb|$| c ")
+ (LaTeX-mode)
+ (font-lock-ensure)
+ (texmathp)))
+
+ (should-not (with-temp-buffer
+ (insert "\
+a $b$
+
+\\begin{verbatim}
+$
+\\end{verbatim}
+c")
+ (LaTeX-mode)
+ (font-lock-ensure)
+ (texmathp)))))
+
;;; texmathp-test.el ends here
diff --git a/texmathp.el b/texmathp.el
index ad0089863a..1030ed858b 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -283,7 +283,7 @@ See the variable `texmathp-tex-commands' about which
commands are checked."
(if (eq major-mode 'doctex-mode)
"[\n\r]%*[ \t]*[\n\r]"
"[\n\r][ \t]*[\n\r]")
- nil 1 texmathp-search-n-paragraphs)
+ nil 1 texmathp-search-n-paragraphs)
(match-beginning 0)
(point-min))))
(mac-match (texmathp-match-macro bound))
@@ -321,12 +321,25 @@ See the variable `texmathp-tex-commands' about which
commands are checked."
;; Store info, show as message when interactive, and return
(setq texmathp-why match)
- (and (called-interactively-p 'any)
- (message "math-mode is %s: %s begins at buffer position %d"
- (if math-on "on" "off")
- (or (car match) "new paragraph")
- (cdr match)))
- (and math-on t)))
+ ;; Check also if the match is inside a verbatim construct and
+ ;; return immediately nil. This relies on the function
+ ;; `LaTeX-verbatim-p'. We add a check here in case this library
+ ;; is used stand-alone without latex.el provided by AUCTeX
+ ;; (bug#61410):
+ (if (and (fboundp 'LaTeX-verbatim-p)
+ (save-excursion (LaTeX-verbatim-p (cdr match))))
+ (progn
+ (setq texmathp-why `(nil . ,(cdr match)))
+ (when (called-interactively-p 'any)
+ (message "math-mode is off: Math command in verbatim construct at
buffer position %d"
+ (cdr match)))
+ nil)
+ (and (called-interactively-p 'any)
+ (message "math-mode is %s: %s begins at buffer position %d"
+ (if math-on "on" "off")
+ (or (car match) "new paragraph")
+ (cdr match)))
+ (and math-on t))))
(defun texmathp-match-environment (bound)
"Find out if point is inside any of the math environments.
- [elpa] externals/auctex 41397e93cb 04/13: ; Improve last change, (continued)
- [elpa] externals/auctex 41397e93cb 04/13: ; Improve last change, Tassilo Horn, 2023/03/05
- [elpa] externals/auctex 5cf1dd2ae2 01/13: Indent the active region (bug#48518, bug#28382), Tassilo Horn, 2023/03/05
- [elpa] externals/auctex 3564d9467e 10/13: ; Fix typos, Tassilo Horn, 2023/03/05
- [elpa] externals/auctex 992410a201 02/13: ; * style/physics.el: Fix trivial typo., Tassilo Horn, 2023/03/05
- [elpa] externals/auctex 9d8bd6b30e 06/13: Update style/ltugboat.el to class version 2.28, Tassilo Horn, 2023/03/05
- [elpa] externals/auctex fbc6399b99 09/13: Add new tests, Tassilo Horn, 2023/03/05
- [elpa] externals/auctex b77907698e 12/13: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2023/03/05
- [elpa] externals/auctex bbb4e2ae23 08/13: Fill \verb-like macros appropriately (bug#61400), Tassilo Horn, 2023/03/05
- [elpa] externals/auctex 658832b8a2 13/13: Release GNU AUCTeX 13.1.10, Tassilo Horn, 2023/03/05
- [elpa] externals/auctex 358cc74dda 03/13: Add new style/algpseudocodex.el, Tassilo Horn, 2023/03/05
- [elpa] externals/auctex de6aa05d74 05/13: Make `texmathp' aware of verbatim macros/environments,
Tassilo Horn <=
- [elpa] externals/auctex 4c77908707 11/13: Fix \includegraphics key-vals prompt in beamer documents., Tassilo Horn, 2023/03/05
- [elpa] externals/auctex 4959b9d240 07/13: * style/url.el ("url"): Add missing \DeclareUrlCommand macro., Tassilo Horn, 2023/03/05