auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 2f1369fc0115addb375df


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 2f1369fc0115addb375df0064460178705ff658c
Date: Thu, 28 May 2020 02:19:28 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  2f1369fc0115addb375df0064460178705ff658c (commit)
      from  d27f6a12d89a094bf5fd8f45f5ef7a16a9a9b29f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2f1369fc0115addb375df0064460178705ff658c
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date:   Thu May 28 14:52:01 2020 +0900

    Fix false negative of texmathp (bug#41559)
    
    * texmathp.el (texmathp-compile): Fix `texmathp-onoff-regexp' to allow
    switch to begin at (point-min).
    Use `regexp-opt' instead of `mapconcat'+`regexp-quote'.
    (texmathp): Use `>=' instead of `>' so that match is updated even when
    arg-on or sw-on begins at (point-min).
    * tests/latex/texmathp-test.el: New test.

diff --git a/tests/latex/texmathp-test.el b/tests/latex/texmathp-test.el
new file mode 100644
index 0000000..a1313b9
--- /dev/null
+++ b/tests/latex/texmathp-test.el
@@ -0,0 +1,51 @@
+;;; texmathp-test.el --- tests for texmathp
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Code:
+
+(require 'ert)
+(require 'latex)
+(require 'texmathp)
+
+;; bug#41559
+(ert-deftest texmathp-bob ()
+  "Test math expressions beginning at BOB are identified correctly."
+  (should (with-temp-buffer
+           (insert "\\(")
+           (LaTeX-mode)
+           (texmathp)))
+
+  (should (with-temp-buffer
+           (insert "\\[")
+           (LaTeX-mode)
+           (texmathp)))
+
+  (should (with-temp-buffer
+           (insert "\\ensuremath{")
+           (LaTeX-mode)
+           (texmathp)))
+
+  (should (with-temp-buffer
+           (insert "$")
+           (LaTeX-mode)
+           (texmathp))))
+
+;;; texmathp-test.el ends here
diff --git a/texmathp.el b/texmathp.el
index ba5aba3..723623b 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -185,13 +185,11 @@ customize (customize calls it when setting the variable)."
                      ((memq type '(sw-toggle))      'togglers)))
       (set var (cons (car entry) (symbol-value var))))
     (setq texmathp-onoff-regexp
-         (concat "[^\\\\]\\("
-                 (mapconcat 'regexp-quote switches "\\|")
-                 "\\)")
+         (concat "\\(?:[^\\\\]\\|\\`\\)"
+                 (regexp-opt switches t))
          texmathp-toggle-regexp
-         (concat "\\([^\\\\\\$]\\|\\`\\)\\("
-                 (mapconcat 'regexp-quote togglers "\\|")
-                 "\\)"))))
+         (concat "\\([^\\\\\\$]\\|\\`\\)"
+                 (regexp-opt togglers t)))))
 
 (defcustom texmathp-tex-commands nil
   "List of environments and macros influencing (La)TeX math mode.
@@ -287,14 +285,17 @@ See the variable `texmathp-tex-commands' about which 
commands are checked."
 
     ;; Select the nearer match
     (and env-match (setq match env-match))
-    (and mac-match (> (cdr mac-match) (cdr match)) (setq match mac-match))
+    ;; Use `>=' instead of `>' in case called inside \ensuremath{..}
+    ;; beginning just at (point-min).
+    (and mac-match (>= (cdr mac-match) (cdr match)) (setq match mac-match))
     (setq math-on (memq (nth 1 (assoc (car match) texmathp-tex-commands1))
                        '(env-on arg-on)))
 
     ;; Check for switches
     (and (not math-on)
         (setq sw-match (texmathp-match-switch bound))
-        (> (cdr sw-match) (cdr match))
+        ;; Use `>=' instead of `>' by similar reason as above. (bug#41559)
+        (>= (cdr sw-match) (cdr match))
         (eq (nth 1 (assoc (car sw-match) texmathp-tex-commands1)) 'sw-on)
         (setq match sw-match math-on t))
 

-----------------------------------------------------------------------

Summary of changes:
 .../path-expansion.el => latex/texmathp-test.el}   | 42 +++++++++++++++-------
 texmathp.el                                        | 17 ++++-----
 2 files changed, 38 insertions(+), 21 deletions(-)
 copy tests/{tex/path-expansion.el => latex/texmathp-test.el} (55%)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]