branch: main commit 6240064f23024807f1cf1b4adeccc04890805908 Merge: 54970585 e410168c Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge remote-tracking branch 'origin/master' into externals/auctex --- font-latex.el | 2 +- tests/latex/texmathp-test.el | 51 ++++++++++++++++++++++++++++++++++++++++++++ tex.el | 3 +-- texmathp.el | 17 ++++++++------- 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/font-latex.el b/font-latex.el index 6210967d..91137bac 100644 --- a/font-latex.el +++ b/font-latex.el @@ -1328,7 +1328,7 @@ If SYNTACTIC-KWS is non-nil, also update (defun font-latex-unfontify-region (beg end &rest ignored) "Unfontify region from BEG to END." (font-lock-default-unfontify-region beg end) - (remove-text-properties beg end '(script-level)) + (remove-list-of-text-properties beg end '(script-level invisible)) (while (< beg end) (let ((next (next-single-property-change beg 'display nil end)) (prop (get-text-property beg 'display))) diff --git a/tests/latex/texmathp-test.el b/tests/latex/texmathp-test.el new file mode 100644 index 00000000..a1313b9f --- /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/tex.el b/tex.el index e8b9e72c..9a1d1b6d 100644 --- a/tex.el +++ b/tex.el @@ -1,6 +1,6 @@ ;;; tex.el --- Support for TeX documents. -;; Copyright (C) 1985-1987, 1991, 1993-2019 Free Software Foundation, Inc. +;; Copyright (C) 1985-2020 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex @@ -2998,7 +2998,6 @@ FORCE is not nil." (defvar TeX-remove-style-hook nil "List of hooks to call when we remove the style specific information.") - (make-variable-buffer-local 'TeX-remove-style-hook) (defun TeX-remove-style () "Remove all style specific information." diff --git a/texmathp.el b/texmathp.el index ba5aba39..723623bc 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))