auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] [elpa] externals/auctex d9e148b 26/27: Merge remote-track


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex d9e148b 26/27: Merge remote-tracking branch 'origin/master' into externals/auctex
Date: Sat, 27 Jun 2020 03:17:46 -0400 (EDT)

branch: externals/auctex
commit d9e148b89a48cbdbd1328cd5735a11da8d9ec131
Merge: 1006b89 3c1f820
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Merge remote-tracking branch 'origin/master' into externals/auctex
---
 Makefile.in                           |   2 +-
 doc/auctex.texi                       |  17 +-
 doc/changes.texi                      |  29 ++++
 doc/todo.texi                         |  15 +-
 font-latex.el                         | 301 ++++++++++++++++++++--------------
 latex.el                              |  10 +-
 style/algorithm.el                    |  80 +++++++++
 style/algpseudocode.el                |  73 +++++++++
 style/alltt.el                        |  11 +-
 style/amsmath.el                      |  33 +++-
 style/beamer.el                       |   9 +-
 style/breqn.el                        |  30 ++--
 style/comment.el                      |  10 +-
 style/empheq.el                       |  41 ++---
 style/expl3.el                        |  14 +-
 style/fancyhdr.el                     |  11 +-
 style/fancyvrb.el                     |  30 ++--
 style/fvextra.el                      |   8 +-
 style/hyperref.el                     |   9 +-
 style/listings.el                     |  15 +-
 style/ltxguide.el                     |   8 +-
 style/mathtools.el                    |  10 +-
 style/minted.el                       |  18 +-
 style/pythontex.el                    |  84 +++++-----
 style/revtex4-2.el                    |   8 +-
 style/tex-live.el                     |   8 +-
 style/url.el                          |  12 +-
 style/verbatim.el                     |   7 +-
 tests/latex/font-latex-test.el        |  44 +++++
 tests/latex/fontification-general.tex |  20 +--
 texmathp.el                           |  50 ++----
 31 files changed, 637 insertions(+), 380 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 6e599c3..1037fe0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -172,7 +172,7 @@ STYLESRC = style/prosper.el \
           style/changelog.el style/ltugboat.el  style/beamerswitch.el \
           style/multitoc.el  style/fbox.el      style/xkcdcolors.el \
           style/ltxguide.el  style/revtex4-2.el style/overpic.el \
-          style/tex-live.el
+          style/tex-live.el  style/algorithm.el style/algpseudocode.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/doc/auctex.texi b/doc/auctex.texi
index d91889c..ab69dd0 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,7 +12,7 @@ This manual is for @AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}),
 a sophisticated TeX environment for Emacs.
 
-Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2019
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2020
 Free Software Foundation, Inc.
 
 @quotation
@@ -173,6 +173,7 @@ Font Locking
 * Fontification of math::       Fontification of math constructs
 * Verbatim content::            Verbatim macros and environments
 * Faces::                       Faces used by font-latex
+* Known problems::              Known fontification problems
 
 Starting Processors, Viewers and Other Programs
 
@@ -2259,6 +2260,8 @@ fontified.
 
 @vindex font-latex-match-math-command-keywords
 @vindex font-latex-math-environments
+@vindex texmathp-tex-commands
+@vindex texmathp-tex-commands-default
 In @LaTeX{} mathematics can be indicated by a variety of different
 methods: toggles (like dollar signs), macros and environments.  Math
 constructs known by @fontlatex{} are displayed with the face
@@ -2266,7 +2269,17 @@ constructs known by @fontlatex{} are displayed with the 
face
 like @samp{\(...\)} or @samp{\[...\]} is built-in and not customizable.
 Support for other math macros and environments can be adapted by
 customizing the variables @code{font-latex-match-math-command-keywords}
-and @code{font-latex-math-environments} respectively.
+and @code{texmathp-tex-commands} respectively. It is no longer
+recommended to customize @code{font-latex-math-environments}, which
+is initialized according to @code{texmathp-tex-commands} and
+@code{texmathp-tex-commands-default} by default.
+
+To convert your customization in @code{font-latex-math-environments}
+into @code{texmathp-tex-commands}, please register your own math
+environments, together with starred variants if any, as entries of
+@code{env-on} type in @code{texmathp-tex-commands}, then clear out
+@code{font-latex-math-environments}. You have to restart Emacs for this
+new customization to take effect for fontification.
 
 In order to make math constructs more readable, @fontlatex{} displays
 subscript and superscript parts in a smaller font and raised or lowered
diff --git a/doc/changes.texi b/doc/changes.texi
index 70de34d..1c09683 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -12,6 +12,35 @@
 
 @itemize @bullet
 @item
+Math expression highlighting was improved. Highlighting for documents
+with a lot of inline math expressions @samp{$...$} won't get scrambled
+now (@samp{bug#33139}).
+
+There is small incompatibility due to this fix. When odd number of
+dollar signs are in a comment, the subsequent lines are highlighted as
+math until another @samp{$} appears. You can insert a commented dollar
+sign (@samp{%$}) at the next suitable end of line as a workaround.
+@ifclear rawfile
+@xref{Known problems}.
+@end ifclear
+
+In addition, it is no longer recommended to customize
+@code{font-latex-math-environments}. Use @code{texmathp-tex-commands}
+instead.
+@ifclear rawfile
+@xref{Fontification of math}.
+@end ifclear
+@item
+Support for highlighting and in-math state detection for AMS-LaTeX
+specific environments, such as @samp{align}, @samp{gather} and
+@samp{multline}, are refactored and put into style file
+@file{amsmath.el}. So these support are available only when
+@code{TeX-parse-self} option is enabled.
+
+Support for in-math state detection for packages mathtools, empheq and
+breqn is also moved into the respective style files, so available only
+when @code{TeX-parse-self} option is enabled.
+@item
 @AUCTeX{} tracks changes in @LaTeX{}2e 2020-02-02 release.  @AUCTeX{}
 supports the improvements to @LaTeX{} font selection mechanism (NFSS).
 New macros like @samp{\textsw} or @samp{\textulc} are added to font
diff --git a/doc/todo.texi b/doc/todo.texi
index 43a8248..ca4db2f 100644
--- a/doc/todo.texi
+++ b/doc/todo.texi
@@ -1,5 +1,5 @@
 @c This is part of the AUCTeX Manual.
-@c Copyright (C) 2004-2006, 2008, 2009, 2013-2015 Free Software
+@c Copyright (C) 2004-2006, 2008, 2009, 2013-2015, 2020 Free Software
 @c Foundation, Inc.
 @c See the file auctex.texi for copying conditions.
 @ifset rawfile
@@ -59,6 +59,19 @@ be looked up in the catalogs in sequence until they were 
identified.
 Macro cross references should also be usable for document navigation
 using RefTeX.
 
+@item Fix remove-style feature
+
+Currently @code{TeX-remove-style} implementation isn't good. It is
+common practice that major mode functions directly add macros and
+environments via @code{TeX-add-symbols} and
+@code{LaTeX-add-environments}, but those macros and environments are
+lost once @code{TeX-remove-style} runs. It is necessary to run major
+mode function, by e.g. @code{normal-mode}, again to recover them, but
+that makes no point in running @code{TeX-remove-style} itself because
+major mode function kills all buffer-local variables.
+
+As of @AUCTeX{} 12.3, @code{TeX-remove-style} is no longer used by any
+other codes.
 
 @end itemize
 
diff --git a/font-latex.el b/font-latex.el
index a707616..d7d26fa 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -849,7 +849,7 @@ Generated by `font-latex-make-user-keywords'.")))
              (0 'font-latex-warning-face t t)
              (1 'font-latex-math-face append t))
             (font-latex-match-math-envII
-             (0 'font-latex-math-face append t))
+             (1 'font-latex-math-face append t))
             (font-latex-match-simple-command
              (0 'font-latex-sedate-face append))
             (font-latex-match-script
@@ -878,7 +878,9 @@ locking machinery will be triggered."
     (dolist (elt keywords)
       (add-to-list list elt))
     (funcall (intern (format "font-latex-match-%s-make" class)))
-    (font-latex-update-font-lock)))
+    ;; Trigger refontification.
+    (when (fboundp 'font-lock-flush)
+      (font-lock-flush))))
 
 (defvar font-latex-keywords font-latex-keywords-1
   "Default expressions to highlight in TeX mode.")
@@ -1222,9 +1224,14 @@ cons pair as expected by `font-lock-defaults'.  The 
function also
 triggers Font Lock to recognize the change."
   (set (make-local-variable 'font-latex-syntax-alist)
        (append font-latex-syntax-alist list))
-  ;; Tell font-lock about the update.
-  (setq font-lock-set-defaults nil)
-  (font-latex-setup))
+  ;; We modify the `font-lock-syntax-table' directly but also call
+  ;; `font-latex-setup' in order to have `font-lock-defaults' be in sync.
+  (font-latex-setup)
+  (dolist (elt list)
+    (modify-syntax-entry (car elt) (cdr elt) font-lock-syntax-table))
+  ;; Trigger refontification.
+  (when (fboundp 'font-lock-flush)
+    (font-lock-flush)))
 
 (defun font-latex-syntax-propertize-function (start end)
   "The `syntax-propertize-function' for (La)TeX documents."
@@ -1254,6 +1261,8 @@ triggers Font Lock to recognize the change."
            nil nil ,font-latex-syntax-alist nil))
        (variables
         '((font-lock-mark-block-function . mark-paragraph)
+          (font-lock-fontify-region-function
+           . font-latex-fontify-region)
           (font-lock-unfontify-region-function
            . font-latex-unfontify-region)
            (font-lock-extend-region-functions
@@ -1262,9 +1271,7 @@ triggers Font Lock to recognize the change."
             font-latex-extend-region-backwards-command-with-args
            font-latex-extend-region-backwards-command-in-braces
            font-latex-extend-region-backwards-quotation
-           font-latex-extend-region-backwards-math-env
-           font-latex-extend-region-backwards-math-envII
-           font-latex-extend-region-backwards-dollar-math)
+           font-latex-extend-region-backwards-math)
            (syntax-propertize-function
             . font-latex-syntax-propertize-function)
            (syntax-propertize-extend-region-functions
@@ -1294,20 +1301,48 @@ triggers Font Lock to recognize the change."
   "Tell font-lock about updates of fontification rules.
 If SYNTACTIC-KWS is non-nil, also update
 `font-latex-syntactic-keywords'."
-  ;; Update syntactic keywords.
-  (when syntactic-kws
-    (font-latex-set-syntactic-keywords))
-
-  ;; Let font-lock recompute its fontification rules.
-  (setq font-lock-set-defaults nil)
-  (font-lock-set-defaults)
-
-  ;; Re-initialize prettification if needed.
-  (when (and (boundp 'prettify-symbols-mode)
-            (boundp 'prettify-symbols--keywords)
-            prettify-symbols-mode
-            prettify-symbols--keywords)
-    (font-lock-add-keywords nil prettify-symbols--keywords)))
+  (display-warning
+   'auctex
+   (concat "`font-latex-update-font-lock' should not be called.
+It is obsolete and going to be removed.
+If you have called `font-latex-add-keywords' and want to refresh fontification,
+call `font-lock-flush' instead.
+If you changed syntactic fontification, e.g., one of the variables
+- `LaTeX-verbatim-macros-with-delims'
+- `LaTeX-verbatim-macros-with-delims-local'
+- `LaTeX-verbatim-macros-with-braces'
+- `LaTeX-verbatim-macros-with-braces-local'
+- `LaTeX-verbatim-environments'
+- `LaTeX-verbatim-environments-local'
+- `font-latex-syntactic-keywords-extra'
+then call `font-latex-set-syntactic-keywords'.")))
+
+(make-obsolete 'font-latex-update-font-lock nil "12.2.4")
+
+(defvar font-latex--updated-region-end nil
+;; During hilighting of math expression, matched range sometimes exceeds
+;; the given end limit. So record the actual end in this variable to
+;; notify the font lock machinery.
+;; Match function of math expression should do the following two if
+;; the end of the actual match goes beyond the limit:
+;; 1. If the value of this variable is smaller than limit, set this
+;;    variable to that limit.
+;; 2. When the end of the actual match exceeds this variable,
+;;    - apply `font-lock-unfontify-region' between the value of this
+;;      variable and the end of the actual match
+;;    - update this variable to the end of the actual match
+;; See implementation of `font-latex-match-math-env' for actual usage.
+  "Record the end of fontification.")
+(defun font-latex-fontify-region (beg end &optional verbose)
+  "Fontify region from BEG to END.
+Take care when the actually fonfified region was extended beyond END."
+  (setq font-latex--updated-region-end end)
+  (let ((res (font-lock-default-fontify-region beg end verbose)))
+    ;; COMPATIBILITY for older emacsen. Return value for jit-lock
+    ;; is meaningful for only newer emacsen.
+    (if (eq (car-safe res) 'jit-lock-bounds)
+       `(jit-lock-bounds ,(cadr res) .
+                         ,(max (cddr res) font-latex--updated-region-end)))))
 
 ;; Copy and adaption of `tex-font-lock-unfontify-region' from
 ;; tex-mode.el in GNU Emacs on 2004-08-04.
@@ -1340,8 +1375,8 @@ modified.  Such variables include
        (or (memq 'LaTeX-verbatim-environments-local hacked-local-vars)
            (memq 'LaTeX-verbatim-macros-with-braces-local hacked-local-vars)
            (memq 'LaTeX-verbatim-macros-with-delims-local hacked-local-vars)))
-    ;; Ok, we need to refresh fontification.
-    (font-latex-update-font-lock t)))
+    ;; Ok, we need to refresh syntactic fontification.
+    (font-latex-set-syntactic-keywords)))
 
 ;;; Utility functions
 
@@ -1712,39 +1747,76 @@ Used for patterns like:
          (if (and (re-search-forward (concat "[^\\]\\(?:\\\\\\\\\\)*\\("
                                              (regexp-quote open-tag) "\\|"
                                              (regexp-quote close-tag) "\\)")
-                                     limit 'move)
+                                     (+ limit font-latex-multiline-boundary)
+                                     'move)
                   (string= (match-string 1) close-tag))
              ;; Found closing tag.
-             (store-match-data (list beg beg beg (point)))
+             (let ((p (point)))
+               (if (< font-latex--updated-region-end limit)
+                   ;; *-extend-region-functions have extended the
+                   ;; limit already.
+                   (setq font-latex--updated-region-end limit))
+               ;; If the closing tag is beyond the current end of
+               ;; region, take care of it.
+               (when (< font-latex--updated-region-end p)
+                 (font-lock-unfontify-region font-latex--updated-region-end p)
+                 (setq font-latex--updated-region-end p))
+               (store-match-data (list beg beg beg p)))
            ;; Did not find closing tag.
            (goto-char (+ beg 2))
            (store-match-data (list beg (point) (point) (point))))
          (throw 'match t))))))
 
-(defun font-latex-extend-region-backwards-math-env ()
-  "Extend region backwards for math environments."
-  (save-excursion
-    (goto-char font-lock-end)
-    (catch 'extend
-      (while (re-search-backward "\\(\\\\)\\)\\|\\(\\\\]\\)" font-lock-beg t)
-       (when (and (zerop (mod (skip-chars-backward "\\\\") 2))
-                  (re-search-backward
-                   (concat "[^\\]\\(?:\\\\\\\\\\)*\\("
-                           (regexp-quote (if (match-beginning 1) "\\(" "\\["))
-                           "\\)")
-                   (- font-lock-beg font-latex-multiline-boundary) t)
-                  (goto-char (match-beginning 1))
-                  (< (point) font-lock-beg))
-          (setq font-lock-beg (point))
-         (throw 'extend t))))))
-
-(defcustom font-latex-math-environments
-  '("display" "displaymath" "equation" "eqnarray" "gather" "math" "multline"
-    "align" "alignat" "xalignat" "xxalignat" "flalign")
-  "List of math environment names for font locking."
+(require 'texmathp)
+(defcustom font-latex-math-environments nil
+  "List of math environment names for font locking.
+It is no longer recommended to customize this option. You should
+customize `texmathp-tex-commands' instead because it is important
+for stable operation of font lock that this option is coherent
+with that option in addition to `texmathp-tex-commands-default'.
+See info node `(auctex)Fontification of math' to convert your
+customization into `texmathp-tex-commands'."
+  ;; This option is now used only through
+  ;; `font-latex--match-math-envII-regexp'.
   :type '(repeat string)
   :group 'font-latex)
 
+(defvar font-latex--match-math-envII-regexp nil
+  "Regular expression to match math environments.
+Set by `font-latex--update-math-env' and used in
+`font-latex-match-math-envII'.")
+
+(defun font-latex-update-math-env ()
+  "Update regexp to search for math environments.
+Helper function for style files such as amsmath.el.
+Extract environments marked as `env-on' in
+`texmathp-tex-commands1' except starred variants. Then build
+`font-latex--match-math-envII-regexp' from them, appending the
+environments in `font-latex-math-environments'."
+  ;; Make sure `texmathp-tex-commands1' is up to date.
+  (texmathp-compile)
+  (let (envs)
+    (dolist (entry texmathp-tex-commands1)
+      (if (and (eq 'env-on (cadr entry))
+              (not (string= "*" (substring (car entry) -1))))
+         (cl-pushnew (car entry) envs :test #'equal)))
+    (setq font-latex--match-math-envII-regexp
+         (concat "\\\\begin[ \t]*{"
+                 ;; Take user additions also into account.
+                 (regexp-opt (append font-latex-math-environments envs) t)
+                 ;; Subexpression 2 is used to build the \end{<env>}
+                 ;; construct later.
+                 "\\(\\*?}\\)"
+                 ;; Match an optional and possible mandatory
+                 ;; argument(s) as long as they are on the same line
+                 ;; with no spaces in-between. The content of optional
+                 ;; argument can span multiple lines.
+                 "\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
+                 "\\(?:{[^}]*}\\)*"))))
+
+;; Initialize.
+(font-latex-update-math-env)
+
 (defun font-latex-match-math-envII (limit)
   "Match math patterns up to LIMIT.
 Used for patterns like:
@@ -1756,85 +1828,63 @@ Used for patterns like:
 \\end{empheq}
 The \\begin{equation} incl. arguments in the same line and
 \\end{equation} are not fontified here."
-  (when (re-search-forward (concat "\\\\begin[ \t]*{"
-                                  (regexp-opt font-latex-math-environments t)
-                                  ;; Subexpression 2 is used to build
-                                  ;; the \end{<env>} construct below
-                                  "\\(\\*?}\\)"
-                                  ;; Match an optional and possible
-                                  ;; mandatory argument(s) as long as
-                                  ;; they are on the same line with
-                                  ;; no spaces in-between
-                                  
"\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
-                                  "\\(?:{[^}]*}\\)*")
-                          limit t)
-    (let ((beg (match-end 0)) end)
+  (when (re-search-forward font-latex--match-math-envII-regexp limit t)
+    (let ((beg (match-end 0)) end
+         (beg-of-begin (match-beginning 0)))
       (if (re-search-forward (concat "\\\\end[ \t]*{"
                                     (regexp-quote
                                      (buffer-substring-no-properties
                                       (match-beginning 1)
                                       (match-end 2))))
-                            ;; XXX: Should this rather be done by
-                            ;; extending the region to be fontified?
                             (+ limit font-latex-multiline-boundary) 'move)
-         (setq end (match-beginning 0))
+         (progn
+           (setq end (match-beginning 0))
+           (if (< font-latex--updated-region-end limit)
+               (setq font-latex--updated-region-end limit))
+           (when (< font-latex--updated-region-end end)
+             (font-lock-unfontify-region font-latex--updated-region-end end)
+             (setq font-latex--updated-region-end end)))
        (goto-char beg)
-       (setq end beg))
-      (store-match-data (list beg end))
+       (setq end beg
+             beg-of-begin beg))
+      ;; Store the position of "\begin{foo}" as (match-beginnig 0) so
+      ;; that `font-lock-multiline' text property covers it. This keeps
+      ;; editing inside multi-line optional argument sane.
+      (store-match-data (list beg-of-begin end beg end))
       t)))
 
-(defun font-latex-extend-region-backwards-math-envII ()
-  "Extend region backwards for math environments."
-  (save-excursion
-    (goto-char font-lock-end)
-    (catch 'extend
-      (while (re-search-backward
-             (concat "\\\\end[ \t]*{"
-                     (regexp-opt font-latex-math-environments t)
-                     "\\*?}") font-lock-beg t)
-       (when (and (re-search-backward
-                   (concat  "\\\\begin[ \t]*{"
-                            (buffer-substring-no-properties
-                             (match-beginning 1)
-                             (match-end 0))
-                            ;; Match an optional and possible
-                            ;; mandatory argument(s)
-                            "\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
-                            "\\(?:{[^}]*}\\)*")
-                   (- font-lock-beg font-latex-multiline-boundary) t)
-                  (< (point) font-lock-beg))
-          (setq font-lock-beg (point))
-         (throw 'extend t))))))
-
 (defun font-latex-match-dollar-math (limit)
   "Match inline math $...$ or display math $$...$$ before LIMIT."
-  (if (font-latex-find-dollar-math limit)
-      ;; Found "$" which starts $...$ or $$...$$.
-      (let ((beg (point))
-           ;; Go inside the math expression.
-           (num (skip-chars-forward "$" limit)))
+  (catch 'match
+    (let (beg num)
+      (while (font-latex-find-dollar-math limit)
+       ;; Found "$" which starts $...$ or $$...$$.
+       (setq beg (point)
+             ;; Go inside the math expression.
+             num (skip-chars-forward "$" limit))
+       ;; If those are three or more consecutive $, ignore them and
+       ;; search again.
        (if (< num 3)
            (if ;; Let's find the same number of live dollar signs.
-               (font-latex-find-dollar-math limit num)
+               (font-latex-find-dollar-math
+                ;; Hope that limit+font-latex-multiline-boundary
+                ;; doesn't fall just inside single "$$".
+                (+ limit font-latex-multiline-boundary) num)
                ;; Found.
                (progn
                  (forward-char num)
-                 (set-match-data (list beg (point)))
-                 t)
-             ;; Not found. It means that there was opening "$" or
-             ;; "$$", but we can't find the corresponding close tag
-             ;; until LIMIT. Then it is either
-             ;; (1) The math expression continues to the next line, or
-             ;; (2) The buffer has unclosed "$" or "$$".
-             ;; Regard the former case as a positive match because
-             ;; experiments tends to imply that's more robust despite
-             ;; of frequent false positives produced during editing.
-             ;; N.B. It is ensured that LIMIT doesn't fall just
-             ;; inside single "$$" because
-             ;; `font-lock-extend-region-functions' takes care of it.
-             (unless (eobp)
-               (set-match-data (list beg (point)))
-               t))))))
+                 (let ((p (point)))
+                   (if (< font-latex--updated-region-end limit)
+                       (setq font-latex--updated-region-end limit))
+                   (when (< font-latex--updated-region-end p)
+                     (font-lock-unfontify-region
+                      font-latex--updated-region-end p)
+                     (setq font-latex--updated-region-end p))
+                   (set-match-data (list beg p)))
+                 (throw 'match t))
+             ;; Not found.
+             ;; That $ or $$ is probably unclosed in the buffer.
+             (throw 'match nil)))))))
 
 (defun font-latex-find-dollar-math (limit &optional num)
   "Find dollar sign(s) before LIMIT.
@@ -1873,7 +1923,7 @@ signs to follow the point and must be 1 or 2."
        ;; > \includegraphics{$HOME/path/to/graphic}
        ;; > \bibliography{$HOME/path/to/bib}
        ;;
-       ;; In order to spare work around of adding "%$" at the end of
+       ;; In order to spare workaround of adding "%$" at the end of
        ;; the lines for such cases, we stay away from the next syntax
        ;; state check.
        ;; ;; check 3: Else, is "$" in comments or verb-like construct?
@@ -1883,29 +1933,26 @@ signs to follow the point and must be 1 or 2."
        ;; That "$" is live one.
        (throw 'found t))))))
 
-(require 'texmathp)
-;; FIXME: Big overhead here. We can obviously unify
-;; `font-latex-extend-region-backwards-math-env' and
-;; `font-latex-extend-region-backwards-math-envII' into
-;; this function.
-(defun font-latex-extend-region-backwards-dollar-math ()
-  "Extend region backwards for math inside $...$ or $$...$$."
-  ;; Use `texmathp' to identify whether the point is inside $...$ or
-  ;; $$...$$. Only heuristic, but it's very difficult to identify
-  ;; rigorously without syntactic support.
-
-  ;; Check if `font-lock-beg' is inside "$...$" or "$$...$$".
+(defun font-latex-extend-region-backwards-math ()
+  "Extend region backwards for math environmets.
+Take into account $...$, $$...$$, \\(...\\) and \\=\\[...\\], too."
+  ;; Use `texmathp' to identify whether the point is inside math mode.
+  ;; Only heuristic, but it's very difficult to identify rigorously
+  ;; without syntactic support.
+
+  ;; Check if `font-lock-beg' is inside math mode.
   (goto-char font-lock-beg)
 
-  ;; Work around bug#41522. Ensure `syntax-table' property is given to
-  ;; all verbatim like constructs up to the position before running
+  ;; Workaround bug#41522. Ensure `syntax-table' property is given to
+  ;; all verbatim-like constructs up to the position before running
   ;; `texmathp' in order to prevent wrong fontification of verbatim
   ;; face. This is necessary because `texmathp' calls `up-list' inside
   ;; narrowing.
   (syntax-propertize (point))
 
-  (when (and (texmathp) (< (cdr texmathp-why) font-lock-beg)
-            (member (car texmathp-why) '("$" "$$")))
+  ;; XXX: Should we make the `texmathp' search honor
+  ;; `font-latex-multiline-boundary'?
+  (when (and (texmathp) (< (cdr texmathp-why) font-lock-beg))
     ;; Make its beginning a new start of font lock region.
     (setq font-lock-beg (cdr texmathp-why))
     t))
diff --git a/latex.el b/latex.el
index 7701eb3..db0af47 100644
--- a/latex.el
+++ b/latex.el
@@ -2303,8 +2303,8 @@ OPTIONAL and IGNORE are ignored."
                    (not (y-or-n-p "Find class yourself? "))
                  TeX-arg-input-file-search)
                (prog2
-                 (message "Searching for LaTeX classes...")
-                 (TeX-search-files-by-type 'texinputs 'global t t)
+                   (message "Searching for LaTeX classes...")
+                   (TeX-search-files-by-type 'texinputs 'global t t)
                  (message "Searching for LaTeX classes...done"))
              LaTeX-style-list)))
     (setq style (completing-read
@@ -2340,11 +2340,7 @@ OPTIONAL and IGNORE are ignored."
                          (list (cons style opts)))))
     (insert TeX-grop style TeX-grcl))
 
-  ;; remove old information
-  (TeX-remove-style)
-
-  ;; defined in individual style hooks
-  (TeX-update-style)
+  (TeX-update-style t)
   (run-hooks 'TeX-after-document-hook))
 
 (defvar LaTeX-after-usepackage-hook nil
diff --git a/style/algorithm.el b/style/algorithm.el
new file mode 100644
index 0000000..8004002
--- /dev/null
+++ b/style/algorithm.el
@@ -0,0 +1,80 @@
+;;; algorithm.el --- AUCTeX style for the (LaTeX) algorithm package
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; Author: Uwe Brauer <oub@mat.ucm.es>
+;; Created: 2020-01-26
+;; Keywords: tex
+
+;; 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.
+
+;;; Commentary:
+;; This file adds support for the algorithm package.
+
+;;; Code:
+
+(defvar LaTeX-algorithm-package-options
+  '("section")
+  "Package options for the algorithm package.")
+
+
+(defun LaTeX-env-algorithm (environment)
+  "Insert a algorithm-like ENVIRONMENT with caption and label."
+  (let* ((pos (completing-read (TeX-argument-prompt t nil "Position")
+                              '(("H"))))
+        (caption (TeX-read-string "Caption: "))
+        (short-caption (when (>= (length caption) 
LaTeX-short-caption-prompt-length)
+                         (TeX-read-string "(Optional) Short caption: "))))
+    (LaTeX-insert-environment environment
+                             (concat
+                              (unless (zerop (length pos))
+                                (concat LaTeX-optop pos LaTeX-optcl))))
+    ;; top caption -- do nothing if user skips caption
+    (unless (zerop (length caption))
+      ;; insert `\caption[short-caption]{caption':
+      (insert TeX-esc "caption")
+      (when (and short-caption (not (string= short-caption "")))
+       (insert LaTeX-optop short-caption LaTeX-optcl))
+      (insert TeX-grop caption)
+      ;; ask for a label and insert it
+;      (LaTeX-label environment 'environment)
+      ;; the longtable `\caption' is equivalent to a
+      ;; `\multicolumn', so it needs a `\\' at the
+      ;; end of the line.  Prior to that, add } to
+      ;; close `\caption{'
+      (insert TeX-grcl "")
+      ;; fill the caption
+      (LaTeX-fill-paragraph)
+      ;; Insert a new line and indent
+      (LaTeX-newline)
+      (LaTeX-label environment 'environment)
+      (LaTeX-newline)
+      (indent-according-to-mode))))
+
+
+(TeX-add-style-hook
+ "algorithm"
+ (lambda ()
+   (LaTeX-add-environments
+    '("algorithm"  LaTeX-env-algorithm ))
+   (TeX-add-symbols
+    '("listofalgorithms" 0))
+      LaTeX-dialect))
+
+
+;;; algorithm.el ends here
diff --git a/style/algpseudocode.el b/style/algpseudocode.el
new file mode 100644
index 0000000..eaae318
--- /dev/null
+++ b/style/algpseudocode.el
@@ -0,0 +1,73 @@
+;;; algpseudocode.el --- AUCTeX style for the (LaTeX) algpseudocode package
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; Author: Uwe Brauer <oub@mat.ucm.es>
+;; Created: 2020-01-26
+;; Keywords: tex
+
+;; 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.
+
+;;; Commentary:
+;; This file adds support for the algpseudocode package.
+
+;;; Code:
+
+(defvar LaTeX-algpseudocode-package-options
+  '("compatible" "nocompatible")
+  "Package options for the algpseudocode package.")
+
+
+(TeX-add-style-hook
+ "algpseudocode"
+ (lambda ()
+   (TeX-add-symbols
+    '("algref" 2)
+    '("algstore" 1)
+    '("algrestore" 1)
+    '("algstore*" 1)
+    '("algrestore*" 1)
+    '("Procedure" 2)
+    '("Comment" 1)
+    '("State" 0)
+    '("While" 0)
+    '("EndWhile" 0)
+    '("EndProcedure" 0)
+    '("Repeat" 0)
+    '("Until" 0)
+    '("For" 1)
+    '("ForAll" 1)
+    '("EndFor" 0)
+    '("If" 1)
+    '("ElsIf" 1)
+    '("Else" 0)
+    '("EndIf" 0)
+    '("Function" 2)
+    '("EndFunction" 0)
+    '("Loop" 0)
+    '("EndLoop" 0)
+    '("Require" 0)
+    '("Ensure" 0)
+    '("State" 0)
+    '("Statex" 0)
+    '("Call" 0))
+   (LaTeX-add-environments
+    '("algorithmic" [ "Number" ]))
+   LaTeX-dialect))
+
+;;; algpseudocode.el ends here
diff --git a/style/alltt.el b/style/alltt.el
index 8ca0acc..c7e232d 100644
--- a/style/alltt.el
+++ b/style/alltt.el
@@ -1,6 +1,6 @@
 ;;; alltt.el --- AUCTeX style for `alltt.sty'
 
-;; Copyright (C) 2004, 2005, 2014, 2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2014, 2016, 2018, 2020 Free Software Foundation, 
Inc.
 
 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -31,9 +31,8 @@
 ;;; Code:
 
 ;; Silence the compiler:
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 (TeX-add-style-hook
  "alltt"
@@ -43,10 +42,10 @@
                '("alltt" current-indentation) t)
    (add-to-list 'LaTeX-verbatim-environments-local "alltt")
    ;; Fontification
-   (when (and (fboundp 'font-latex-update-font-lock)
+   (when (and (fboundp 'font-latex-set-syntactic-keywords)
              (eq TeX-install-font-lock 'font-latex-setup))
      ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+     (font-latex-set-syntactic-keywords)))
  LaTeX-dialect)
 
 (defvar LaTeX-alltt-package-options nil
diff --git a/style/amsmath.el b/style/amsmath.el
index 7114b51..0fd9817 100644
--- a/style/amsmath.el
+++ b/style/amsmath.el
@@ -1,6 +1,6 @@
 ;;; amsmath.el --- Style hook for the AMS-LaTeX amsmath package.
 
-;; Copyright (C) 2002, 2005-2007, 2012-2014, 2017-2019
+;; Copyright (C) 2002, 2005-2007, 2012-2014, 2017-2020
 ;;      Free Software Foundation, Inc.
 ;; FIXME: What about the copyright for <= 2001?
 
@@ -29,6 +29,30 @@
 ;; This will also load the amstext, amsbsy and amsopn style files.
 
 ;;; Code:
+(eval-when-compile (require 'cl-lib))
+
+;; Fontification
+(declare-function font-latex-add-keywords
+                 "font-latex"
+                 (keywords class))
+(declare-function font-latex-update-math-env
+                 "font-latex")
+(require 'texmathp)
+(let ((list '(("equation*"     env-on)
+             ("align"         env-on) ("align*"        env-on)
+             ("gather"        env-on) ("gather*"       env-on)
+             ("multline"      env-on) ("multline*"     env-on)
+             ("flalign"       env-on) ("flalign*"      env-on)
+             ("alignat"       env-on) ("alignat*"      env-on)
+             ("xalignat"      env-on) ("xalignat*"     env-on)
+             ("xxalignat"     env-on) ("\\boxed"       arg-on)
+             ("\\text"        arg-off) ("\\intertext"   arg-off))))
+  (dolist (entry list)
+    (cl-pushnew entry texmathp-tex-commands-default :test #'equal)))
+(texmathp-compile)
+(if (and (featurep 'font-latex)
+        (eq TeX-install-font-lock 'font-latex-setup))
+    (font-latex-update-math-env))
 
 (TeX-add-style-hook
  "amsmath"
@@ -173,7 +197,12 @@
    ;; is non-nil
    (and LaTeX-reftex-ref-style-auto-activate
        (fboundp 'reftex-ref-style-activate)
-       (reftex-ref-style-activate "AMSmath")))
+       (reftex-ref-style-activate "AMSmath"))
+
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("boxed" "{"))
+                             'math-command)))
  LaTeX-dialect)
 
 (defun LaTeX-amsmath-env-alignat (env)
diff --git a/style/beamer.el b/style/beamer.el
index 5de0d32..5323ec7 100644
--- a/style/beamer.el
+++ b/style/beamer.el
@@ -1,6 +1,6 @@
 ;;; beamer.el --- AUCTeX style for the latex-beamer class
 
-;; Copyright (C) 2003, 2004, 2005, 2008, 2013-2016, 2018 Free Software 
Foundation
+;; Copyright (C) 2003-2005, 2008, 2013-2016, 2018, 2020 Free Software 
Foundation, Inc.
 
 ;; Author: Thomas Baumann <thomas.baumann@ch.tum.de>
 ;; Created: 2003-12-20
@@ -34,10 +34,6 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
-
 (defun LaTeX-beamer-after-insert-env (env start _end)
   "Do beamer-specific stuff after the insertion of an environment."
   ;; Add `fragile' as an optional argument to the frame environment if
@@ -189,8 +185,7 @@
                                ("subtitle" "[{")
                                ("author" "[{")
                                ("date" "[{")
-                               ("frametitle" "<[{")) 'slide-title)
-     (font-latex-update-font-lock t)))
+                               ("frametitle" "<[{")) 'slide-title)))
  LaTeX-dialect)
 
 (defun TeX-arg-beamer-overlay-spec (optional &optional prompt)
diff --git a/style/breqn.el b/style/breqn.el
index 3a89860..22c45aa 100644
--- a/style/breqn.el
+++ b/style/breqn.el
@@ -49,6 +49,7 @@
 ;;; Code:
 
 (require 'latex)
+(eval-when-compile (require 'cl-lib))
 
 (defvar LaTeX-breqn-key-val-options
   '(("style" ("\\tiny" "\\scriptsize" "\\footnotesize" "\\small"
@@ -95,6 +96,21 @@ Keys offered for key=val query depend on ENV.  \"label\" and
 
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
+;; Fontification
+(declare-function font-latex-update-math-env "font-latex")
+(require 'texmathp)
+(let ((list '(("dmath"         env-on) ("dmath*"        env-on)
+             ("dseries"       env-on) ("dseries*"      env-on)
+             ("dgroup"        env-on) ("dgroup*"       env-on)
+             ("darray"        env-on) ("darray*"       env-on)
+             ("dsuspend"      env-off))))
+  (dolist (entry list)
+    (cl-pushnew entry texmathp-tex-commands-default :test #'equal)))
+(texmathp-compile)
+(if (and (featurep 'font-latex)
+        (eq TeX-install-font-lock 'font-latex-setup))
+    (font-latex-update-math-env))
+
 (TeX-add-style-hook
  "breqn"
  (lambda ()
@@ -132,19 +148,7 @@ Keys offered for key=val query depend on ENV.  \"label\" 
and
    (TeX-add-symbols
     '("condition"  [ "Punctuation mark (default ,)" ] t)
     '("condition*" [ "Punctuation mark (default ,)" ] t)
-    '("hiderel" t))
-
-   ;; Fontification
-   (when (and (featurep 'font-latex)
-             (eq TeX-install-font-lock 'font-latex-setup)
-             (boundp 'font-latex-math-environments))
-     (make-local-variable 'font-latex-math-environments)
-     (let ((envs '(;; Do not insert the starred versions here;
-                  ;; function `font-latex-match-math-envII' takes
-                  ;; care of it
-                  "dmath" "dseries" "dgroup" "darray")))
-       (dolist (env envs)
-        (add-to-list 'font-latex-math-environments env t)))))
+    '("hiderel" t)))
  LaTeX-dialect)
 
 (defvar LaTeX-breqn-package-options nil
diff --git a/style/comment.el b/style/comment.el
index 8d2bc7d..dcac6e1 100644
--- a/style/comment.el
+++ b/style/comment.el
@@ -1,6 +1,6 @@
 ;;; comment.el --- AUCTeX style for `comment.sty'
 
-;; Copyright (C) 2007, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2018, 2020 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
@@ -35,9 +35,8 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 (defvar font-latex-syntactic-keywords-extra)
 
@@ -55,7 +54,6 @@
    (mapc 'LaTeX-add-environments LaTeX-comment-env-list)
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      ;; For syntactic fontification.
      (add-to-list 'font-latex-syntactic-keywords-extra
@@ -74,7 +72,7 @@
                                ("processcomment" "{{{{"))
                              'variable)
      ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+     (font-latex-set-syntactic-keywords)))
  LaTeX-dialect)
 
 ;;; comment.el ends here
diff --git a/style/empheq.el b/style/empheq.el
index e01d04c..9add6c4 100644
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -1,6 +1,6 @@
 ;;; empheq.el --- AUCTeX style for `empheq.sty' (v2.14)
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2020 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -41,12 +41,13 @@
 (declare-function font-latex-add-keywords
                  "font-latex"
                  (keywords class))
+(declare-function font-latex-update-math-env
+                 "font-latex")
 
 (declare-function LaTeX-item-equation-alignat
                  "amsmath" (&optional suppress))
 
 (defvar LaTeX-mathtools-package-options)
-(defvar font-latex-math-environments)
 
 (defvar LaTeX-empheq-key-val-options
   `(("box")
@@ -275,6 +276,24 @@ number of ampersands if possible."
       (save-excursion
        (insert (make-string (+ ncols ncols -1) ?&))))))
 
+;; Fontification
+(require 'texmathp)
+(let ((list '(("empheq"        env-on)
+             ;; XXX: Should we add the remaining entries only when
+             ;; "overload" or "overload2" option is given?
+             ("AmSequation"   env-on) ("AmSequation*"  env-on)
+             ("AmSalign"      env-on) ("AmSalign*"     env-on)
+             ("AmSgather"     env-on) ("AmSgather*"    env-on)
+             ("AmSmultline"   env-on) ("AmSmultline*"  env-on)
+             ("AmSflalign"    env-on) ("AmSflalign*"   env-on)
+             ("AmSalignat"    env-on) ("AmSalignat*"   env-on))))
+  (dolist (entry list)
+    (cl-pushnew entry texmathp-tex-commands-default :test #'equal)))
+(texmathp-compile)
+(if (and (featurep 'font-latex)
+        (eq TeX-install-font-lock 'font-latex-setup))
+    (font-latex-update-math-env))
+
 (TeX-add-style-hook
  "empheq"
  (lambda ()
@@ -489,23 +508,7 @@ number of ampersands if possible."
      (font-latex-add-keywords '(("empheqset"             "{")
                                ("DeclareLeftDelimiter"  "[{")
                                ("DeclareRightDelimiter" "[{"))
-                             'function)
-     ;; Append our addition so that we don't interfere with user customizations
-     (make-local-variable 'font-latex-math-environments)
-     (add-to-list 'font-latex-math-environments "empheq" t)
-     (when (or (LaTeX-provided-package-options-member "empheq" "overload")
-              (LaTeX-provided-package-options-member "empheq" "overload2"))
-       (let ((envs '(;; Do not insert the starred versions here;
-                    ;; function `font-latex-match-math-envII' takes
-                    ;; care of it
-                    "AmSalign"
-                    "AmSalignat"
-                    "AmSequation"
-                    "AmSflalign"
-                    "AmSgather"
-                    "AmSmultline")))
-        (dolist (env envs)
-          (add-to-list 'font-latex-math-environments env t))))))
+                             'function)))
  LaTeX-dialect)
 
 ;;; empheq.el ends here
diff --git a/style/expl3.el b/style/expl3.el
index 1ee605e..18b1f28 100644
--- a/style/expl3.el
+++ b/style/expl3.el
@@ -1,6 +1,6 @@
 ;;; expl3.el --- AUCTeX style for `expl3.sty'
 
-;; Copyright (C) 2015, 2017-2019 Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2017-2020 Free Software Foundation, Inc.
 
 ;; Author: Tassilo Horn <tsdh@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -30,11 +30,6 @@
 
 ;;; Code:
 
-;; Silence the compiler:
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
-
 (defvar font-latex-match-simple-include-list)
 
 (defvar LaTeX-expl3-syntax-table
@@ -48,13 +43,10 @@
  "expl3"
  (lambda ()
    (set-syntax-table LaTeX-expl3-syntax-table)
-   (when (and (fboundp 'font-latex-update-font-lock)
-             (eq TeX-install-font-lock 'font-latex-setup))
+   (when (and (eq TeX-install-font-lock 'font-latex-setup))
      ;; Fontify _ and : as part of macros.
      (add-to-list 'font-latex-match-simple-include-list "_" t)
-     (add-to-list 'font-latex-match-simple-include-list ":" t)
-     ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+     (add-to-list 'font-latex-match-simple-include-list ":" t)))
  LaTeX-dialect)
 
 (defun LaTeX-expl3-package-options ()
diff --git a/style/fancyhdr.el b/style/fancyhdr.el
index 3e81e3a..46253e2 100644
--- a/style/fancyhdr.el
+++ b/style/fancyhdr.el
@@ -1,6 +1,6 @@
 ;;; fancyhdr.el --- AUCTeX style for `fancyhdr.sty'
 
-;; Copyright (C) 2012, 2013, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012, 2013, 2018, 2020 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <mje@inducks.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -34,10 +34,6 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
-
 (TeX-add-style-hook
  "fancyhdr"
  (lambda ()
@@ -73,7 +69,6 @@
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("fancyhead" "[{")
                                 ("fancyfoot" "[{")
@@ -89,9 +84,7 @@
      (font-latex-add-keywords '(("headrulewidth" "")
                                 ("footrulewidth" "")
                                 ("plainheadrulewidth" "")
-                                ("plainfootrulewidth" "")) 'variable)
-     ;; Tell font-lock about the update.
-     (font-latex-update-font-lock)))
+                                ("plainfootrulewidth" "")) 'variable)))
  LaTeX-dialect)
 
 ;; Because there can be many positions, `TeX-completing-read-multiple' is used
diff --git a/style/fancyvrb.el b/style/fancyvrb.el
index 1354e3b..ee046b7 100644
--- a/style/fancyvrb.el
+++ b/style/fancyvrb.el
@@ -1,6 +1,6 @@
 ;;; fancyvrb.el --- AUCTeX style for `fancyvrb.sty' version 3.0.
 
-;; Copyright (C) 2013, 2014, 2016--2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2016-2018, 2020 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano <mose@gnu.org>
@@ -52,9 +52,8 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 (defvar LaTeX-fancyvrb-key-val-options
   `(("commentchar" ("none"))
@@ -247,7 +246,7 @@ RECUSTOM is non-nil, delete macros from the variable
                [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
                LaTeX-fancyvrb-arg-file-relative))
             (when (and (fboundp 'font-latex-add-keywords)
-                       (fboundp 'font-latex-update-font-lock))
+                       (eq TeX-install-font-lock 'font-latex-setup))
               (font-latex-add-keywords `((,mac-name "[{"))
                                        'reference)))
            ;; New macros for saving verbatim text:
@@ -263,7 +262,7 @@ RECUSTOM is non-nil, delete macros from the variable
                     (format "%s" name))))
                TeX-arg-verb))
             (when (and (fboundp 'font-latex-add-keywords)
-                       (fboundp 'font-latex-update-font-lock))
+                       (eq TeX-install-font-lock 'font-latex-setup))
               (font-latex-add-keywords `((,mac-name "[{"))
                                        'textual)))
            ;; New macros for using previously saved text:
@@ -275,7 +274,7 @@ RECUSTOM is non-nil, delete macros from the variable
                 (TeX-argument-prompt optional nil "Saved name")
                 (LaTeX-fancyvrb-saveverb-list))))
             (when (and (fboundp 'font-latex-add-keywords)
-                       (fboundp 'font-latex-update-font-lock))
+                       (eq TeX-install-font-lock 'font-latex-setup))
               (font-latex-add-keywords `((,mac-name "{"))
                                        'textual)))
            ;; Anything else is considered as verbatim typesetting macro:
@@ -294,14 +293,13 @@ RECUSTOM is non-nil, delete macros from the variable
             (add-to-list 'LaTeX-verbatim-macros-with-delims-local
                          (concat mac-name "*") t)
             (when (and (fboundp 'font-latex-add-keywords)
-                       (fboundp 'font-latex-update-font-lock))
+                       (eq TeX-install-font-lock 'font-latex-setup))
               (font-latex-add-keywords `((,mac-name "*["))
                                        'textual))))))
   ;; Update font-lock:
-  (when (and (fboundp 'font-latex-add-keywords)
-            (fboundp 'font-latex-update-font-lock)
+  (when (and (fboundp 'font-latex-set-syntactic-keywords)
             (eq TeX-install-font-lock 'font-latex-setup))
-    (font-latex-update-font-lock t)))
+    (font-latex-set-syntactic-keywords)))
 
 (defun LaTeX-fancyvrb-arg-define-environment (optional &optional cleanup)
   "Query and insert a new verbatim environment with fancyvrb package.
@@ -368,10 +366,9 @@ update only various AUCTeX variables for verbatim 
environments."
       (add-to-list 'LaTeX-verbatim-environments-local env)
       (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation) 
t)))
   ;; Update font-lock:
-  (when (and (fboundp 'font-latex-add-keywords)
-            (fboundp 'font-latex-update-font-lock)
+  (when (and (fboundp 'font-latex-set-syntactic-keywords)
             (eq TeX-install-font-lock 'font-latex-setup))
-    (font-latex-update-font-lock t)))
+    (font-latex-set-syntactic-keywords)))
 
 (defun LaTeX-fancyvrb-arg-file-relative (optional)
   "Query and insert a file name relative to current master file.
@@ -530,7 +527,6 @@ If OPTIONAL is non-nil, insert the file name in brackets."
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("CustomVerbatimCommand"       "|{\\{{")
                                ("RecustomVerbatimCommand"     "|{\\{{")
@@ -550,9 +546,7 @@ If OPTIONAL is non-nil, insert the file name in brackets."
                                ("UseVerbatim"  "{")
                                ("LUseVerbatim" "{")
                                ("BUseVerbatim" "{"))
-                             'textual)
-     ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+                             'textual)))
  LaTeX-dialect)
 
 (defvar LaTeX-fancyvrb-package-options nil
diff --git a/style/fvextra.el b/style/fvextra.el
index 4e817ee..77b7d90 100644
--- a/style/fvextra.el
+++ b/style/fvextra.el
@@ -40,10 +40,6 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
-
 (declare-function LaTeX-color-definecolor-list "color" ())
 (declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
 
@@ -186,13 +182,11 @@
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("fvinlineset" "{"))
                              'function)
      (font-latex-add-keywords '(("EscVerb"     "*["))
-                             'textual)
-     (font-latex-update-font-lock t)) )
+                             'textual)))
  LaTeX-dialect)
 
 (defvar LaTeX-fvextra-package-options nil
diff --git a/style/hyperref.el b/style/hyperref.el
index 3b25491..e412120 100644
--- a/style/hyperref.el
+++ b/style/hyperref.el
@@ -1,6 +1,6 @@
 ;;; hyperref.el --- AUCTeX style for `hyperref.sty' v6.83m
 
-;; Copyright (C) 2008, 2013--2019 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2013-2020 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
@@ -35,9 +35,8 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 (defvar LaTeX-hyperref-package-options-list
   '(;; See https://www.tug.org/applications/hyperref/manual.html#x1-40003
@@ -316,7 +315,7 @@
      (font-latex-add-keywords '(("hypersetup" "{"))
                              'function)
      ;; For syntactic fontification, e.g. verbatim constructs.
-     (font-latex-update-font-lock t))
+     (font-latex-set-syntactic-keywords))
 
    ;; Option management
    (if (and (LaTeX-provided-package-options-member "hyperref" "dvipdfmx")
diff --git a/style/listings.el b/style/listings.el
index dffbf30..f4ae693 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -1,6 +1,6 @@
 ;;; listings.el --- AUCTeX style for `listings.sty'
 
-;; Copyright (C) 2004, 2005, 2009, 2013--2019 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2009, 2013-2020 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -55,9 +55,8 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 ;; The following are options taken from chapter 4 of the listings
 ;; manual (2007/02/22 Version 1.4).
@@ -337,10 +336,9 @@ with user-defined values via the \"lstdefinestyle\" macro."
                 (regexp "[Ll]isting")))))
       ;; Fontification
       (when (and (fboundp 'font-latex-add-keywords)
-                (fboundp 'font-latex-update-font-lock)
                 (eq TeX-install-font-lock 'font-latex-setup))
        ;; Tell font-lock about the update.
-       (font-latex-update-font-lock t))
+       (font-latex-set-syntactic-keywords))
       ;; Add new env's to `ispell-tex-skip-alist': skip the entire env
       (TeX-ispell-skip-setcdr `(,(cons env (concat "\\\\end{" env "}"))))))
   (when (LaTeX-listings-lstdefinestyle-list)
@@ -451,7 +449,6 @@ caption key is found, an error is issued."
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("lstnewenvironment" "{[[{{")) 'function)
      (font-latex-add-keywords '(("lstinputlisting" "[{")) 'reference)
@@ -461,9 +458,7 @@ caption key is found, an error is issued."
      (font-latex-add-keywords '(("lstalias" "{{")
                                ("lstdefinestyle" "{{")
                                ("lstset" "{"))
-                             'variable)
-     ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+                             'variable)))
  LaTeX-dialect)
 
 (defvar LaTeX-listings-package-options '("draft" "final" "savemem"
diff --git a/style/ltxguide.el b/style/ltxguide.el
index 437e2be..8145f6e 100644
--- a/style/ltxguide.el
+++ b/style/ltxguide.el
@@ -35,6 +35,7 @@
 (declare-function font-latex-add-keywords
                  "font-latex"
                  (keywords class))
+
 (defvar LaTeX-article-class-options)
 
 (defun LaTeX-item-ltxguide-decl ()
@@ -100,8 +101,7 @@ For decl environment provided by ltxguide.cls."
 
    ;; Fontification
    (when (and (featurep 'font-latex)
-             (eq TeX-install-font-lock 'font-latex-setup)
-             (fboundp 'font-latex-update-font-lock))
+             (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("m"              "{")
                                ("arg"            "{")
                                ("oarg"           "{")
@@ -109,9 +109,7 @@ For decl environment provided by ltxguide.cls."
                                ("NEWdescription" "{"))
                              'textual)
      (font-latex-add-keywords '(("URL" ""))
-                             'reference)
-     ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+                             'reference)))
  LaTeX-dialect)
 
 (defvar LaTeX-ltxguide-class-options
diff --git a/style/mathtools.el b/style/mathtools.el
index 83bef3e..5695f11 100644
--- a/style/mathtools.el
+++ b/style/mathtools.el
@@ -1,6 +1,6 @@
 ;;; mathtools.el --- Style hook for the LaTeX package `mathtools'.
 
-;; Copyright (C) 2011-2012, 2014, 2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2020 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <mje@inducks.org>
 ;; Created: 2011-02-13
@@ -39,6 +39,8 @@
 ;; Needed for auto-parsing:
 (require 'tex)
 
+(eval-when-compile (require 'cl-lib))
+
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
                  "font-latex"
@@ -235,6 +237,12 @@ Put line break macro on the last line.  Next, insert an 
ampersand."
   (save-excursion
     (insert ?&)))
 
+;; Fontification
+(require 'texmathp)
+(cl-pushnew '("\\shortintertext" arg-off)
+           texmathp-tex-commands-default :test #'equal)
+(texmathp-compile)
+
 (TeX-add-style-hook
  "mathtools"
  (lambda ()
diff --git a/style/minted.el b/style/minted.el
index 55cdfa3..ad849e7 100644
--- a/style/minted.el
+++ b/style/minted.el
@@ -1,6 +1,6 @@
 ;;; minted.el --- AUCTeX style for `minted.sty' (v2.5)
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2018, 2020 Free Software Foundation, Inc.
 
 ;; Author: Tassilo Horn <tsdh@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -37,9 +37,8 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 (declare-function LaTeX-color-definecolor-list "color" ())
 (declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
@@ -294,7 +293,6 @@ are loaded."
                           TeX-arg-verb))
       (add-to-list 'LaTeX-verbatim-macros-with-delims-local lang)
       (when (and (fboundp 'font-latex-add-keywords)
-                (fboundp 'font-latex-update-font-lock)
                 (eq TeX-install-font-lock 'font-latex-setup))
        (font-latex-add-keywords `((,lang "[")) 'textual))))
   ;; \newmintinline{foo}{opts} => \fooinline[key=vals]|code| or
@@ -307,11 +305,10 @@ are loaded."
                  (concat (cadr name-lang) "inline"))))
       (add-to-list 'TeX-auto-symbol
                   `(,lang [ TeX-arg-key-val LaTeX-minted-key-val-options-local 
]
-                         TeX-arg-verb-delim-or-brace))
+                          TeX-arg-verb-delim-or-brace))
       (add-to-list 'LaTeX-verbatim-macros-with-delims-local lang)
       (add-to-list 'LaTeX-verbatim-macros-with-braces-local lang)
       (when (and (fboundp 'font-latex-add-keywords)
-                (fboundp 'font-latex-update-font-lock)
                 (eq TeX-install-font-lock 'font-latex-setup))
        (font-latex-add-keywords `((,lang "[")) 'textual))))
   ;; \newmintedfile{foo}{opts} => \foofile[key=vals]{file-name}
@@ -323,10 +320,10 @@ are loaded."
       (add-to-list 'TeX-auto-symbol
                   `(,lang [ TeX-arg-key-val LaTeX-minted-key-val-options-local 
]
                           TeX-arg-file))))
-  (when (and (fboundp 'font-latex-update-font-lock)
+  (when (and (fboundp 'font-latex-set-syntactic-keywords)
             (eq TeX-install-font-lock 'font-latex-setup))
     ;; Refresh font-locking so that the verbatim envs take effect.
-    (font-latex-update-font-lock t))
+    (font-latex-set-syntactic-keywords))
   ;; Also update the key=vals
   (LaTeX-minted-update-key-vals))
 
@@ -452,7 +449,6 @@ a list of strings."
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("usemintedstyle"  "[{")
                                ("setminted"       "[{")
@@ -475,7 +471,7 @@ a list of strings."
      (LaTeX-minted-add-syntactic-keywords-extra 'delim
                                                '("mint" "mintinline"))
      ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+     (font-latex-set-syntactic-keywords)))
  LaTeX-dialect)
 
 (defvar LaTeX-minted-package-options '("chapter"     "cache"
diff --git a/style/pythontex.el b/style/pythontex.el
index 6aecb93..206c32d 100644
--- a/style/pythontex.el
+++ b/style/pythontex.el
@@ -1,6 +1,6 @@
 ;;; pythontex.el --- AUCTeX style for `pythontex.sty' (v0.16)
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018, 2020 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -41,9 +41,8 @@
 (declare-function font-latex-add-keywords
                  "font-latex"
                  (keywords class))
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 ;; The next two are provided by `newfloat.el':
 (declare-function LaTeX-add-newfloat-DeclareFloatingEnvironments
@@ -193,13 +192,13 @@ a list of strings."
                     ;; font-latex.el:
                     (if (eq type 'brace)
                         (concat "\\({\\)"
-                                  "\\(?:[^}{]*"
-                                    "\\(?:{[^}{]*"
-                                      "\\(?:{[^}{]*"
-                                        "\\(?:{[^}{]*}[^}{]*\\)*"
-                                      "}[^}{]*\\)*"
-                                    "}[^}{]*\\)*"
-                                  "\\)"
+                                "\\(?:[^}{]*"
+                                "\\(?:{[^}{]*"
+                                "\\(?:{[^}{]*"
+                                "\\(?:{[^}{]*}[^}{]*\\)*"
+                                "}[^}{]*\\)*"
+                                "}[^}{]*\\)*"
+                                "\\)"
                                 "\\(}\\)")
                       (concat
                        ;; Opening delimiter
@@ -259,7 +258,7 @@ a list of strings."
                    `(,env current-indentation) t))
      ;; Fontification
      (when (and (fboundp 'font-latex-add-keywords)
-               (fboundp 'font-latex-update-font-lock)
+               (fboundp 'font-latex-set-syntactic-keywords)
                (boundp 'font-latex-syntactic-keywords-extra)
                (eq TeX-install-font-lock 'font-latex-setup))
        (font-latex-add-keywords (mapcar (lambda (mac)
@@ -288,15 +287,15 @@ a list of strings."
                               "\\)}")
                      (1 "|" t))))
      ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t))
+     (font-latex-set-syntactic-keywords))
 
    (TeX-add-symbols
     ;; 4.2.5 Custom code
     ;; pythontexcustomc[<position>]{<family>}{<code>}
     '("pythontexcustomc"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Position")
-                    '("begin" "end") ]
+       (TeX-argument-prompt optional nil "Position")
+       '("begin" "end") ]
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Family")
                    LaTeX-pythontex-family-list)
@@ -306,15 +305,15 @@ a list of strings."
     ;; \setpythontexfv[<family>]{<fancyvrb settings>}
     '("setpythontexfv"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Family")
-                    LaTeX-pythontex-family-list ]
+       (TeX-argument-prompt optional nil "Family")
+       LaTeX-pythontex-family-list ]
       (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
 
     ;; \setpythontexprettyprinter[<family>]{<printer>}
     '("setpythontexprettyprinter"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Family")
-                    (cons "auto" LaTeX-pythontex-family-list) ]
+       (TeX-argument-prompt optional nil "Family")
+       (cons "auto" LaTeX-pythontex-family-list) ]
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Printer")
                    '("text" "bw" "fancyvrb" "pygments")))
@@ -322,8 +321,8 @@ a list of strings."
     ;; \setpythontexpyglexer[<family>]{<pygments lexer>}
     '("setpythontexpyglexer"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Family")
-                    LaTeX-pythontex-family-list ]
+       (TeX-argument-prompt optional nil "Family")
+       LaTeX-pythontex-family-list ]
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Pygments lexer")
                    (LaTeX-pythontex-language-list)))
@@ -331,8 +330,8 @@ a list of strings."
     ;; \setpythontexpygopt[<family>]{<pygments options>}
     '("setpythontexpygopt"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Family")
-                    LaTeX-pythontex-family-list ]
+       (TeX-argument-prompt optional nil "Family")
+       LaTeX-pythontex-family-list ]
       (TeX-arg-key-val
        (("style") ("texcomments") ("mathescape"))))
 
@@ -340,15 +339,15 @@ a list of strings."
     ;; \printpythontex[<mode>][<options>]
     '("printpythontex"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Mode")
-                    '("raw" "verb" "verbatim") ]
+       (TeX-argument-prompt optional nil "Mode")
+       '("raw" "verb" "verbatim") ]
       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] )
 
     ;; \stdoutpythontex[<mode>][<options>]
     '("stdoutpythontex"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Mode")
-                    '("raw" "verb" "verbatim") ]
+       (TeX-argument-prompt optional nil "Mode")
+       '("raw" "verb" "verbatim") ]
       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] )
 
     ;;\saveprintpythontex{<name>}
@@ -371,8 +370,8 @@ a list of strings."
     ;; I assume <verbatim options> is meant to be <mode>
     '("useprintpythontex"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Mode")
-                    '("raw" "verb" "verbatim") ]
+       (TeX-argument-prompt optional nil "Mode")
+       '("raw" "verb" "verbatim") ]
       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Name")
@@ -382,8 +381,8 @@ a list of strings."
     ;; I assume <verbatim options> is meant to be <mode>
     '("usestdoutpythontex"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Mode")
-                    '("raw" "verb" "verbatim") ]
+       (TeX-argument-prompt optional nil "Mode")
+       '("raw" "verb" "verbatim") ]
       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Name")
@@ -392,8 +391,8 @@ a list of strings."
     ;; \stderrpythontex[<mode>][<fancyvrb options>]
     '("stderrpythontex"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Mode")
-                    '("raw" "verb" "verbatim") ]
+       (TeX-argument-prompt optional nil "Mode")
+       '("raw" "verb" "verbatim") ]
       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] )
 
 
@@ -408,8 +407,8 @@ a list of strings."
     ;; \usestderrpythontex[<mode>][<fancyvrb options>]{<name>}
     '("usestderrpythontex"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Mode")
-                    '("raw" "verb" "verbatim") ]
+       (TeX-argument-prompt optional nil "Mode")
+       '("raw" "verb" "verbatim") ]
       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Name")
@@ -446,15 +445,15 @@ a list of strings."
     ;; \setpygmentsfv[<lexer>]{<fancyvrb settings>}
     '("setpygmentsfv"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Lexer")
-                    (LaTeX-pythontex-language-list) ]
+       (TeX-argument-prompt optional nil "Lexer")
+       (LaTeX-pythontex-language-list) ]
       (TeX-arg-eval LaTeX-fancyvrb-key-val-options-local))
 
     ;; \setpygmentspygopt[<lexer>]{<pygments options>}
     '("setpygmentspygopt"
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Lexer")
-                    (LaTeX-pythontex-language-list) ]
+       (TeX-argument-prompt optional nil "Lexer")
+       (LaTeX-pythontex-language-list) ]
       (TeX-arg-key-val
        (("style") ("texcomments") ("mathescape"))))
 
@@ -504,8 +503,8 @@ a list of strings."
     ;; 4.2.5 Custom code
     '("pythontexcustomcode" LaTeX-env-args
       [ TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Position")
-                    '("begin" "end") ]
+       (TeX-argument-prompt optional nil "Position")
+       '("begin" "end") ]
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Family")
                    LaTeX-pythontex-family-list))
@@ -527,7 +526,6 @@ a list of strings."
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("pythontexcustomc"         "[{{")
                                ("setpythontexfv"           "[{")
@@ -564,7 +562,7 @@ a list of strings."
      (LaTeX-pythontex-add-syntactic-keywords-extra 'brace "pygment")
      (LaTeX-pythontex-add-syntactic-keywords-extra 'delim "pygment")
      ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+     (font-latex-set-syntactic-keywords)))
  LaTeX-dialect)
 
 ;;; pythontex.el ends here
diff --git a/style/revtex4-2.el b/style/revtex4-2.el
index 2c9a524..dd516b1 100644
--- a/style/revtex4-2.el
+++ b/style/revtex4-2.el
@@ -186,8 +186,7 @@ provided by REVTeX class."
 
    ;; Fontification
    (when (and (featurep 'font-latex)
-             (eq TeX-install-font-lock 'font-latex-setup)
-             (fboundp 'font-latex-update-font-lock))
+             (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("fbox"          "*[{")
                                ("keywords"      "{")
                                ("preprint"      "")
@@ -209,10 +208,7 @@ provided by REVTeX class."
                                ("setfloatlink" ""))
                              'reference)
      (font-latex-add-keywords '(("appendix*" ""))
-                             'warning)
-
-     ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+                             'warning)))
  LaTeX-dialect)
 
 (defvar LaTeX-revtex4-2-class-options
diff --git a/style/tex-live.el b/style/tex-live.el
index 6b059cf..0750d91 100644
--- a/style/tex-live.el
+++ b/style/tex-live.el
@@ -42,10 +42,6 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
-
 (TeX-add-style-hook
  "tex-live"
  (lambda ()
@@ -169,9 +165,7 @@
      (font-latex-add-keywords '(("var" "{") )
                              'italic-command)
      (font-latex-add-keywords '(("Ucom" "{"))
-                             'bold-command)
-     ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+                             'bold-command)))
  LaTeX-dialect)
 
 ;;; tex-live.el ends here
diff --git a/style/url.el b/style/url.el
index 1f856af..740d2d7 100644
--- a/style/url.el
+++ b/style/url.el
@@ -1,6 +1,6 @@
 ;;; url.el --- AUCTeX style for `url.sty'
 
-;; Copyright (C) 2004, 2005, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2005, 2018, 2020 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -35,9 +35,8 @@
                  "font-latex"
                  (keywords class))
 
-(declare-function font-latex-update-font-lock
-                 "font-latex"
-                 (&optional syntactic-kws))
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
 
 (TeX-add-style-hook
  "url"
@@ -60,7 +59,7 @@
     ;; braces.  We check here if hyperref is loaded:
     '("url" (TeX-arg-conditional (member "hyperref" (TeX-style-list))
                                 ("Url")
-                              ((TeX-arg-verb-delim-or-brace "Url"))))
+                                ((TeX-arg-verb-delim-or-brace "Url"))))
     "urldef"
     '("urlstyle" TeX-arg-urlstyle))
 
@@ -75,7 +74,6 @@
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("path" "") ("url" "")) 'reference)
      (font-latex-add-keywords '(("Url" "")
@@ -93,7 +91,7 @@
                                ("urlstyle" "{"))
                              'variable)
      ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+     (font-latex-set-syntactic-keywords)))
  LaTeX-dialect)
 
 (defun TeX-arg-urlstyle (optional &optional prompt)
diff --git a/style/verbatim.el b/style/verbatim.el
index 10fae74..d4cb5fe 100644
--- a/style/verbatim.el
+++ b/style/verbatim.el
@@ -29,6 +29,10 @@
 
 ;;; Code
 
+;; Silence the compiler:
+(declare-function font-latex-set-syntactic-keywords
+                 "font-latex")
+
 (TeX-add-style-hook
  "verbatim"
  (lambda ()
@@ -40,7 +44,6 @@
    ;; Fontification:
    ;; Code taken from `comment.el'
    (when (and (boundp 'font-latex-syntactic-keywords-extra)
-             (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
      ;; For syntactic fontification.
      (add-to-list 'font-latex-syntactic-keywords-extra
@@ -50,7 +53,7 @@
                  '("^[ \t]*\\(\\\\\\)end *{comment}"
                    (1 "!" t)))
      ;; Tell font-lock about the update.
-     (font-latex-update-font-lock t)))
+     (font-latex-set-syntactic-keywords)))
  LaTeX-dialect)
 
 (defvar LaTeX-verbatim-package-options nil
diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
new file mode 100644
index 0000000..c45a7b5
--- /dev/null
+++ b/tests/latex/font-latex-test.el
@@ -0,0 +1,44 @@
+;;; font-latex-test.el --- tests for font-latex
+
+;; 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 'font-latex)
+
+(ert-deftest font-latex-three-dollars ()
+  "Test three consecutive dollar is ignored."
+  ;; When the function `font-latex-match-dollar-math' encounters three
+  ;; or more consecutive dollar signs which have no special meaning,
+  ;; it should not stop there and return nil, but instead should
+  ;; ignore them and search another occurence of $. That is the
+  ;; behavior expected for MATCHER function of `font-lock-keywords'.
+  (should (let ((TeX-install-font-lock 'font-latex-setup))
+           (with-temp-buffer
+             (insert "% $$$ $$$
+$a$")
+             (LaTeX-mode)
+             (goto-char (point-min))
+             (setq font-latex--updated-region-end (point-max))
+             (font-latex-match-dollar-math (point-max))))))
+
+;;; font-latex-test.el ends here
diff --git a/tests/latex/fontification-general.tex 
b/tests/latex/fontification-general.tex
index 4866e4f..c864cd1 100644
--- a/tests/latex/fontification-general.tex
+++ b/tests/latex/fontification-general.tex
@@ -194,11 +194,11 @@ a bug report \#26630 for this issue: {\bfseries Text 
before, $(a+b)^2$
   is equal to \(a^2+2ab+b^2\)!}  First math expression is fontified
 with
 \begin{quote}
-\verb|(font-latex-math-face font-latex-bold-face)|
+  \verb|(font-latex-math-face font-latex-bold-face)|
 \end{quote}
 while the second with
 \begin{quote}
-\verb|(font-latex-bold-face font-latex-math-face)|
+  \verb|(font-latex-bold-face font-latex-math-face)|
 \end{quote}
 
 \part{Environments}
@@ -223,32 +223,32 @@ AUC\TeX{} fontifies the entire math content with
 should not be fontified.  Spaces or line breaks are used in order to
 distinguish argument from math content, i.e.
 \begin{quote}
-\verb|\begin{<mathenv>}[<opt-arg>]{<mand-arg>}|
+  \verb|\begin{<mathenv>}[<opt-arg>]{<mand-arg>}|
 \end{quote}
 will be fontified differently than
 \begin{quote}
-\verb|\begin{<mathenv>}[<opt-arg>] {<math-content>}|
+  \verb|\begin{<mathenv>}[<opt-arg>] {<math-content>}|
 \end{quote}
 or
 \begin{quote}
-\verb|\begin{<mathenv>} [<math-content>]{<math-content>}|
+  \verb|\begin{<mathenv>} [<math-content>]{<math-content>}|
 \end{quote}
 
-The relevant functions is \verb|font-latex.el| are
+The relevant functions in \verb|font-latex.el| are
 \begin{quote}
-\verb|font-latex-match-math-envII|\quad and \\
-\verb|font-latex-extend-region-backwards-math-envII|
+  \verb|font-latex-match-math-envII|\quad and \\
+  \verb|font-latex-extend-region-backwards-math|
 \end{quote}
 
 \subsubsection{Standard \protect\LaTeX{}}
 
 Examples taken from \cite{voss16}.
 \begin{equation}
-f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
+  f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
 \end{equation}
 or
 \begin{displaymath}
-f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
+  f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)
 \end{displaymath}
 or
 \[ f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right) \]
diff --git a/texmathp.el b/texmathp.el
index 3beac2e..326caad 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -1,6 +1,6 @@
 ;;; texmathp.el -- Code to check if point is inside LaTeX math environment
 
-;; Copyright (C) 1998, 2004, 2017 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2004, 2017, 2020 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
 ;; Maintainer: auctex-devel@gnu.org
@@ -51,11 +51,12 @@
 ;;  specifying which command at what position is responsible for math
 ;;  mode being on or off.
 ;;
-;;  To configure which macros and environments influence LaTeX math mode,
-;;  customize the variable `texmathp-tex-commands'.  By default
-;;  it recognizes the plain TeX and LaTeX core as well as AMS-LaTeX and
-;;  packages mathtools, empheq and breqn (see the variable
-;;  `texmathp-tex-commands-default', also as an example).
+;;  To configure which macros and environments influence LaTeX math
+;;  mode, customize the variable `texmathp-tex-commands'. By default
+;;  it recognizes the plain TeX and LaTeX core (see the variable
+;;  `texmathp-tex-commands-default', also as an example). Support for
+;;  AMS-LaTeX and packages mathtools, empheq and breqn is added as
+;;  well if `TeX-parse-self' option is enabled.
 ;;
 ;;  To try out the code interactively, use `M-x texmathp RET'.
 ;;
@@ -88,6 +89,11 @@
 ;;  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:
+;;  \[ x=y \mbox{abc \(\alpha\) cba} AAA \]
+;;  \[ x=y \begin{minipage}{3cm} abc \[\alpha\] cba \end{minipage} AAA \]
 ;;--------------------------------------------------------------------------
 
 ;;; Code:
@@ -130,37 +136,7 @@
     ("\\textrm"      arg-off)
     ("\\("           sw-on)       ("\\)"           sw-off)
     ("\\["           sw-on)       ("\\]"           sw-off)
-    ("\\ensuremath"  arg-on)
-
-    ;; AMS-LaTeX
-    ("equation*"     env-on)
-    ("align"         env-on)      ("align*"        env-on)
-    ("gather"        env-on)      ("gather*"       env-on)
-    ("multline"      env-on)      ("multline*"     env-on)
-    ("flalign"       env-on)      ("flalign*"      env-on)
-    ("alignat"       env-on)      ("alignat*"      env-on)
-    ("xalignat"      env-on)      ("xalignat*"     env-on)
-    ("xxalignat"     env-on)      ("\\boxed"       arg-on)
-    ("\\text"        arg-off)     ("\\intertext"   arg-off)
-
-    ;; mathtools
-    ("\\shortintertext"   arg-off)
-
-    ;; empheq
-    ("empheq"        env-on)
-    ("AmSequation"   env-on)      ("AmSequation*"  env-on)
-    ("AmSalign"      env-on)      ("AmSalign*"     env-on)
-    ("AmSgather"     env-on)      ("AmSgather*"    env-on)
-    ("AmSmultline"   env-on)      ("AmSmultline*"  env-on)
-    ("AmSflalign"    env-on)      ("AmSflalign*"   env-on)
-    ("AmSalignat"    env-on)      ("AmSalignat*"   env-on)
-
-    ;; breqn
-    ("dmath"         env-on)      ("dmath*"        env-on)
-    ("dseries"       env-on)      ("dseries*"      env-on)
-    ("dgroup"        env-on)      ("dgroup*"       env-on)
-    ("darray"        env-on)      ("darray*"       env-on)
-    ("dsuspend"      env-off))
+    ("\\ensuremath"  arg-on))
   "The default entries for `texmathp-tex-commands', which see.")
 
 (defun texmathp-compile ()



reply via email to

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