emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex c6d6c19 79/80: Merge remote-tracking branch 'ori


From: Tassilo Horn
Subject: [elpa] externals/auctex c6d6c19 79/80: Merge remote-tracking branch 'origin/master' into externals/auctex
Date: Wed, 16 Oct 2019 11:07:22 -0400 (EDT)

branch: externals/auctex
commit c6d6c19b1387dc488693f1a7407299314f485f2e
Merge: 0c8d670 01dc048
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Merge remote-tracking branch 'origin/master' into externals/auctex
---
 Makefile.in                                        |  15 +-
 auctex.el.in                                       |  41 ++-
 context.el                                         |   2 +-
 doc/auctex.texi                                    |   6 +-
 doc/changes.texi                                   |  28 +-
 doc/install.texi                                   |   4 +-
 doc/preview-problems.texi                          |  56 ++++
 font-latex.el                                      | 130 ++++++++--
 latex.el                                           | 124 ++++++++-
 multi-prompt.el                                    |   8 +-
 preview.el                                         | 194 ++++++++++----
 prv-emacs.el                                       |   9 +-
 style/AnonymousPro.el                              |  10 +-
 style/babel.el                                     | 286 ++++++++++++++++++---
 style/beamer.el                                    |   1 +
 .../path-expansion.el => style/beamerarticle.el    |  24 +-
 .../tex/path-expansion.el => style/beamerswitch.el |  24 +-
 style/bicaption.el                                 |   9 +-
 style/breqn.el                                     |  14 +-
 style/caption.el                                   |  11 +-
 style/changelog.el                                 | 159 ++++++++++++
 style/cleveref.el                                  | 141 ++++++++--
 style/color.el                                     |   6 +-
 style/expl3.el                                     |   7 +-
 style/fancyvrb.el                                  |  10 +-
 style/floatrow.el                                  |  20 +-
 style/fontspec.el                                  |   2 +-
 style/fvextra.el                                   |  74 +++++-
 style/hyperref.el                                  |  12 +-
 style/listings.el                                  |  23 +-
 style/ltugboat.el                                  | 283 ++++++++++++++++++++
 style/mflogo.el                                    |  15 +-
 style/{mflogo.el => multitoc.el}                   |  38 ++-
 style/paracol.el                                   |  27 +-
 style/pst-plot.el                                  |   6 +-
 style/ragged2e.el                                  |  15 +-
 style/subcaption.el                                |  19 +-
 style/tcolorbox.el                                 |  21 +-
 style/thmtools.el                                  |  35 ++-
 style/titlesec.el                                  |  18 +-
 style/varioref.el                                  | 141 +++++-----
 style/xcolor.el                                    |   9 +-
 style/xparse.el                                    |  10 +-
 tests/latex/preview-latex-test.el                  |   2 +-
 tests/tex/navigation.el                            |  54 ++++
 tests/tex/path-expansion.el                        |   2 +-
 tex-buf.el                                         |  62 +++--
 tex-info.el                                        |   6 +-
 tex-jp.el                                          |   3 +-
 tex.el                                             | 126 +++++++--
 texmathp.el                                        |   6 +-
 51 files changed, 1860 insertions(+), 488 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 3c07c16..bee090e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -52,12 +52,15 @@ PACKAGE=auctex
 PACKAGE_INFO=auctex preview-latex
 EMACS=@EMACS@
 ELCC=$(EMACS) -batch -q -no-site-file -no-init-file -l lpath.el
-AUTOLOAD=--eval '(let ((generated-autoload-file (expand-file-name "$@"))) \
-  (mapcar (function update-file-autoloads) command-line-args-left) \
+AUTOLOAD=--eval '(let ((autoload-file (expand-file-name "$@"))) \
+  (mapcar (lambda (file) \
+            (update-file-autoloads file nil autoload-file)) \
+          command-line-args-left) \
   (save-buffers-kill-emacs t))'
 
-PREVIEW_AUTOLOAD=--eval '(let ((generated-autoload-file (expand-file-name 
"$@"))) \
-               (update-file-autoloads "preview.el")(save-buffers-kill-emacs 
t))'
+PREVIEW_AUTOLOAD=--eval '(let ((autoload-file (expand-file-name "$@"))) \
+  (update-file-autoloads "preview.el" nil autoload-file) \
+  (save-buffers-kill-emacs t))'
 
 # Files and directories excluded from distributed tar ball.
 EXCLUDEDFILES=autogen.sh .gitignore doc/.gitignore doc/tex-ref.log \
@@ -165,7 +168,9 @@ STYLESRC = style/prosper.el \
           style/arabxetex.el style/australian.el style/newzealand.el \
           style/xltabular.el style/marginnote.el style/thmtools.el \
           style/ocg-p.el     style/ocgx.el      style/thm-restate.el \
-          style/pythontex.el style/dashundergaps.el
+          style/pythontex.el style/dashundergaps.el style/beamerarticle.el \
+          style/changelog.el style/ltugboat.el  style/beamerswitch.el \
+          style/multitoc.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/auctex.el.in b/auctex.el.in
index f75b53e..93c9284 100644
--- a/auctex.el.in
+++ b/auctex.el.in
@@ -1,10 +1,45 @@
-;;; auctex.el
-;;
+;;; auctex.el --- Integrated environment for *TeX*
+
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
+
+;; URL: https://www.gnu.org/software/auctex/
+;; Maintainer: address@hidden
+;; Notifications-To: address@hidden
+;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
+;; Keywords: TeX LaTeX Texinfo ConTeXt docTeX preview-latex
+
+;; 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 of the License, 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 can be used for starting up AUCTeX.  The following somewhat
 ;; strange trick causes tex-site.el to be loaded in a way that can be
 ;; safely undone using (unload-feature 'tex-site).
-;;
+
+;;; Code:
+
+;; FIXME: I don't quite understand in which way this is better than less
+;; strange code such as
+;;     (require 'tex-site (expand-file-name "tex-site.el"
+;;                         (file-name-directory load-file-name))
+
 (autoload 'TeX-load-hack
   @lisptexsite@)
 (TeX-load-hack)
 
+;;; auctex.el ends here
diff --git a/context.el b/context.el
index db2f86f..87bcd38 100644
--- a/context.el
+++ b/context.el
@@ -619,7 +619,7 @@ inserted after the sectioning command."
 ;;; Environments
 
 (defgroup ConTeXt-environment nil
-  "Environments in AUCTeX."
+  "Environments in ConTeXt."
   :group 'ConTeXt-macro)
 
 ;; TODO: interface awareness
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 8843fa9..cb25757 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -459,10 +459,10 @@ and @samp{\(...\)} in @LaTeX{} files by pressing @kbd{$}, 
add the
 following to your init file
 @lisp
 (add-hook 'plain-TeX-mode-hook
-         (lambda () (set (make-variable-buffer-local 'TeX-electric-math)
+         (lambda () (set (make-local-variable 'TeX-electric-math)
                          (cons "$" "$"))))
 (add-hook 'LaTeX-mode-hook
-         (lambda () (set (make-variable-buffer-local 'TeX-electric-math)
+         (lambda () (set (make-local-variable 'TeX-electric-math)
                          (cons "\\(" "\\)"))))
 @end lisp
 
@@ -2163,7 +2163,7 @@ following stanza into your init file:
 (eval-after-load "font-latex"
   '(setq-default
     font-latex-match-reference-keywords-local
-    (remove (TeX-assoc-string "footnote"
+    (remove (assoc-string "footnote"
             font-latex-match-reference-keywords-local)
                 font-latex-match-reference-keywords-local)))
 @end lisp
diff --git a/doc/changes.texi b/doc/changes.texi
index 8475ced..41e73da 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -1,5 +1,5 @@
 @c This is part of the AUCTeX manual.
-@c Copyright (C) 1994-2002, 2004-2010, 2012-2017 Free Software
+@c Copyright (C) 1994-2002, 2004-2010, 2012-2019 Free Software
 @c Foundation, Inc.
 @c See file auctex.texi for copying conditions.
 @include macros.texi
@@ -12,6 +12,18 @@
 
 @itemize @bullet
 @item
+A new method is implemented in @previewlatex{} to adjust the foreground
+colors of generated images to those of Emacs, when the @LaTeX{} command
+produces @acronym{PDF}.  The traditional method became invalid because
+of the change introduced in Ghostscript 9.27.  Unfortunately, the new
+method doesn't work due to a bug in Ghostscript 9.27 and is valid only
+for Ghostscript > 9.27.  There is also a fallback method for gs 9.27
+users which displays plain ``black on white'' images.  For successful
+function of @previewlatex{}, the users are encouraged to set up the new
+user option @code{preview-pdf-color-adjust-method} to choose appropriate
+option among the three: new, traditional and fallback method.
+
+@item
 @AUCTeX{} has support for the Flymake package in Emacs 26 or newer.  To
 enable, call @kbd{M-x flymake-mode RET} or add this to your
 @file{.emacs} file:
@@ -52,11 +64,25 @@ Texinfo mode.  When it is enabled, typing @kbd{@@} will 
invoke
 other TeX modes of @AUCTeX{}.
 
 @item
+Fontification support for @samp{biblatex} package is improved and
+updated to macros provided by package version 3.12.  For qualified
+lists, at least 2 mandatory arguments are fontified.
+
+@item
 Support for column specifiers @samp{w} and @samp{W} provided by
 @samp{array} package is added to @file{array.el}.  The correct counting
 of columns only works when the @samp{align} parameter is enclosed in
 braces, e.g., @samp{w@{l@}@{3cm@}}.  The short version @samp{wl@{3cm@}}
 is not supported.
+
+@item
+Entries for @samp{PDF Tools} are added in
+@code{TeX-view-program-list-builtin} for Windows and macOS.  This viewer
+can be configured under these operating systems with an entry like this
+in an init file:
+@lisp
+(setq TeX-view-program-selection '((output-pdf "PDF Tools")))
+@end lisp
 @end itemize
 
 @heading News in 12.1
diff --git a/doc/install.texi b/doc/install.texi
index 1940d9d..0e88cec 100644
--- a/doc/install.texi
+++ b/doc/install.texi
@@ -94,8 +94,8 @@ support.
 @item Windows
 Precompiled versions are available from
 @uref{https://ftp.gnu.org/gnu/emacs/windows/}.
-@item Mac OS X
-For an overview of precompiled versions of Emacs for Mac OS X see for
+@item macOS
+For an overview of precompiled versions of Emacs for macOS see for
 example @uref{https://www.emacswiki.org/emacs/EmacsForMacOS}.
 @item GNU/Linux
 Most GNU/Linux distributions nowadays provide a recent variant of Emacs
diff --git a/doc/preview-problems.texi b/doc/preview-problems.texi
index 824892c..264e14c 100644
--- a/doc/preview-problems.texi
+++ b/doc/preview-problems.texi
@@ -19,6 +19,7 @@ newer versions of the problematic software or by simple 
patches.
 * Too small bounding boxes::    
 * x-symbol interoperation::     
 * Middle-clicks paste instead of toggling::  
+* No images are displayed with gs 9.27 and earlier::
 @end menu
 
 If you find something not mentioned here, please send a bug report using
@@ -137,3 +138,58 @@ such a complicated mess that no patch is in sight.  Better 
just end the
 search with @kbd{@key{RET}} before toggling and resume with @kbd{C-s
 C-s} or similar afterwards.  Since previews over the current match will
 auto-open, anyway, this should not be much of a problem in practice.
+
+@node No images are displayed with gs 9.27 and earlier
+@section No images are displayed with gs 9.27 and earlier
+
+@previewlatex{} tries to adjust the foreground and background colors of
+generated images to those of Emacs.  Unfortunately, incompatible changes
+introduced in Ghostscript 9.27 breaks the traditional method partially,
+and @previewlatex{} can display no images under certain circumstances.
+
+A new method implemented alternatively works only with Ghostscript >
+9.27.  If you are using Ghostscript 9.27 or earlier, customize the
+option @code{preview-pdf-adjust-color-method}.
+
+@defopt preview-pdf-adjust-color-method
+Method to adjust colors of images generated from @acronym{PDF}.  It is
+not consulted when the @LaTeX{} command produces @acronym{DVI} files.
+
+When the option is @code{t} (default), @previewlatex{} adjusts the FG
+and BG colors of the generated images by the new method.  This method
+requires that Ghostscript has working @code{DELAYBIND} feature, thus is
+invalid with gs 9.27 (and possibly < 9.27).
+
+When it is @code{compatible}, @previewlatex{} uses traditional method.
+This option is provided for backward compatibility with older gs.  See
+the below explanation for detail.
+
+When @code{nil}, no adjustment is done and ``black on white'' image is
+generated regardless of Emacs color.  This is provided for fallback for
+gs 9.27 users with customized foreground color.  See the below
+explanation for detail.
+
+When the @LaTeX{} command produces @acronym{PDF} rather than
+@acronym{DVI} and Emacs has non-trivial foreground color, the
+traditional method (@code{compatible}) makes gs >= 9.27 to stop with
+error.  Here, ``non-trivial foreground color'' includes customized
+themes.
+
+If you use such non-trivial foreground color and the version of
+Ghostscript equals to 9.27, you have two options:
+@enumerate
+@item
+Choose the value @code{compatible} and customize
+@code{preview-reference-face} to have default (black) foreground color.
+This makes the generated image almost non-readable on dark background,
+so the next option would be your only choice in that case.
+@item
+Choose the value @code{nil}, which forces plain ``black on white''
+appearance for the generated image.  You can at least read what are
+written in the image although they may not match with your Emacs color
+well.
+@end enumerate
+
+The default value used to be @code{compatible} for short period before
+Ghostscript 9.50 was released but now is @code{t}.
+@end defopt
diff --git a/font-latex.el b/font-latex.el
index bd504a8..4df9526 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1,6 +1,6 @@
 ;;; font-latex.el --- LaTeX fontification for Font Lock mode.
 
-;; Copyright (C) 1996-2017  Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019  Free Software Foundation, Inc.
 
 ;; Authors:    Peter S. Galbraith <address@hidden>
 ;;             Simon Marshall <address@hidden>
@@ -263,33 +263,84 @@ variable `font-latex-fontify-sectioning'." ',num)
      ("newrefsegment" "mancite" "pno" "ppno" "nopp" "psq" "psqq")
      font-lock-variable-name-face 2 noarg)
     ("biblatex"
-     (("newrefsection" "[") ("ExecuteBibliographyOptions" "[{")
-      ("printbibliography" "[") ("printshorthands" "[") ("printbibheading" "[")
+     (;; 3.2.2 Setting Package Options
+      ("ExecuteBibliographyOptions" "[{")
+      ;; 3.7.1 Resources
       ("addbibresource" "[{") ("addglobalbib" "[{") ("addsectionbib" "[{")
-      ("bibbysection" "[") ("bibbysegment" "[") ("bibbycategory" "[")
-      ("DeclareBibliographyCategory" "{") ("addtocategory" "{{") 
("defbibenvironment" "{{{{")
-      ("defbibheading" "{[{") ("defbibnote" "{{") ("defbibfilter" "{{") 
("defbibcheck" "{{")
-      ("defbibentryset" "{{") ("Cite" "[[{") ("parencite" "*[[{") ("Parencite" 
"[[{")
-      ("footcite" "[[{") ("footcitetext" "[[{") ("textcite" "[[{") ("Textcite" 
"[[{")
-      ("smartcite" "[[{") ("Smartcite" "[[{") ("supercite" "{") ("autocite" 
"*[[{")
-      ("Autocite" "*[[{") ("citeauthor" "*[[{") ("Citeauthor" "*[[{") 
("citetitle" "*[[{")
-      ("citeyear" "*[[{") ("citedate" "*[[{") ("citeurl" "[[{") ("parentext" 
"{")
-      ("brackettext" "{") ("fullcite" "[[{") ("fullfootcite" "[[{") ("volcite" 
"[{[[")
-      ("Volcite" "[{[[") ("pvolcite" "[{[[") ("Pvolcite" "[{[[") ("fvolcite" 
"[{[[")
-      ("ftvolcite" "[{[[") ("svolcite" "[{[[") ("Svolcite" "[{[[") ("tvolcite" 
"[{[[")
-      ("Tvolcite" "[{[[") ("avolcite" "[{[[") ("Avolcite" "[{[[") ("notecite" 
"[[{")
-      ("Notecite" "[[{") ("pnotecite" "[[{") ("Pnotecite" "[[{") ("fnotecite" 
"[[{")
-      ("citename" "[[{[{") ("citelist" "[[{[{") ("citefield" "[[{[{") 
("citereset" "*")
-      ("RN" "{") ("Rn" "{") ("DefineBibliographyStrings" "{{") 
("DefineBibliographyExtras" "{{")
+      ;; 3.7.2 The Bibliography
+      ("printbibliography" "[") ("bibbysection"    "[") ("bibbysegment" "[")
+      ("bibbycategory"     "[") ("printbibheading" "[")
+      ;; 3.7.3 Bibliography Lists
+      ("printbiblist" "[{") ("printshorthands" "[")
+      ;; 3.7.4 Bibliography Sections
+      ("newrefsection" "[")
+      ;; 3.7.6 Bibliography Categories
+      ("DeclareBibliographyCategory" "{") ("addtocategory" "{{")
+      ;; 3.7.7 Bibliography Headings and Environments
+      ("defbibenvironment" "{{{{") ("defbibheading" "{[{")
+      ;; 3.7.8 Bibliography Notes
+      ("defbibnote" "{{")
+      ;; 3.7.9 Bibliography Filters and Checks
+      ("defbibfilter" "{{") ("defbibcheck" "{{")
+      ;; 3.7.10 Reference Contexts
+      ("DeclareRefcontext"       "{{")  ("newrefcontext"        "[{")
+      ("assignrefcontextkeyws"   "*[{") ("assignrefcontextcats" "*[{")
+      ("assignrefcontextentries" "*[{")
+      ;; 3.7.11 Dynamic Entry Sets
+      ("defbibentryset" "{{")
+      ;; 3.8.1 Standard Commands
+      ("Cite" "[[{")
+      ("parencite" "*[[{") ("Parencite"    "[[{")
+      ("footcite"  "[[{")  ("footcitetext" "[[{")
+      ;; 3.8.2 Style-specific Commands
+      ("textcite"  "[[{") ("Textcite"  "[[{")
+      ("smartcite" "[[{") ("Smartcite" "[[{")
+      ("supercite" "{")
+      ;; 3.8.3 Qualified Citation Lists
+      ;; For qualified lists, fontify at least 2 mandatory arguments
+      ("cites"      "(([[{[[{") ("Cites"         "(([[{[[{")
+      ("parencites" "(([[{[[{") ("Parencites"    "(([[{[[{")
+      ("footcites"  "(([[{[[{") ("footcitetexts" "(([[{[[{")
+      ("smartcites" "(([[{[[{") ("Smartcites"    "(([[{[[{")
+      ("textcites"  "(([[{[[{") ("Textcites"     "(([[{[[{")
+      ("supercites" "(([[{[[{")
+      ;; 3.8.4 Style-independent Commands
+      ("autocite" "*[[{")      ("Autocite" "*[[{")
+      ("autocites" "(([[{[[{") ("Autocites" "(([[{[[{")
+      ;; 3.8.5 Text Commands
+      ("citeauthor" "*[[{") ("Citeauthor" "*[[{") ("citetitle" "*[[{")
+      ("citeyear"   "*[[{") ("citedate" "*[[{")
+      ("citeurl"    "[[{")  ("parentext" "{")
+      ("brackettext" "{")
+      ;; 3.8.6 Special Commands
+      ("fullcite"  "[[{")         ("footfullcite" "[[{")
+      ("volcite"   "[{[{")        ("Volcite"      "[{[{")
+      ("volcites"  "(([{[{[{[{")  ("Volcites"     "(([{[{[{[{")
+      ("pvolcite"  "[{[{")        ("Pvolcite"     "[{[{")
+      ("pvolcites" "(([{[{[{[{")  ("Pvolcites"    "(([{[{[{[{")
+      ("fvolcite"  "[{[{")        ("ftvolcite"    "[{[{")
+      ("fvolcites" "(([{[{[{[{")  ("Fvolcites"    "(([{[{[{[{")
+      ("svolcite"  "[{[{")        ("Svolcite"     "[{[{")
+      ("svolcites" "(([{[{[{[{")  ("Svolcites"    "(([{[{[{[{")
+      ("tvolcite"  "[{[{")        ("Tvolcite"     "[{[{")
+      ("tvolcites" "(([{[{[{[{")  ("Tvolcites"    "(([{[{[{[{")
+      ("avolcite"  "[{[{")        ("Avolcite"     "[{[{")
+      ("avolcites" "(([{[{[{[{")  ("Avolcites"    "(([{[{[{[{")
+      ("notecite"  "[[{")         ("Notecite"     "[[{")
+      ("pnotecite" "[[{")         ("Pnotecite"    "[[{")
+      ("fnotecite" "[[{")
+      ;; 3.8.7 Low-level Commands
+      ("citename" "[[{[{") ("citelist" "[[{[{") ("citefield" "[[{[{")
+      ;; 3.8.8 Miscellaneous Commands
+      ("citereset" "*") ("RN" "{") ("Rn" "{")
+      ;; 3.9 Localization Commands
+      ("DefineBibliographyStrings" "{{")  ("DefineBibliographyExtras" "{{")
       ("UndefineBibliographyExtras" "{{") ("DefineHyphenationExceptions" "{{")
-      ("NewBibliographyString" "{") ("autocites" "(([[{") ("Autocites" "(([[{")
-      ("cites" "(([[{") ("Cites" "(([[{") ("parencites" "(([[{") ("Parencites" 
"(([[{")
-      ("footcites" "(([[{") ("footcitetexts" "(([[{") ("smartcites" "(([[{")
-      ("Smartcites" "(([[{") ("textcites" "(([[{") ("Textcites" "(([[{") 
("supercites" "(([[{"))
+      ("NewBibliographyString" "{"))
      font-lock-constant-face 2 command)
     ("reference"
      (("nocite" "*{") ("cite" "*[[{") ("label" "{") ("pageref" "{")
-      ("vref" "*{") ("eqref" "{") ("ref" "{") ("include" "{")
+      ("vref" "*{") ("eqref" "{") ("ref" "{") ("Ref" "{") ("include" "{")
       ("input" "{") ("bibliography" "{") ("index" "{") ("glossary" "{")
       ("footnote" "[{") ("footnotemark" "[") ("footnotetext" "[{")
       ("marginpar" "[{"))
@@ -305,7 +356,9 @@ variable `font-latex-fontify-sectioning'." ',num)
       ("newcounter" "{[") ("renewenvironment" "*{[[{{")
       ("renewcommand" "*|{\\[[{") ("renewtheorem" "{[{[")
       ("usepackage" "[{[") ("fbox" "{") ("mbox" "{") ("rule" "[{{")
-      ("addvspace" "{") ("vspace" "*{") ("hspace" "*{") ("thinspace" "") 
("negthinspace" "")
+      ("addvspace" "{") ("vspace" "*{") ("hspace" "*{")
+      ("thinspace" "")  ("negthinspace" "")
+      ("labelformat" "{{")
       ;; XXX: Should macros without arguments rather be listed in a
       ;; separate category with 'noarg instead of 'command handling?
       ("enspace" "") ("enskip" "") ("quad" "") ("qquad" "") ("nonumber" "")
@@ -523,7 +576,11 @@ use."
           (4 (font-latex-matched-face 4) append t)
           (5 (font-latex-matched-face 5) append t)
           (6 (font-latex-matched-face 6) append t)
-          (7 (font-latex-matched-face 7) append t)))
+          (7 (font-latex-matched-face 7) append t)
+          (8 (font-latex-matched-face 8) append t)
+          (9 (font-latex-matched-face 9) append t)
+          (10 (font-latex-matched-face 10) append t)
+          (11 (font-latex-matched-face 11) append t)))
        ((eq type 'noarg)
         `(,(intern (concat prefix name))
           (0 ,face)))
@@ -1714,6 +1771,14 @@ marks boundaries for searching for group ends."
   "List of characters directly after \"\\\" excluded from fontification.
 Each character is a string.")
 
+(defvar font-latex-match-simple-include-list '("@")
+  "List of characters allowed in a macro for fontification.
+Each character is a string.  This variable is initialized to
+\"@\" since internal LaTeX commands are very often redefined in a
+.tex file and the fontification should work correctly in those
+cases.")
+(make-variable-buffer-local 'font-latex-match-simple-include-list)
+
 (defun font-latex-match-simple-command (limit)
   "Search for command like \\foo before LIMIT."
   ;; \s_ matches chars with symbol syntax, \sw chars with word syntax,
@@ -1726,7 +1791,20 @@ Each character is a string.")
   ;; like `\__module_foo:nnn'
   (let* ((search (lambda ()
                   (TeX-re-search-forward-unescaped
-                   "\\\\\\(\\s_\\|\\sw\\|\\s.\\)\\(?:\\s_\\|\\sw\\)*" limit 
t)))
+                   (concat
+                     ;; Chars directly after backslash
+                     "\\\\\\(\\s_\\|\\sw\\|\\s.\\)"
+                     ;; Start group of the following chars
+                     "\\(?:["
+                     ;; a-zA-Z are always allowed:
+                     "a-zA-Z"
+                     ;; Additional characters added by AUCTeX styles
+                     (mapconcat #'identity
+                                  font-latex-match-simple-include-list
+                                  "")
+                     ;; End group
+                     "]\\)*")
+                   limit t)))
         (pos (funcall search)))
     (while (and pos
                (member (match-string 1)
diff --git a/latex.el b/latex.el
index d260006..514ffbb 100644
--- a/latex.el
+++ b/latex.el
@@ -1,6 +1,6 @@
 ;;; latex.el --- Support for LaTeX documents.
 
-;; Copyright (C) 1991, 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1993-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -1701,7 +1701,8 @@ The value is actually the tail of the list of options 
given to CLASS."
   (member option (cdr (assoc class LaTeX-provided-class-options))))
 
 (defun LaTeX-match-class-option (regexp)
-  "Check if a documentclass option matching REGEXP is active."
+  "Check if a documentclass option matching REGEXP is active.
+Return first found class option matching REGEXP, or nil if not found."
   (TeX-member regexp (apply #'append
                            (mapcar #'cdr LaTeX-provided-class-options))
              'string-match))
@@ -2351,7 +2352,8 @@ of the options, nil otherwise."
            packages))
     (insert LaTeX-optop options LaTeX-optcl))
   (insert TeX-grop (mapconcat 'identity packages ",") TeX-grcl)
-  (run-hooks 'LaTeX-after-usepackage-hook))
+  (run-hooks 'LaTeX-after-usepackage-hook)
+  (apply #'TeX-run-style-hooks packages))
 
 (defun LaTeX-arg-usepackage (_optional)
   "Insert arguments to usepackage.
@@ -2359,8 +2361,7 @@ OPTIONAL is ignored."
   (let* ((packages-options (LaTeX-arg-usepackage-read-packages-with-options))
         (packages (car packages-options))
         (options (cdr packages-options)))
-    (LaTeX-arg-usepackage-insert packages options)
-    (apply #'TeX-run-style-hooks packages)))
+    (LaTeX-arg-usepackage-insert packages options)))
 
 (defun LaTeX-insert-usepackages ()
   "Prompt for the insertion of usepackage macros until empty
@@ -2791,6 +2792,8 @@ Automatic right brace insertion is done only if no prefix 
ARG is given and
 `LaTeX-electric-left-right-brace' is non-nil.
 Normally bound to keys \(, { and [."
   (interactive "*P")
+  ;; If you change the condition for `auto-p', adjust the condition in
+  ;; the `delete-selection' property, just below this defun, accordingly.
   (let ((auto-p (and LaTeX-electric-left-right-brace (not arg))))
     (if (and auto-p
             (TeX-active-mark)
@@ -2828,6 +2831,33 @@ Normally bound to keys \(, { and [."
                (goto-char (mark)))
            (LaTeX-insert-corresponding-right-macro-and-brace
             lmacro lbrace)))))))
+;; Cater for `delete-selection-mode' (bug#36385)
+;; See the header comment of delsel.el for detail.
+(put #'LaTeX-insert-left-brace 'delete-selection
+     ;; COMPATIBILITY for Emacs < 24.3
+     (if (and (= emacs-major-version 24)
+             (< emacs-minor-version 3))
+        ;; Emacs < 24.3 doesn't support a function as value of
+        ;; `delete-selection' property.
+        nil
+       (lambda ()
+        ;; Consult `delete-selection' property when
+        ;; `LaTeX-insert-left-brace' works just the same as
+        ;; `self-insert-command'.
+        (and (or (not LaTeX-electric-left-right-brace)
+                 current-prefix-arg)
+             (let ((f (get #'self-insert-command 'delete-selection)))
+               ;; If `delete-selection' property of
+               ;; `self-insert-command' is one of the predefined
+               ;; special symbols, just return itself.
+               (if (memq f '(yank supersede kill t nil))
+                   ;; FIXME: if this list of special symbols is
+                   ;; extended in future delsel.el, this discrimination
+                   ;; will become wrong.
+                   f
+                 ;; Otherwise, call it as a function and return
+                 ;; its value.
+                 (funcall f)))))))
 
 (defun LaTeX-insert-corresponding-right-macro-and-brace
   (lmacro lbrace &optional optional prompt)
@@ -5362,11 +5392,31 @@ commands are defined:
   "Insert \\STRING{}.  If DOLLAR is non-nil, put $'s around it.
 If `TeX-electric-math' is non-nil wrap that symbols around the
 string."
-  (when dollar
-    (insert (or (car TeX-electric-math) "$"))
-    (save-excursion
-      (insert (or (cdr TeX-electric-math) "$"))))
-  (funcall LaTeX-math-insert-function string))
+  (let ((active (TeX-active-mark))
+       m closer)
+    (if (and active (> (point) (mark)))
+       (exchange-point-and-mark))
+    (when dollar
+      (insert (or (car TeX-electric-math) "$"))
+      (save-excursion
+       (if active (goto-char (mark)))
+       ;; Store closer string for later reference.
+       (setq closer (or (cdr TeX-electric-math) "$"))
+       (insert closer)
+       ;; Set temporal marker to decide whether to put the point
+       ;; after the math mode closer or not.
+       (setq m (point-marker))))
+    (funcall LaTeX-math-insert-function string)
+    (when dollar
+      ;; If the above `LaTeX-math-insert-function' resulted in
+      ;; inserting, e.g., a pair of "\langle" and "\rangle" by
+      ;; typing "`(", keep the point between them.  Otherwise
+      ;; move the point after the math mode closer.
+      (if (= m (+ (point) (length closer)))
+         (goto-char m))
+      ;; Make temporal marker point nowhere not to slow down the
+      ;; subsequent editing in the buffer.
+      (set-marker m nil))))
 
 (defun LaTeX-math-cal (char dollar)
   "Insert a {\\cal CHAR}.  If DOLLAR is non-nil, put $'s around it.
@@ -6020,7 +6070,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
 Also sets `match-data' so that group 1 is the already typed
 prefix.
 
-For example, in $a + \a| - 17$ with | denoting point, the
+For example, in $a + \\a| - 17$ with | denoting point, the
 function would return non-nil and `(match-string 1)' would return
 \"a\" afterwards."
   (and (texmathp)
@@ -6086,7 +6136,7 @@ function would return non-nil and `(match-string 1)' 
would return
                  ("\\\\nocite{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-bibitem-list "}")
                  ("\\\\nocite{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
                   2 LaTeX-bibitem-list)
-                 ("\\\\ref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
+                 ("\\\\[Rr]ef{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
                  ("\\\\eqref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
                  ("\\\\pageref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
                  ("\\\\\\(index\\|glossary\\){\\([^{}\n\r\\%]*\\)"
@@ -6172,6 +6222,9 @@ function would return non-nil and `(match-string 1)' 
would return
    '("label" TeX-arg-define-label)
    '("pageref" TeX-arg-ref)
    '("ref" TeX-arg-ref)
+   ;; \Ref and \labelformat are part of kernel with LaTeX 2019-10-01:
+   '("Ref" TeX-arg-ref)
+   '("labelformat" TeX-arg-counter t)
    '("newcommand" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] t)
    '("renewcommand" TeX-arg-macro [ TeX-arg-define-macro-arguments ] t)
    '("newenvironment" TeX-arg-define-environment
@@ -6496,7 +6549,11 @@ function would return non-nil and `(match-string 1)' 
would return
   ;; emacs 24.4.
   (when (and LaTeX-electric-left-right-brace
             (boundp 'electric-pair-mode))
-    (set (make-local-variable 'electric-pair-mode) nil)))
+    (set (make-local-variable 'electric-pair-mode) nil))
+
+  ;; Initialization of `add-log-current-defun-function':
+  (set (make-local-variable 'add-log-current-defun-function)
+       #'TeX-current-defun-name))
 
 (defun LaTeX-imenu-create-index-function ()
   "Imenu support function for LaTeX."
@@ -6640,6 +6697,47 @@ functions `TeX-arg-color' (style/color.el) or
              last-optional-rejected))
      ,@body))
 
+(defun LaTeX-extract-key-value-label (&optional key num)
+  "Return a regexp string to match a label in an optional argument.
+The optional KEY is a string which is the name of the key in the
+key=value, default is \"label\".  NUM is an integer for an
+explicitly numbered group construct, useful when adding items to
+`reftex-label-regexps'.
+
+As an extra feature, the key can be the symbol none where the
+entire matching for the key=value is skipped.  The regexp then is
+useful for skipping complex optional arguments.  It should be
+wrapped in \\(?:...\\)? then."
+  ;; The regexp produced here is ideally in sync with the complex one
+  ;; in `reftex-label-regexps'.
+  (concat
+   ;; Match the opening [ and the following chars
+   "\\[[^][]*"
+   ;; Allow nested levels of chars enclosed in braces
+   "\\(?:{[^}{]*"
+     "\\(?:{[^}{]*"
+       "\\(?:{[^}{]*}[^}{]*\\)*"
+     "}[^}{]*\\)*"
+   "}[^][]*\\)*"
+   ;; If KEY is the symbol none, don't look for any key=val:
+   (unless (eq key 'none)
+     (concat "\\<"
+            ;; Match the key, default is label
+            (or key "label")
+            ;; Optional spaces
+            "[[:space:]]*=[[:space:]]*"
+            ;; Match the value; braces around the value are optional
+            "{?\\("
+            ;; Cater for NUM which sets the regexp group
+            (when (and num (integerp num))
+              (concat "?" (number-to-string num) ":"))
+            ;; One of these chars terminates the value
+            "[^] ,}\r\n\t%]+"
+            ;; Close the group
+            "\\)}?"))
+   ;; We are done.  Just search until the next closing bracket
+   "[^]]*\\]"))
+
 (provide 'latex)
 
 ;;; latex.el ends here
diff --git a/multi-prompt.el b/multi-prompt.el
index 8337ebc..f7632be 100644
--- a/multi-prompt.el
+++ b/multi-prompt.el
@@ -1,6 +1,7 @@
 ;;; multi-prompt.el --- Completing read of multiple strings
 
-;; Copyright (C) 1996, 1997, 2000, 2009, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 2000, 2009, 2014, 2019 Free Software
+;; Foundation, Inc.
 
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Maintainer: address@hidden
@@ -52,10 +53,7 @@ are the arguments to `completing-read'.  See that."
                     minibuffer-local-must-match-map
                   minibuffer-local-completion-map))
        (new-map (make-sparse-keymap)))
-    (if (fboundp 'set-keymap-parent)
-       ;; `set-keymap-parent' was introduced in Emacs 19.32.
-       (set-keymap-parent new-map old-map)
-      (setq new-map (copy-keymap old-map)))
+    (set-keymap-parent new-map old-map)
     (define-key new-map separator (if require-match
                                      'multi-prompt-next-must-match
                                    'multi-prompt-next))
diff --git a/preview.el b/preview.el
index f10c930..a507369 100644
--- a/preview.el
+++ b/preview.el
@@ -1,7 +1,7 @@
 ;;; preview.el --- embed preview LaTeX images in source buffer
 
 ;; Copyright (C) 2001-2006, 2010-2015,
-;;               2017, 2018  Free Software Foundation, Inc.
+;;               2017-2019  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: tex, wp, convenience
@@ -602,6 +602,49 @@ tag in the mode line."
       (setq preview-error-condition nil
            compilation-in-progress (delq process compilation-in-progress)))))
 
+(defcustom preview-pdf-color-adjust-method t
+  "Method to adjust colors of images generated from PDF.
+It is not consulted when the latex command produces DVI files.
+
+The valid values are:
+
+t: preview-latex transfers the foreground and background colors
+of Emacs to the generated images.  This option requires that
+Ghostscript has working DELAYBIND feature, thus is invalid with
+gs 9.27 (and possibly < 9.27).
+
+`compatible': preview-latex uses another mothod to transfer
+colors.  This option is provided for compatibility with older gs.
+See the below explanation for detail.
+
+nil: no adjustment is done and \"black on white\" image is
+generated regardless of Emacs color.  This is provided for fallback for
+gs 9.27 users with customized foreground color.  See the below
+explanation for detail.
+
+When the latex command produces PDF rather than DVI and Emacs has
+non-trivial foreground color, the traditional method (`compatible')
+makes gs >= 9.27 to stop with error.  Here, \"non-trivial foreground
+color\" includes customized themes.
+
+If you use such non-trivial foreground color and the version of
+Ghostscript equals to 9.27, you have two options:
+
+- Choose the value `compatible' and customize
+`preview-reference-face' to have default (black) foreground
+color.  This makes the generated image almost non-readable on
+dark background, so the next option would be your only choice in
+that case.
+- Choose the value nil, which forces plain \"black on white\"
+appearance for the generated image.  You can at least read what
+are written in the image although they may not match with your
+Emacs color well."
+  :group 'preview-appearance
+  :type '(choice
+         (const :tag "Adjust to Emacs color (gs > 9.27)" t)
+         (const :tag "Compatibility for gs =< 9.27" compatible)
+         (const :tag "No adjustment (B/W, for gs 9.27)" nil)))
+
 (defun preview-gs-sentinel (process string)
   "Sentinel function for rendering process.
 Gets the default PROCESS and STRING arguments
@@ -681,8 +724,8 @@ Gets the usual PROCESS and STRING parameters, see
       (setq preview-gs-sequence (list 1)))
     (setcdr preview-gs-sequence 1)
     (let* ((process-connection-type nil)
-          (outfile (format "-dOutputFile=%s"
-                           (preview-ps-quote-filename
+          (outfile (format "-sOutputFile=%s"
+                           (file-relative-name
                             (format "%s/pr%d-%%d.%s"
                                     (car TeX-active-tempdir)
                                     (car preview-gs-sequence)
@@ -732,7 +775,19 @@ null eq{pop{pop}bind}if def\
 {pop}{setpagedevice}{ifelse exec}\
 stopped{handleerror quit}if \
 .preview-ST aload pop restore}bind def "
-                 (preview-gs-color-string preview-colors)))
+                 (preview-gs-color-string
+                  preview-colors
+                  ;; Compatibility for gs 9.27 with non-trivial
+                  ;; foreground color and dark background.
+                  ;; Suppress color adjustment with PDF backend
+                  ;; when `preview-pdf-color-adjust-method' is nil.
+                  (and (not preview-pdf-color-adjust-method)
+                       ;; The switch `preview-parsed-pdfoutput' isn't
+                       ;; set before parsing the latex output, so use
+                       ;; heuristic here.
+                       (with-current-buffer TeX-command-buffer
+                         (and TeX-PDF-mode
+                              (not TeX-PDF-from-DVI)))))))
     (preview-gs-queue-empty)
     (preview-parse-messages (or setup #'preview-gs-dvips-process-setup))))
 
@@ -744,21 +799,46 @@ to Ghostscript floats."
 
 (defun preview-pdf-color-string (colors)
   "Return a string that patches PDF foreground color to work properly."
-  ;; Actually, this is rather brutal.  It will only be invoked in
-  ;; cases, however, where previously it was not expected that
-  ;; anything readable turned up, anyway.
   (let ((fg (aref colors 1)))
     (if fg
-       (concat
-        "/GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin\
+       (cond ((eq preview-pdf-color-adjust-method t)
+              ;; New code for gs > 9.27.
+              ;; This assumes DELAYBIND feature, which is known to be
+              ;; broken in gs 9.27 (and possibly, < 9.27).
+              ;; 
<URL:https://lists.gnu.org/archive/html/auctex-devel/2019-07/msg00000.html>
+              ;; DELAYBIND is sometimes mentioned in association with
+              ;; security holes in the changelog of Ghostscript:
+              ;; <URL:https://www.ghostscript.com/doc/9.27/History9.htm>
+              ;; Thus we might have to be prepared for removal of this
+              ;; feature in future Ghostscript.
+              (concat
+               "/initgraphics {
+  //initgraphics
+  /RG where {
+    pop "
+               (mapconcat #'preview-gs-color-value fg " ")
+               " 3 copy rg RG
+  } if
+} bind def .bindnow "))
+             ((eq preview-pdf-color-adjust-method 'compatible)
+              ;; Traditional code for gs < 9.27.
+              (concat
+               "/GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup 
begin\
 /graphicsbeginpage{//graphicsbeginpage exec "
-        (mapconcat #'preview-gs-color-value fg " ")
-        " 3 copy rg RG}bind store end readonly store "))))
-
-(defun preview-gs-color-string (colors)
-  "Return a string setting up colors"
-  (let ((bg (aref colors 0))
-       (fg (aref colors 1))
+               (mapconcat #'preview-gs-color-value fg " ")
+               " 3 copy rg RG}bind store end readonly store "))
+             (;; Do nothing otherwise.
+              t
+              "")))))
+
+(defun preview-gs-color-string (colors &optional suppress-fgbg)
+  "Return a string setting up COLORS.
+If optional argument SUPPRESS-FGBG is non-nil, behave as if FG/BG
+colors were just the default value."
+  (let ((bg (and (not suppress-fgbg)
+                (aref colors 0)))
+       (fg (and (not suppress-fgbg)
+                (aref colors 1)))
        (mask (aref colors 2))
        (border (aref colors 3)))
     (concat
@@ -910,6 +990,12 @@ The usual PROCESS and COMMAND arguments for
        (cond ((eq status 'exit)
               (delete-process process)
               (setq TeX-sentinel-function nil)
+              ;; Add DELAYBIND option for adjustment of foreground
+              ;; color to work.
+              (if (eq preview-pdf-color-adjust-method t)
+                  (setq preview-gs-command-line (append
+                                                 preview-gs-command-line
+                                                 '("-dDELAYBIND"))))
               (setq preview-gs-init-string
                     (concat preview-gs-init-string
                             (preview-pdf-color-string preview-colors)))
@@ -1076,9 +1162,16 @@ NONREL is not NIL."
                      (list file))))
     (setq preview-gs-dsc (preview-dsc-parse file))
     (setq preview-gs-init-string
-         (concat (format "{<</PermitFileReading[%s]>> setuserparams \
+         ;; Add commands for revised file access controls introduced
+         ;; after gs 9.27 (bug#37719)
+         (concat (format "systemdict /.addcontrolpath known {%s} if\n"
+                         (mapconcat (lambda (f)
+                                      (format "/PermitFileReading %s 
.addcontrolpath"
+                                              (preview-ps-quote-filename f)))
+                                    all-files "\n"))
+                 (format "{<</PermitFileReading[%s]>> setuserparams \
 .locksafe} stopped pop "
-                         (mapconcat 'preview-ps-quote-filename all-files ""))
+                         (mapconcat #'preview-ps-quote-filename all-files ""))
                  preview-gs-init-string
                  (format " %s(r)file /.preview-ST 1 index def %s exec 
.preview-ST "
                          (preview-ps-quote-filename file)
@@ -1149,32 +1242,37 @@ for the file extension."
 (defun preview-mouse-open-eps (file &optional position)
   "Display eps FILE in a view buffer on click.
 Place point at POSITION, else beginning of file."
-  (let ((default-major-mode
+  (let ((default-mode
           ;; FIXME: Yuck!  Just arrange for the file name to have the right
           ;; extension instead!
-         (or
-          (assoc-default "x.ps" auto-mode-alist #'string-match)
-          (default-value 'major-mode)))
+         (assoc-default "x.ps" auto-mode-alist #'string-match))
        (buff (get-file-buffer file)))
     (save-excursion
       (if buff
          (pop-to-buffer buff)
        (view-file-other-window file))
+      (if (and (eq major-mode (default-value 'major-mode))
+              default-mode)
+         (funcall default-mode))
       (goto-char (or position (point-min)))
-      (if (eq major-mode 'ps-mode)          ; Bundled with GNU Emacs
-         (message "%s" (substitute-command-keys "\
+      (message "%s" (substitute-command-keys "\
 Try \\[ps-run-start] \\[ps-run-buffer] and \
-\\<ps-run-mode-map>\\[ps-run-mouse-goto-error] on error offset." )))
-      (if (eq major-mode 'postscript-mode) ; Bundled with XEmacs, limited
-         (message "%s" (substitute-command-keys "\
-Try \\[ps-shell] and \\[ps-execute-buffer]."))))))
+\\<ps-run-mode-map>\\[ps-run-mouse-goto-error] on error offset.")))))
 
 (defun preview-gs-flag-error (ov err)
   "Make an eps error flag in overlay OV for ERR string."
+  ;; N.B.  Although this code shows command line of gs invocation and
+  ;; error together via mouse popup menu, they are not necessarilly
+  ;; associated with each other.  There is a case that the command
+  ;; line is for "[...].prv/tmpXXXXXX/pr1-2.png" while the error is
+  ;; raised for "[...].prv/tmpXXXXXX/pr1-1.png".  (c.f. bug#37719)
   (let* ((filenames (overlay-get ov 'filenames))
         (file (car (nth 0 filenames)))
-        (outfile (format "-dOutputFile=%s"
-                         (preview-ps-quote-filename
+        ;; FIXME: This format isn't equal to actual invocation of gs
+        ;; command constructed in `preview-gs-restart', which
+        ;; contains "%d".
+        (outfile (format "-sOutputFile=%s"
+                         (file-relative-name
                           (car (nth 1 filenames)))))
         (ps-open
          `(lambda() (interactive "@")
@@ -1366,11 +1464,16 @@ This is for matching screen font size and previews."
 If packages, classes or styles were called with an option
 like 10pt, size is taken from the first such option if you
 had let your document be parsed by AucTeX."
-  (catch 'return (dolist (option (TeX-style-list))
-                  (if (string-match "\\`\\([0-9]+\\)pt\\'" option)
-                      (throw 'return
-                             (string-to-number
-                              (match-string 1 option)))))))
+  (let* ((regexp "\\`\\([0-9]+\\)pt\\'")
+        (option
+         (or
+          (LaTeX-match-class-option regexp)
+          ;; We don't have `LaTeX-match-package-option'.
+          (TeX-member regexp
+                      (apply #'append
+                             (mapcar #'cdr LaTeX-provided-package-options))
+                      #'string-match))))
+    (if option (string-to-number (match-string 1 option)))))
 
 (defsubst preview-document-pt ()
   "Calculate the default font size of document."
@@ -2214,7 +2317,7 @@ list of LaTeX commands is inserted just before 
\\begin{document}."
 (defcustom preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\
 \\PassOptionsToPackage{" ("," . preview-required-option-list) "}{preview}\
 \\AtBeginDocument{\\ifx\\ifPreview\\undefined"
-preview-default-preamble "\\fi}\"%' \"{\\detokenize{\" %t \"}}\"")
+preview-default-preamble "\\fi}\"%' \"\\detokenize{\" %t \"}\"")
   ;; Since TeXLive 2018, the default encoding for LaTeX files has been
   ;; changed to UTF-8 if used with classic TeX or pdfTeX.  I.e.,
   ;; \usepackage[utf8]{inputenc} is enabled by default in (pdf)latex.
@@ -2365,7 +2468,7 @@ filename=%s>
 
 (defun preview-TeX-style-cooked ()
   "Return `preview-TeX-style-dir' in cooked form.
-This will be fine for prepending to a `TEXINPUT' style
+This will be fine for prepending to a `TEXINPUTS' style
 environment variable, including an initial `.' at the front."
   (if (or (zerop (length preview-TeX-style-dir))
          (member (substring preview-TeX-style-dir -1) '(";" ":")))
@@ -2422,7 +2525,7 @@ systems, or `;' on Windows-like systems.  And it should be
 preceded with .: or .; accordingly in order to have . first in
 the search path.
 
-The `TEXINPUT' environment type variables will get this prepended
+The `TEXINPUTS' environment type variables will get this prepended
 at load time calling \\[preview-set-texinputs] to reflect this.
 You can permanently install the style files using
 \\[preview-install-styles].
@@ -2497,14 +2600,14 @@ to add the preview functionality."
        ["(or toggle) at point" preview-at-point]
        ["for environment" preview-environment]
        ["for section" preview-section]
-       ["for region" preview-region (preview-mark-active)]
+       ["for region" preview-region mark-active]
        ["for buffer" preview-buffer]
        ["for document" preview-document]
        "---"
        "Remove previews"
        ["at point" preview-clearout-at-point]
        ["from section" preview-clearout-section]
-       ["from region" preview-clearout (preview-mark-active)]
+       ["from region" preview-clearout mark-active]
        ["from buffer" preview-clearout-buffer]
        ["from document" preview-clearout-document]
        "---"
@@ -3290,7 +3393,7 @@ This is passed through `preview-do-replacements'."
   ;; Discard all other options.
   '(("\\`\\([^ ]+\\)\
 \\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^ 
\\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*.*\
- \"\\\\input\" \"{\\\\detokenize{\" \\(.*\\) \"}}\"\\'"
+ \"\\\\input\" \"\\\\detokenize{\" \\(.*\\) \"}\"\\'"
      . ("\\1 \\2 -interaction=nonstopmode -file-line-error "
        preview-format-name " \"/AUCTEXINPUT{\" \\3 \"}\"")))
   ;; See the ini file code below in `preview-cache-preamble' for the
@@ -3634,14 +3737,5 @@ If not a regular release, the date of the last change.")
 file exhibiting the problem might help."
      )))
 
-(eval-when-compile
-  (when (boundp 'preview-compatibility-macros)
-    (dolist (elt preview-compatibility-macros)
-      (if (consp elt)
-         (fset (car elt) (cdr elt))
-       (fmakunbound elt)))))
-
-(makunbound 'preview-compatibility-macros)
-
 (provide 'preview)
 ;;; preview.el ends here
diff --git a/prv-emacs.el b/prv-emacs.el
index fe0f8f9..0ccce7b 100644
--- a/prv-emacs.el
+++ b/prv-emacs.el
@@ -1,6 +1,6 @@
 ;;; prv-emacs.el --- GNU Emacs specific code for preview.el
 
-;; Copyright (C) 2001-2005, 2018  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2005, 2018, 2019  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: convenience, tex, wp
@@ -30,9 +30,6 @@
 (require 'tex)
 (require 'latex)
 
-(defvar preview-compatibility-macros nil
-  "List of macros only present when compiling/loading.")
-
 (defcustom preview-transparent-color '(highlight :background)
   "Color to appear transparent in previews.
 Set this to something unusual when using `preview-transparent-border',
@@ -568,10 +565,6 @@ The fourth value is the transparent border thickness."
       (setq mask nil))
     (vector bg fg mask preview-transparent-border)))
 
-(defmacro preview-mark-active ()
-  "Return t if the mark is active."
-  'mark-active)
-
 (defun preview-import-image (image)
   "Convert the printable IMAGE rendition back to an image."
   (cond ((stringp image)
diff --git a/style/AnonymousPro.el b/style/AnonymousPro.el
index a9a436b..c88a917 100644
--- a/style/AnonymousPro.el
+++ b/style/AnonymousPro.el
@@ -1,6 +1,6 @@
-;;; AnonymousPro.el --- AUCTeX style for `AnonymousPro.sty' (v2.1)
+;;; AnonymousPro.el --- AUCTeX style for `AnonymousPro.sty' (v2.2)
 
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,8 +26,8 @@
 
 ;;; Commentary:
 
-;; This file adds support for `AnonymousPro.sty' (v2.1) from
-;; 2014/03/22.  `AnonymousPro.sty' is part of TeXLive.
+;; This file adds support for `AnonymousPro.sty' (v2.2) from
+;; 2019/07/07.  `AnonymousPro.sty' is part of TeXLive.
 
 ;;; Code:
 
@@ -84,7 +84,7 @@
  LaTeX-dialect)
 
 (defvar LaTeX-AnonymousPro-package-options
-  '("ttdefault" "scale")
+  '("ttdefault" "scale" "scaled")
   "Package options for the AnonymousPro package.")
 
 ;;; AnonymousPro.el ends here
diff --git a/style/babel.el b/style/babel.el
index 52ee8ee..24d6cbb 100644
--- a/style/babel.el
+++ b/style/babel.el
@@ -1,6 +1,6 @@
-;;; babel.el --- AUCTeX style for `babel.sty' version 3.9h.
+;;; babel.el --- AUCTeX style for `babel.sty' version 3.31.
 
-;; Copyright (C) 2005, 2007, 2013-2014, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007, 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,13 +26,16 @@
 
 ;;; Commentary:
 
-;; This file adds support for `babel.sty' version 3.9h.
+;; This file adds support for `babel.sty' version 3.31 from 2019/05/04.
 
 ;;; Code:
 
 (eval-when-compile
   (require 'cl-lib))
 
+;; Needed for auto-parsing.
+(require 'tex)
+
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
                  "font-latex"
@@ -40,6 +43,7 @@
 
 (defvar LaTeX-babel-language-list
   '("afrikaans"
+    "azerbaijani"
     "bahasa" "indonesian" "indon" "bahasai" "bahasam" "malay" "meyalu"
     "basque"
     "breton"
@@ -85,9 +89,21 @@
     "albanian" "hindi" "thai" "thaicjk" "latvian" "turkmen" "hungarian" 
"magyar"
     "mongolian" "romansh" "lithuanian" "spanglish" "vietnamese" "japanese"
     "pinyin" "arabinc" "farsi" "ibygreek" "bgreek" "serbianic" "frenchle"
-    "ethiop" "friulan" "frenchb")
+    "ethiop" "friulan")
   "List of languages supported by the babel LaTeX package.")
 
+(defvar LaTeX-babel-babelprovide-key-val-options
+  `(("import")
+    ("captions")
+    ("hyphenrules" ,(append '("+") LaTeX-babel-language-list))
+    ("main")
+    ("script")
+    ("language")
+    ("mapfont")
+    ("intraspace")
+    ("intrapenalty"))
+  "Key=value options for `\\babelprovide' macro from `babel' package.")
+
 (defun LaTeX-babel-active-languages ()
   "Return a list of languages used in the document."
   (let (main-language active-languages)
@@ -117,13 +133,109 @@
            ;; except if it is set with the `main' option.
            (cl-pushnew elt active-languages :test #'equal))))
     (if main-language
-        (cl-pushnew main-language active-languages :test #'equal))
+       (cl-pushnew main-language active-languages :test #'equal))
     (nreverse active-languages)))
 
-(defun TeX-arg-babel-lang (_optional &optional _prompt)
+;; Setup for \babeltags: Note that the macro is \babeltags, we use
+;; the version without `s' in order to reduce the hassle with AUCTeX
+;; auto-generating the plural form:
+(TeX-auto-add-type "babel-babeltag" "LaTeX")
+
+(defvar LaTeX-babel-babeltags-regexp
+  '("\\\\babeltags{\\([^}]+\\)}" 1 LaTeX-auto-babel-babeltag)
+  "Matches the argument of `\\babeltags' from `babel' package.")
+
+(defun LaTeX-babel-cleanup-babeltags ()
+  "Parse defined babel tags and add them to AUCTeX."
+  ;; Check if we parsed something at all
+  (when (LaTeX-babel-babeltag-list)
+    (let (results tag tags cmds)
+      ;; Clean up the parsed results from characters we don't want;
+      ;; also remove possible comment lines
+      (setq results
+           (replace-regexp-in-string
+            "\\(%.*$\\|[ \n\r\t]\\)" ""
+            (mapconcat #'car (LaTeX-babel-babeltag-list) ",")))
+      ;; Look if \babeltags was issued once with multiple entries or
+      ;; more than once in the document:
+      (if (string-match-p "," results)
+         (progn
+           (dolist (elt (split-string results "," t))
+             (setq tag (car (split-string elt "=" t)))
+             (push tag tags)
+             (push (list (concat "text" tag) t) cmds)
+             (push (list tag -1) cmds)))
+       ;; One \babeltags with one entry only
+       (setq tag (car (split-string results "=" t)))
+       (push tag tags)
+       (push (list (concat "text" tag) t) cmds)
+       (push (list tag -1) cmds))
+      (mapc #'TeX-add-symbols cmds)
+      (mapc #'LaTeX-add-environments tags)
+      ;; Fontification
+      (when (and (featurep 'font-latex)
+                (eq TeX-install-font-lock 'font-latex-setup))
+       (font-latex-add-keywords (mapcar (lambda (x)
+                                          (list (concat "text" x)  "{"))
+                                        tags)
+                                'textual)
+       (font-latex-add-keywords (mapcar (lambda (x)
+                                          (list x  ""))
+                                        tags)
+                                'type-declaration)))))
+
+;; Setup for \babelfont:
+(TeX-auto-add-type "babel-babelfont" "LaTeX")
+
+(defvar LaTeX-babel-babelfont-regexp
+  '("\\\\babelfont\\(?:\\[[^]]*\\]\\)?[ \t\n\r%]*{\\([^}]+\\)}"
+    1 LaTeX-auto-babel-babelfont)
+  "Matches the <font-family> argument of `\\babelfont' from `babel' package.")
+
+(defun LaTeX-babel-cleanup-babelfont ()
+  "Parse defined font-families and add them to AUCTeX."
+  (when (LaTeX-babel-babelfont-list)
+    (dolist (elt (mapcar #'car (LaTeX-babel-babelfont-list)))
+      ;; Don't do anything for standard font-families:
+      (unless (member elt '("rm" "sf" "tt"))
+       ;; Define \<font>family, \<font>default and \text<font>:
+       (let ((fam (concat elt "family"))
+             (def (concat elt "default"))
+             (mac (concat "text" elt)))
+         (apply #'TeX-add-symbols
+                `((,fam -1)
+                  (,def -1)
+                  (,mac t)))
+         ;; Cater for fontification:
+         (when (and (featurep 'font-latex)
+                    (eq TeX-install-font-lock 'font-latex-setup))
+           (font-latex-add-keywords `((,fam "")
+                                      (,def ""))
+                                    'type-declaration)
+           (font-latex-add-keywords `((,mac "{"))
+                                    'type-command)))))))
+
+(defun LaTeX-babel-auto-prepare ()
+  "Clear `LaTeX-auto-babel-babel*' before parsing."
+  (setq LaTeX-auto-babel-babeltag  nil
+       LaTeX-auto-babel-babelfont nil))
+
+(defun LaTeX-babel-auto-cleanup ()
+  "Process parsed elements."
+  (LaTeX-babel-cleanup-babeltags)
+  (LaTeX-babel-cleanup-babelfont))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-babel-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-babel-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun TeX-arg-babel-lang (optional &optional prompt)
   "Prompt for a language with completion and insert it as an argument."
   (TeX-argument-insert
-   (completing-read "Language: " (LaTeX-babel-active-languages)) nil))
+   (completing-read
+    (TeX-argument-prompt optional prompt "Language")
+    (LaTeX-babel-active-languages))
+   optional))
 
 (defun LaTeX-env-babel-lang (env)
   "Prompt for a language and insert it as an argument of ENV."
@@ -135,46 +247,152 @@
   "Load style files of babel active languages."
   ;; Run style hooks for every active language in loading order, so
   ;; `TeX-quote-language' will be correctly set.
-  (mapc 'TeX-run-style-hooks (LaTeX-babel-active-languages)))
+  (mapc #'TeX-run-style-hooks (LaTeX-babel-active-languages)))
 
 (TeX-add-style-hook
  "babel"
  (lambda ()
    (LaTeX-babel-load-languages)
    (add-hook 'LaTeX-after-usepackage-hook 'LaTeX-babel-load-languages nil t)
+
+   ;; Add babel to the parser.
+   (TeX-auto-add-regexp LaTeX-babel-babeltags-regexp)
+   (TeX-auto-add-regexp LaTeX-babel-babelfont-regexp)
+
    ;; New symbols
    (TeX-add-symbols
+
+    ;; 1.7 Basic language selectors
     '("selectlanguage" TeX-arg-babel-lang)
     '("foreignlanguage" TeX-arg-babel-lang t)
-    "languagename"
-    '("iflanguage" TeX-arg-babel-lang t nil)
-    '("useshorthands" t)
-    '("defineshorthand" t nil)
-    '("aliasshorthand" t nil)
+
+    ;; 1.9 More on selection
+    '("babeltags" t)
+    '("babelensure" (TeX-arg-key-val
+                    (("include") ("exclude")
+                     ("fontenc" (;; 128+ glyph encodings (text)
+                                 "OT1" "OT2" "OT3" "OT4" "OT6"
+                                 ;; 256 glyph encodings (text)
+                                 "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
+                                 ;; 256 glyph encodings (text extended)
+                                 "X2"
+                                 ;; Other encodings
+                                 "LY1" "LV1" "LGR"))))
+      TeX-arg-babel-lang)
+    ;; 1.10 Shorthands
+    '("shorthandon"    "Shorthands list")
+    '("shorthandoff"   "Shorthands list")
+    '("shorthandoff*"  "Shorthands list")
+    '("useshorthands"  "Character")
+    '("useshorthands*" "Character")
+    '("defineshorthand"
+      [ TeX-arg-eval mapconcat #'identity
+                    (TeX-completing-read-multiple
+                     (TeX-argument-prompt optional nil "Language(s)")
+                     (LaTeX-babel-active-languages)) ""]
+      t nil)
+    '("aliasshorthand"   "Original" "Alias")
     '("languageshorthands" TeX-arg-babel-lang)
-    '("shorthandon" t)
-    '("shorthandoff" t)
+    '("babelshorthand"   "Short hand")
+    '("ifbabelshorthand" "Character" t nil)
+
+    ;; 1.12 The base option
+    '("AfterBabelLanguage"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Language")
+                   LaTeX-babel-language-list)
+      t)
+
+    ;; 1.14 Selecting fonts
+    '("babelfont"
+      [ TeX-arg-eval mapconcat #'identity
+                    (TeX-completing-read-multiple
+                     (TeX-argument-prompt optional nil "Language(s)")
+                     LaTeX-babel-language-list)
+                    "," ]
+      (TeX-arg-eval let ((fontfam (completing-read
+                                  (TeX-argument-prompt optional nil "font 
family")
+                                  '("rm" "sf" "tt"))))
+                   ;; Make sure `tex-buf.el' is also loaded otherwise
+                   ;; `TeX-check-engine-add-engines' is not defined.
+                   ;; Then load `fontspec.el' and make sure the
+                   ;; key-vals are up to date.
+                   (unless (member "fontspec" (TeX-style-list))
+                     (require 'tex-buf)
+                     (TeX-check-engine-add-engines 'luatex 'xetex)
+                     (TeX-run-style-hooks "fontspec")
+                     (LaTeX-fontspec-auto-cleanup))
+                   (LaTeX-add-babel-babelfonts fontfam)
+                   (LaTeX-babel-cleanup-babelfont)
+                   (format "%s" fontfam))
+      [ TeX-arg-key-val LaTeX-fontspec-font-features-local]
+      LaTeX-fontspec-arg-font)
+
+    ;; 1.16 Creating a language
+    '("babelprovide"
+      [ TeX-arg-key-val LaTeX-babel-babelprovide-key-val-options ]
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Language")
+                   LaTeX-babel-language-list))
+
+    ;; 1.18 Getting the current language name
+    '("languagename" 0)
+    '("iflanguage" TeX-arg-babel-lang t nil)
+
+    ;; 1.19 Hyphenation and line breaking
+    '("babelhyphen"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Type/Text")
+                   '("soft" "hard" "repeat" "empty")))
+    '("babelhyphen*"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Type/Text")
+                   '("soft" "hard" "repeat" "empty")))
+
+    '("babelhyphenation"
+      [ TeX-arg-eval mapconcat #'identity
+                    (TeX-completing-read-multiple
+                     (TeX-argument-prompt optional nil "Language(s)")
+                     LaTeX-babel-language-list)
+                    "," ]
+      t)
+
+    ;; 1.20 Selecting scripts
+    '("ensureascii" "Text")
+
+    ;; 1.22 Language attributes
     '("languageattribute" TeX-arg-babel-lang t))
-   ;; New environments
+
+   ;; New environments: 1.8 Auxiliary language selectors
    (LaTeX-add-environments
     '("otherlanguage" LaTeX-env-babel-lang)
     '("otherlanguage*" LaTeX-env-babel-lang)
     '("hyphenrules" LaTeX-env-babel-lang))
+
    ;; Fontification
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("selectlanguage" "{")
-                               ("foreignlanguage" "{{")
-                               ("iflanguage" "{{{")
-                               ("languagename" "")
-                               ("useshorthands" "{")
+     (font-latex-add-keywords '(("selectlanguage"     "{")
+                               ("foreignlanguage"    "{{")
+                               ("babeltags"          "{")
+                               ("babelensure"        "{{")
+                               ("shorthandon"        "{")
+                               ("shorthandoff"       "*{")
+                               ("useshorthands"      "*{")
                                ("languageshorthands" "{")
-                               ("shorthandon" "{")
-                               ("shorthandoff" "{"))
+                               ("babelshorthand"     "{")
+                               ("AfterBabelLanguage" "{")
+                               ("babelfont"          "[{[{")
+                               ("babelprovide"       "[{")
+                               ("languagename"       "")
+                               ("iflanguage"         "{{{")
+                               ("babelhyphen"        "*{")
+                               ("babelhyphenation"   "[{")
+                               ("ensureascii"        "{"))
                              'function)
-     (font-latex-add-keywords '(("defineshorthand" "{{")
-                               ("aliasshorthand" "{{")
-                               ("languageattribute" "{{"))
+     (font-latex-add-keywords '(("defineshorthand"    "[{{")
+                               ("aliasshorthand"     "{{")
+                               ("languageattribute"  "{{"))
                              'variable)))
  LaTeX-dialect)
 
@@ -186,17 +404,27 @@
     '(("KeepShorthandsActive")
       ("activeacute")
       ("activegrave")
-      ("shorthands")
+      ("shorthands" ("off"))
       ("safe" ("none" "ref" "bib"))
       ("math" ("active" "normal"))
       ("config")
       ("main" LaTeX-babel-language-list)
       ("headfoot" LaTeX-babel-language-list)
       ("noconfigs")
+      ("nocase")
+      ("silent")
       ("showlanguages")
-      ("strings" ("generic" "unicode" "encoded"))
+      ("nocase")
+      ("silent")
+      ("strings" ("generic" "unicode" "encoded"
+                 "OT1" "OT2" "OT3" "OT4" "OT6"
+                 "T1"  "T2A" "T2B" "T2C" "T3" "T4" "T5"
+                 "X2"  "LY1" "LV1" "LGR"))
       ("hyphenmap" ("off" "main" "select" "other" "other*"))
+      ("bidi" ("default" "basic" "basic-r" "bidi-l" "bidi-r"))
+      ("layout" ("sectioning" "counters" "lists" "captions"
+                "contents" "footnotes" "columns" "extras"))
       ("base"))
-    (mapcar 'list LaTeX-babel-language-list))))
+    (mapcar #'list LaTeX-babel-language-list))))
 
 ;;; babel.el ends here
diff --git a/style/beamer.el b/style/beamer.el
index fb69fc4..5de0d32 100644
--- a/style/beamer.el
+++ b/style/beamer.el
@@ -363,6 +363,7 @@ also be a string.  Then the length of the string is used."
 
 (defun LaTeX-beamer-class-options ()
   "Read the beamer class options from the user."
+  (TeX-load-style "hyperref")
   (TeX-read-key-val t '(("usepdftitle" ("false")) ("envcountsect")
                        ("notheorems") ("noamsthm") ("compress") ("t") ("c")
                        ("leqno") ("fleqn") ("handout") ("trans") ("pdftex")
diff --git a/tests/tex/path-expansion.el b/style/beamerarticle.el
similarity index 60%
copy from tests/tex/path-expansion.el
copy to style/beamerarticle.el
index 3a1d72e..2c5cff0 100644
--- a/tests/tex/path-expansion.el
+++ b/style/beamerarticle.el
@@ -1,6 +1,8 @@
-;;; path-expansion.el --- tests for path expansion
+;;; beamerarticle.el --- AUCTeX style for the latex-beamerarticle class
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2019 Free Software Foundation
+
+;; Keywords: tex
 
 ;; This file is part of AUCTeX.
 
@@ -19,17 +21,13 @@
 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 ;; 02110-1301, USA.
 
-;;; Code:
+;;; Commentary:
 
-(require 'ert)
+;; Triggers the beamer style when using the beamerarticle style.
 
-(ert-deftest TeX-variable-truncation ()
-  "Check whether list variable is not truncated as side effect."
-  (let ((var '("str1" "str2"))
-       (TeX-kpathsea-path-delimiter nil)
-       (TeX-search-files-type-alist
-        '((abc "${dummy}" ("str2" var) TeX-file-extensions))))
-    (TeX-search-files-by-type 'abc 'global)
-    (should (equal var '("str1" "str2")))))
+;;; Code:
 
-;;; command-expansion.el ends here
+(TeX-add-style-hook
+ "beamerarticle"
+ (lambda ()
+   (TeX-run-style-hooks "beamer")))
diff --git a/tests/tex/path-expansion.el b/style/beamerswitch.el
similarity index 60%
copy from tests/tex/path-expansion.el
copy to style/beamerswitch.el
index 3a1d72e..716d16d 100644
--- a/tests/tex/path-expansion.el
+++ b/style/beamerswitch.el
@@ -1,6 +1,8 @@
-;;; path-expansion.el --- tests for path expansion
+;;; beamerswitch.el --- AUCTeX style for the latex-beamerswitch class
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2019 Free Software Foundation
+
+;; Keywords: tex
 
 ;; This file is part of AUCTeX.
 
@@ -19,17 +21,13 @@
 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 ;; 02110-1301, USA.
 
-;;; Code:
+;;; Commentary:
 
-(require 'ert)
+;; Triggers the beamer style when using the beamerswitch style.
 
-(ert-deftest TeX-variable-truncation ()
-  "Check whether list variable is not truncated as side effect."
-  (let ((var '("str1" "str2"))
-       (TeX-kpathsea-path-delimiter nil)
-       (TeX-search-files-type-alist
-        '((abc "${dummy}" ("str2" var) TeX-file-extensions))))
-    (TeX-search-files-by-type 'abc 'global)
-    (should (equal var '("str1" "str2")))))
+;;; Code:
 
-;;; command-expansion.el ends here
+(TeX-add-style-hook
+ "beamerswitch"
+ (lambda ()
+   (TeX-run-style-hooks "beamer")))
diff --git a/style/bicaption.el b/style/bicaption.el
index 5dc4063..7bc0a35 100644
--- a/style/bicaption.el
+++ b/style/bicaption.el
@@ -1,6 +1,6 @@
 ;;; bicaption.el --- AUCTeX style for `bicaption.sty' (v1.1-158)
 
-;; Copyright (C) 2016--2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -34,8 +34,8 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'latex))
+;; Needed for compiling `LaTeX-check-insert-macro-default-style':
+(require 'latex)
 
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
@@ -122,7 +122,8 @@ arguments."
                     (completing-read (TeX-argument-prompt t nil "Width")
                                      (mapcar (lambda (elt) (concat TeX-esc 
(car elt)))
                                              (LaTeX-length-list)))))
-            (last-optional-rejected (and width (string= width "")))
+            (last-optional-rejected (or (not width)
+                                        (and width (string= width ""))))
             (inpos (LaTeX-check-insert-macro-default-style
                     (if (and width (not (string-equal width "")))
                         (completing-read (TeX-argument-prompt t nil "Inner 
position")
diff --git a/style/breqn.el b/style/breqn.el
index 63821f2..f22696c 100644
--- a/style/breqn.el
+++ b/style/breqn.el
@@ -1,6 +1,6 @@
 ;;; breqn.el --- AUCTeX style for `breqn.sty' (v0.98e)
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -48,6 +48,8 @@
 
 ;;; Code:
 
+(require 'latex)
+
 ;; Silence the compiler:
 (declare-function LaTeX-color-definecolor-list "color" ())
 (declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
@@ -77,15 +79,7 @@ The keys \"label\" and \"labelprefix\" are omitted.")
       "\\\\begin{"
       (regexp-opt '("dmath" "dseries" "dgroup" "darray"))
       "}"
-      "\\(?:\\[[^][]*"
-       "\\(?:{[^}{]*"
-         "\\(?:{[^}{]*"
-           "\\(?:{[^}{]*}[^}{]*\\)*"
-         "}[^}{]*\\)*"
-       "}[^][]*\\)*"
-      "label[ \t]*=[ \t]*{\\([^}]+\\)}"
-      "\\(?:[^]]*\\)*"
-      "\\]\\)")
+      (LaTeX-extract-key-value-label))
     1 LaTeX-auto-label)
   "Matches the label inside an optional argument after 
\\begin{<breqn-env's>}.")
 
diff --git a/style/caption.el b/style/caption.el
index c38c1fa..60e6e5a 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -1,6 +1,6 @@
 ;;; caption.el --- AUCTeX style for `caption.sty' (v3.3-111)
 
-;; Copyright (C) 2015--2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -35,8 +35,10 @@
 ;;; Code:
 
 (eval-when-compile
-  (require 'cl-lib)
-  (require 'latex))
+  (require 'cl-lib))
+
+;; Needed for compiling `LaTeX-check-insert-macro-default-style':
+(require 'latex)
 
 ;; Needed for auto-parsing:
 (require 'tex)
@@ -271,7 +273,8 @@ caption, insert only a caption."
                 (completing-read (TeX-argument-prompt t nil "Width")
                                  (mapcar (lambda (elt) (concat TeX-esc (car 
elt)))
                                          (LaTeX-length-list)))))
-        (last-optional-rejected (and width (string= width "")))
+        (last-optional-rejected (or (not width)
+                                    (and width (string= width ""))))
         (inpos (LaTeX-check-insert-macro-default-style
                 (if (and width (not (string-equal width "")))
                     (completing-read (TeX-argument-prompt t nil "Inner 
position")
diff --git a/style/changelog.el b/style/changelog.el
new file mode 100644
index 0000000..feaa9dd
--- /dev/null
+++ b/style/changelog.el
@@ -0,0 +1,159 @@
+;;; changelog.el --- AUCTeX style for `changelog.sty' (v2.0.0)
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2019-05-05
+;; 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 `changelog.sty' (v2.0.0).
+;; `changelog.sty' is part of TeXLive.
+
+;;; Code:
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                 "font-latex"
+                 (keywords class))
+
+(defvar LaTeX-changelog-env-key-val-options
+  '(("section" ("true" "false"))
+    ("title"))
+  "Key=value options for changelog environment.
+The keys sectioncmd and label are added in the function
+`LaTeX-env-changelog'.")
+
+(defvar LaTeX-changelog-version-env-key-val-options
+  '(("version")
+    ("v")
+    ("author")
+    ("date")
+    ("yanked" ("true" "false"))
+    ("simple" ("true" "false"))
+    ("short"  ("true" "false")))
+  "key=value options for version environment.")
+
+(defun LaTeX-env-changelog (environment)
+  "Insert ENVIRONMENT, ask for optional argument and insert a label."
+  (let* ((seccmds (mapcar #'car LaTeX-section-list))
+        ;; Collect the key=vals acc. to environment & documentclass
+        (opts (TeX-read-key-val
+               t
+               (if (string= environment "changelog")
+                   (append
+                    `(("sectioncmd"
+                       ,(if (< (LaTeX-largest-level) 2)
+                            (append
+                             (mapcar (lambda (cmd) (concat TeX-esc cmd))
+                                     seccmds)
+                             (mapcar (lambda (cmd) (concat TeX-esc cmd "*"))
+                                     seccmds))
+                          (append
+                           (mapcar (lambda (cmd) (concat TeX-esc cmd))
+                                   (remove "chapter" seccmds))
+                           (mapcar (lambda (cmd) (concat TeX-esc cmd "*"))
+                                   (remove "chapter" seccmds))))))
+                    LaTeX-changelog-env-key-val-options
+                    LaTeX-changelog-version-env-key-val-options)
+                 LaTeX-changelog-version-env-key-val-options)))
+        ;; Extract the chosen sectioning command
+        (sec (progn
+               (string-match "sectioncmd=\\\\\\([a-z]+\\)\\(\\*?\\)" opts)
+               (match-string-no-properties 1 opts)))
+        ;; Temp. re-bind `LaTeX-label-alist' and pick the label
+        ;; prefix from `LaTeX-section-label'
+        (LaTeX-label-alist
+         (when (and (string= environment "changelog")
+                    (match-string 2 opts)
+                    (not (string= (match-string 2 opts) "*")))
+           `(,(cons environment
+                    (cdr (assoc sec LaTeX-section-label))))))
+        ;; Temp. re-bind `reftex-label-alist' as well and make
+        ;; `reftex-label' DTRT:
+        (reftex-label-alist
+         (when (and (boundp 'reftex-label-alist)
+                    LaTeX-label-alist
+                    (string= environment "changelog"))
+           `((,environment ?s ,(cdr (assoc sec LaTeX-section-label)) nil t)))))
+    (LaTeX-insert-environment
+     environment
+     (when (and opts (not (string= opts "")))
+       (concat LaTeX-optop opts LaTeX-optcl)))
+    ;; Add a label into the opt. argument
+    (when (string= environment "changelog")
+      (LaTeX-env-label-as-keyval nil "sectioncmd" nil environment))
+    ;; Add an \item in version environment
+    (when (string= environment "version")
+      (TeX-insert-macro "item")
+      (indent-according-to-mode))))
+
+(TeX-add-style-hook
+ "changelog"
+ (lambda ()
+
+   (LaTeX-add-environments
+    '("changelog" LaTeX-env-changelog)
+    '("version"   LaTeX-env-changelog))
+
+   (TeX-add-symbols
+    '("added"      0)
+    '("changed"    0)
+    '("deprecated" 0)
+    '("removed"    0)
+    '("fixed"      0)
+    '("security"   0)
+    `("shortversion" (TeX-arg-key-val
+                     ,(append
+                       '(("changes"))
+                       LaTeX-changelog-version-env-key-val-options))))
+
+   ;; Tell RefTeX that the optional arg of changelog env. can contain a label:
+   (when (and (boundp 'reftex-label-regexps)
+             (fboundp 'reftex-compile-variables)
+             (not (string-match  "\\bchangelog\\b"
+                                 (mapconcat #'identity
+                                            reftex-label-regexps
+                                            "|"))))
+     (add-to-list (make-local-variable 'reftex-label-regexps)
+                 (concat "\\\\begin{changelog}"
+                         (LaTeX-extract-key-value-label nil 1))
+                 t)
+     (reftex-compile-variables))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("added"        "")
+                               ("changed"      "")
+                               ("deprecated"   "")
+                               ("removed"      "")
+                               ("fixed"        "")
+                               ("security"     "")
+                               ("shortversion" "{"))
+                             'function)))
+ LaTeX-dialect)
+
+(defvar LaTeX-changelog-package-options nil
+  "Package options for the changelog package.")
+
+;;; changelog.el ends here
diff --git a/style/cleveref.el b/style/cleveref.el
index 2774dcb..290bc2f 100644
--- a/style/cleveref.el
+++ b/style/cleveref.el
@@ -1,6 +1,6 @@
-;;; cleveref.el --- Style hook for the `cleveref.sty' package.
+;;; cleveref.el --- AUCTeX style for `cleveref.sty' (v0.21.4)
 
-;; Copyright (C) 2014--2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014--2019 Free Software Foundation, Inc.
 
 ;; Author: Matthew Leach <address@hidden>
 ;; Maintainer: address@hidden
@@ -23,6 +23,11 @@
 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 ;; 02110-1301, USA.
 
+;;; Commentary:
+
+;; This file adds support for `cleveref.sty' (v0.21.4), dated
+;; 2018/03/27.
+
 ;;; Code
 
 ;; Silence the compiler:
@@ -47,22 +52,41 @@ string."
           (labels-string (mapconcat #'identity labels ",")))
       (TeX-argument-insert labels-string optional))))
 
+(defun TeX-arg-cleveref-crossref-type (optional &optional prompt)
+  "Insert the cross-reference type for macros of cleveref package.
+If OPTIONAL is non-nil, insert the resulting value in brackets.
+Use PROMPT as the prompt string."
+  (let* ((type (mapcar #'list
+                      '("appendix" "subappendix" "subsubappendix"
+                        "subsubsubappendix" "subfigure" "subtable"
+                        "subequation")))
+        (types (append (LaTeX-counter-list) type)))
+    (TeX-argument-insert
+     (completing-read (TeX-argument-prompt optional prompt "Type") types)
+     optional)))
+
+(defvar LaTeX-cleveref-label-regexp
+  '("\\\\label\\[[^]]*\\]{\\([^\n\r%\\{}]+\\)}" 1 LaTeX-auto-label)
+  "Regexp matching a \\label incl. an optional argument.")
+
 (TeX-add-style-hook
  "cleveref"
  (lambda ()
+
    (TeX-add-symbols
+    ;; 4 Typesetting Cross-References
     '("cref" TeX-arg-cleveref-multiple-labels)
     '("Cref" TeX-arg-cleveref-multiple-labels)
     '("crefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
     '("Crefrange" (TeX-arg-ref "key (first)") (TeX-arg-ref "Key (last)"))
-    '("cpageref" TeX-arg-cleveref-multiple-labels)
-    '("Cpageref" TeX-arg-cleveref-multiple-labels)
-    '("cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
-    '("Cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
     '("cref*" TeX-arg-cleveref-multiple-labels)
     '("Cref*" TeX-arg-cleveref-multiple-labels)
     '("crefrange*" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
     '("Crefrange*" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
+    '("cpageref" TeX-arg-cleveref-multiple-labels)
+    '("Cpageref" TeX-arg-cleveref-multiple-labels)
+    '("cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
+    '("Cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
     '("namecref" TeX-arg-ref)
     '("nameCref" TeX-arg-ref)
     '("lcnamecref" TeX-arg-ref)
@@ -70,35 +94,100 @@ string."
     '("nameCrefs" TeX-arg-ref)
     '("lcnamecrefs" TeX-arg-ref)
     '("labelcref" TeX-arg-cleveref-multiple-labels)
-    '("labelcpageref" TeX-arg-cleveref-multiple-labels))
+    '("labelcpageref" TeX-arg-cleveref-multiple-labels)
+    ;; 6 Overriding the Cross-Reference Type
+    '("crefalias" TeX-arg-counter "Type")
+    '("label" [ TeX-arg-cleveref-crossref-type ] TeX-arg-define-label)
+
+    ;; 8.1.1 Global Customisation
+    '("crefdefaultlabelformat" t)
+
+    ;; 8.1.2 Customising Individual Cross-Reference Types
+    '("crefname" TeX-arg-cleveref-crossref-type
+      "Singular name" "Plural name")
+    '("Crefname" TeX-arg-cleveref-crossref-type
+      "Singular name" "Plural name")
+    '("creflabelformat" TeX-arg-cleveref-crossref-type t)
+    '("crefrangelabelformat" TeX-arg-cleveref-crossref-type t)
+
+    ;; 8.2.1 Single Cross-References
+    '("crefformat" TeX-arg-cleveref-crossref-type t)
+    '("Crefformat" TeX-arg-cleveref-crossref-type t)
+
+    ;; 8.2.2 Reference Ranges
+    '("crefrangeformat" TeX-arg-cleveref-crossref-type t)
+    '("Crefrangeformat" TeX-arg-cleveref-crossref-type t)
+
+    ;; 8.2.3 Multiple Cross-References
+    '("crefmultiformat"      TeX-arg-cleveref-crossref-type 4)
+    '("Crefmultiformat"      TeX-arg-cleveref-crossref-type 4)
+    '("crefrangemultiformat" TeX-arg-cleveref-crossref-type 4)
+    '("Crefrangemultiformat" TeX-arg-cleveref-crossref-type 4))
 
    ;; These macros aren't used particularly often during the course of
    ;; normal referencing.
    (TeX-declare-expert-macros
     "cleveref"
     "namecref" "nameCref" "lcnamecref" "namecrefs" "nameCrefs"
-    "lcnamecrefs" "labelcref" "labelcpageref")
+    "lcnamecrefs" "labelcref" "labelcpageref"
+    "crefdefaultlabelformat"
+    "crefname" "Crefname" "creflabelformat" "crefrangelabelformat"
+    "crefformat" "Crefformat"
+    "crefrangeformat" "Crefrangeformat"
+    "crefmultiformat" "Crefmultiformat"
+    "crefrangemultiformat" "Crefrangemultiformat")
+
+   ;; Add \label[type]{label} to AUCTeX parser
+   (TeX-auto-add-regexp LaTeX-cleveref-label-regexp)
+
+   ;; Tell RefTeX.  Check if `reftex-label-regexps' is bound and use a
+   ;; local version of it.  Check if the regexp is already added in
+   ;; order not to run `reftex-compile-variables' every time the style
+   ;; hook runs
+   (when (and (boundp 'reftex-label-regexps)
+             (fboundp 'reftex-compile-variables))
+     (let ((regexp "\\\\label\\[[^]]*\\]{\\(?1:[^\n\r%\\{}]+\\)}"))
+       (unless (member regexp reftex-label-regexps)
+        (add-to-list (make-local-variable 'reftex-label-regexps)
+                     regexp t)
+        (reftex-compile-variables))))
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("cref" "*{")
-                               ("Cref" "*{")
-                               ("crefrange" "*{{")
-                               ("Crefrange" "*{{")
-                                ("cpageref" "{")
-                                ("Cpageref" "{")
-                                ("cpagerefrange" "{{")
-                                ("Cpagerefrange" "{{")
-                                ("namecref" "{")
-                                ("nameCref" "{")
-                                ("lcnamecref" "{")
-                                ("namecrefs" "{")
-                                ("nameCrefs" "{")
-                                ("lcnamecrefs" "{")
-                                ("labelcref" "{")
-                                ("labelcpageref" "{"))
-                             'reference))
+     (font-latex-add-keywords '(("cref"          "*{")
+                               ("Cref"          "*{")
+                               ("crefrange"     "*{{")
+                               ("Crefrange"     "*{{")
+                               ("cpageref"      "{")
+                               ("Cpageref"      "{")
+                               ("cpagerefrange" "{{")
+                               ("Cpagerefrange" "{{")
+                               ("namecref"      "{")
+                               ("nameCref"      "{")
+                               ("lcnamecref"    "{")
+                               ("namecrefs"     "{")
+                               ("nameCrefs"     "{")
+                               ("lcnamecrefs"   "{")
+                               ("labelcref"     "{")
+                               ("labelcpageref" "{")
+                               ("label"         "[{"))
+                             'reference)
+     (font-latex-add-keywords '(("crefalias"              "{{")
+                               ("crefname"               "{{{")
+                               ("Crefname"               "{{{")
+                               ("creflabelformat"        "{{")
+                               ("crefrangelabelformat"   "{{")
+                               ("crefdefaultlabelformat" "{")
+                               ("crefformat"             "{{")
+                               ("Crefformat"             "{{")
+                               ("crefrangeformat"        "{{")
+                               ("Crefrangeformat"        "{{")
+                               ("crefmultiformat"        "{{{{{")
+                               ("Crefmultiformat"        "{{{{{")
+                               ("crefrangemultiformat"   "{{{{{")
+                               ("Crefrangemultiformat"   "{{{{{"))
+                             'function))
 
    ;; Activate RefTeX reference style.
    (and LaTeX-reftex-ref-style-auto-activate
@@ -108,6 +197,6 @@ string."
 
 (defvar LaTeX-cleveref-package-options
   '("capitalise" "nameinlink" "noabbrev" "poorman")
-    "Package options for the cleveref package.")
+  "Package options for the cleveref package.")
 
 ;;; cleveref.el ends here.
diff --git a/style/color.el b/style/color.el
index 30e575e..f8f850a 100644
--- a/style/color.el
+++ b/style/color.el
@@ -1,6 +1,6 @@
 ;;; color.el --- AUCTeX style for `color.sty' (v1.1a)
 
-;; Copyright (C) 2015--2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -34,8 +34,8 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'latex))
+;; Needed for compiling `LaTeX-check-insert-macro-default-style':
+(require 'latex)
 
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
diff --git a/style/expl3.el b/style/expl3.el
index c1bb029..1ee605e 100644
--- a/style/expl3.el
+++ b/style/expl3.el
@@ -1,6 +1,6 @@
 ;;; expl3.el --- AUCTeX style for `expl3.sty'
 
-;; Copyright (C) 2015, 2017, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Tassilo Horn <address@hidden>
 ;; Maintainer: address@hidden
@@ -35,6 +35,8 @@
                  "font-latex"
                  (&optional syntactic-kws))
 
+(defvar font-latex-match-simple-include-list)
+
 (defvar LaTeX-expl3-syntax-table
   (let ((st (copy-syntax-table LaTeX-mode-syntax-table)))
     ;; Make _ and : symbol chars
@@ -48,6 +50,9 @@
    (set-syntax-table LaTeX-expl3-syntax-table)
    (when (and (fboundp 'font-latex-update-font-lock)
              (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)))
  LaTeX-dialect)
diff --git a/style/fancyvrb.el b/style/fancyvrb.el
index 32adcd4..1354e3b 100644
--- a/style/fancyvrb.el
+++ b/style/fancyvrb.el
@@ -45,6 +45,7 @@
 
 ;; Needed for auto-parsing:
 (require 'tex)
+(require 'latex)
 
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
@@ -129,14 +130,7 @@ Starred versions are not included in this list.")
 Starred versions are not included in this list.")
 
 (defvar LaTeX-fancyvrb-key-val-skip-regexp
-  (concat
-   "\\(?:\\[[^][]*"
-     "\\(?:{[^}{]*"
-       "\\(?:{[^}{]*"
-        "\\(?:{[^}{]*}[^}{]*\\)*"
-       "}[^}{]*\\)*"
-     "}[^][]*\\)*"
-   "\\]\\)?")
+  (concat "\\(?:" (LaTeX-extract-key-value-label 'none) "\\)?")
   "Helper regexp to skip over an optional argument.")
 
 ;; Setup for defining new Verbatim commands:
diff --git a/style/floatrow.el b/style/floatrow.el
index baad7cf..57f58c7 100644
--- a/style/floatrow.el
+++ b/style/floatrow.el
@@ -1,6 +1,6 @@
 ;;; floatrow.el --- AUCTeX style for `floatrow.sty' (v0.3b)
 
-;; Copyright (C) 2017, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -58,10 +58,12 @@
 
 ;;; Code:
 
-;; Needed for compiling `cl-pushnew' & 
`LaTeX-check-insert-macro-default-style':
+;; Needed for compiling `cl-pushnew':
 (eval-when-compile
-  (require 'cl-lib)
-  (require 'latex))
+  (require 'cl-lib))
+
+;; Needed for compiling `LaTeX-check-insert-macro-default-style':
+(require 'latex)
 
 ;; Needed for auto-parsing:
 (require 'tex)
@@ -353,13 +355,15 @@ If OPTIONAL is non-nil, indicate optional argument during 
query."
                  (TeX-argument-prompt t nil "Width")
                  (mapcar (lambda (x) (concat TeX-esc (car x)))
                          (LaTeX-length-list)))))
-        (last-optional-rejected (and width (string= width "")))
+        (last-optional-rejected (or (not width)
+                                    (and width (string= width ""))))
         (height (LaTeX-check-insert-macro-default-style
                  (completing-read
                   (TeX-argument-prompt t nil "Height")
                   (mapcar (lambda (x) (concat TeX-esc (car x)))
                           (LaTeX-length-list)))))
-        (last-optional-rejected (and height (string= height "")))
+        (last-optional-rejected (or (not height)
+                                    (and height (string= height ""))))
         (vertpos (LaTeX-check-insert-macro-default-style
                   (if (string= height "")
                       ""
@@ -372,8 +376,8 @@ If OPTIONAL is non-nil, indicate optional argument during 
query."
     (when (and width (string= width "")
               height (not (string= height "")))
       (insert "[]"))
-    (and (TeX-argument-insert height t))
-    (and (TeX-argument-insert vertpos t)))
+    (and height (TeX-argument-insert height t))
+    (and vertpos (TeX-argument-insert vertpos t)))
   ;; Now query for the (short-)caption.  Also check for the
   ;; float-type; if we're inside (sub)?floatrow*?, then check for the
   ;; next outer environment:
diff --git a/style/fontspec.el b/style/fontspec.el
index 03e5178..0688e98 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -215,7 +215,7 @@ to retrieve the list of fonts."
     (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
                         #'LaTeX-xcolor-definecolor-list
                       #'LaTeX-color-definecolor-list))
-          (tmp (copy-alist LaTeX-fontspec-font-features-local)))
+          (tmp (copy-alist LaTeX-fontspec-font-features)))
       (setq tmp (assq-delete-all (car (assoc "Color" tmp)) tmp))
       (push (list "Color" (mapcar #'car (funcall colorcmd))) tmp)
       (setq LaTeX-fontspec-font-features-local
diff --git a/style/fvextra.el b/style/fvextra.el
index e5f5d19..4e817ee 100644
--- a/style/fvextra.el
+++ b/style/fvextra.el
@@ -1,6 +1,6 @@
-;;; fvextra.el --- AUCTeX style for `fvextra.sty' (v1.2.1)
+;;; fvextra.el --- AUCTeX style for `fvextra.sty' (v1.4)
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017, 2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `fvextra.sty' (v1.2.1) from 2016/09/02.
+;; This file adds support for `fvextra.sty' (v1.4) from 2019/02/04.
 ;; `fvextra.sty' is part of TeXLive.
 
 ;;; Code:
@@ -35,27 +35,50 @@
 (eval-when-compile
   (require 'cl-lib))
 
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                 "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" ())
 
+;; Defined in fancyvrb.el:
 (defvar LaTeX-fancyvrb-key-val-options-local)
 
 (defvar LaTeX-fvextra-key-val-options
   '(;; 3 General options
+    ("beameroverlays" ("true" "false"))
     ("curlyquotes" ("true" "false"))
+    ("extra" ("true" "false"))
+    ("fontencoding" (;; Reset to default document font encoding
+                    "none"
+                    ;; 128+ glyph encodings (text)
+                    "OT1" "OT2" "OT3" "OT4" "OT6"
+                    ;; 256 glyph encodings (text)
+                    "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
+                    ;; 256 glyph encodings (text extended)
+                    "X2"
+                    ;; Other encodings
+                    "LY1" "LV1" "LGR"))
     ("highlightcolor")
     ("highlightlines")
     ("linenos" ("true" "false"))
     ("mathescape" ("true" "false"))
     ("numberfirstline" ("true" "false"))
     ;; ("numbers" ("none" "left" "right" "both"))
+    ("retokenize" ("true" "false"))
     ("space" ("\\textvisiblespace"))
     ("spacecolor" ("none"))
     ("stepnumberfromfirst" ("true" "false"))
     ("stepnumberoffsetvalues" ("true" "false"))
     ("tab" ("\\FancyVerbTab"))
     ("tabcolor" ("none"))
-    ;; 5.1 Line breaking options
+    ;; 7.1 Line breaking options
     ("breakafter" ("none"))
     ("breakaftergroup" ("true" "false"))
     ("breakaftersymbolpre")
@@ -69,16 +92,23 @@
     ("breakbeforesymbolpre")
     ("breakbeforesymbolpost")
     ("breakindent")
+    ("breakindentnchars")
     ("breaklines" ("true" "false"))
     ("breaksymbol")
     ("breaksymbolleft")
     ("breaksymbolright")
     ("breaksymbolindent")
+    ("breaksymbolindentnchars")
     ("breaksymbolindentleft")
+    ("breaksymbolindentleftnchars")
     ("breaksymbolindentright")
+    ("breaksymbolindentrightnchars")
     ("breaksymbolsep")
+    ("breaksymbolsepnchars")
     ("breaksymbolsepleft")
-    ("breaksymbolsepright"))
+    ("breaksymbolsepleftnchars")
+    ("breaksymbolsepright")
+    ("breaksymbolseprightnchars"))
   "Key=value options for fvextra macros and environments.")
 
 (defun LaTeX-fvextra-update-key-val ()
@@ -126,17 +156,43 @@
                 LaTeX-fancyvrb-key-val-options-local))
 
    (TeX-add-symbols
-    ;; 4.1 Line and text formatting
+    ;; 4.1 Inline formatting with \fvinlineset
+    '("fvinlineset" (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
+
+    ;; 4.2 Line and text formatting
     "FancyVerbFormatText"
 
-    ;; 5.3.2 Breaks within macro arguments
+    ;; 6 New commands and environments
+    ;; 6.1 \EscVerb
+    '("EscVerb"
+      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] "Text")
+    '("EscVerb*"
+      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] "Text")
+
+    ;; 7.3.2 Breaks within macro arguments
     "FancyVerbBreakStart"
     "FancyVerbBreakStop"
 
-    ;; 5.3.3 Customizing break behavior
+    ;; 7.3.3 Customizing break behavior
     "FancyVerbBreakAnywhereBreak"
     "FancyVerbBreakBeforeBreak"
-    "FancyVerbBreakAfterBreak"))
+    "FancyVerbBreakAfterBreak")
+
+   ;; Add \EscVerb*? to `LaTeX-verbatim-macros-with-braces-local':
+   (add-to-list 'LaTeX-verbatim-macros-with-braces-local
+               "EscVerb" t)
+   (add-to-list 'LaTeX-verbatim-macros-with-braces-local
+               "EscVerb*" t)
+
+   ;; 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)) )
  LaTeX-dialect)
 
 (defvar LaTeX-fvextra-package-options nil
diff --git a/style/hyperref.el b/style/hyperref.el
index 02d886e..3b25491 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--2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2013--2019 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -35,6 +35,10 @@
                  "font-latex"
                  (keywords class))
 
+(declare-function font-latex-update-font-lock
+                 "font-latex"
+                 (&optional syntactic-kws))
+
 (defvar LaTeX-hyperref-package-options-list
   '(;; See https://www.tug.org/applications/hyperref/manual.html#x1-40003
     ;; General options
@@ -286,6 +290,7 @@
    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperbaseurl")
    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperimage")
    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperref")
+   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "href")
 
    ;; In hyperref package, \url macro is redefined and \url|...| can't be used,
    ;; while it's possible when only url package (required by hyperref) is 
loaded
@@ -293,8 +298,7 @@
         (remove "url"  LaTeX-verbatim-macros-with-delims-local))
 
    ;; Fontification
-   (when (and (fboundp 'font-latex-add-keywords)
-             (fboundp 'font-latex-set-syntactic-keywords)
+   (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("href" "[{{")
                                ("nolinkurl" "{")
@@ -312,7 +316,7 @@
      (font-latex-add-keywords '(("hypersetup" "{"))
                              'function)
      ;; For syntactic fontification, e.g. verbatim constructs.
-     (font-latex-set-syntactic-keywords))
+     (font-latex-update-font-lock t))
 
    ;; Option management
    (if (and (LaTeX-provided-package-options-member "hyperref" "dvipdfmx")
diff --git a/style/listings.el b/style/listings.el
index c488c51..5c20308 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-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2009, 2013--2019 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -46,6 +46,10 @@
 (eval-when-compile
   (require 'cl-lib))
 
+;; Needed for auto-parsing:
+(require 'tex)
+(require 'latex)
+
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
                  "font-latex"
@@ -270,22 +274,9 @@ from `listings' package.")
 
 ;; Setup for parsing the labels inside optional arguments:
 
-(defvar LaTeX-listings-key-val-label-extract
-  (concat
-   "\\(?:\\[[^][]*"
-     "\\(?:{[^}{]*"
-       "\\(?:{[^}{]*"
-        "\\(?:{[^}{]*}[^}{]*\\)*"
-       "}[^}{]*\\)*"
-     "}[^][]*\\)*"
-   "label[ \t]*=[ \t]*{\\([^}]+\\)}"
-   "\\(?:[^]]*\\)*"
-   "\\]\\)")
-  "Helper regexp to extract the label out of optional argument.")
-
 (defvar LaTeX-listings-key-val-label-regexp
   `(,(concat
-      "\\\\begin{lstlisting}" LaTeX-listings-key-val-label-extract)
+      "\\\\begin{lstlisting}" (LaTeX-extract-key-value-label))
     1 LaTeX-auto-label)
   "Matches the label inside an optional argument after \\begin{lstlisting}.")
 
@@ -335,7 +326,7 @@ with user-defined values via the \"lstdefinestyle\" macro."
       (add-to-list 'LaTeX-label-alist `(,env . LaTeX-listing-label) t)
       ;; Add new env to parser for labels in opt. argument:
       (TeX-auto-add-regexp `(,(concat "\\\\begin{" env "}"
-                                     LaTeX-listings-key-val-label-extract)
+                                     (LaTeX-extract-key-value-label))
                             1 LaTeX-auto-label))
       ;; Tell RefTeX
       (when (fboundp 'reftex-add-label-environments)
diff --git a/style/ltugboat.el b/style/ltugboat.el
new file mode 100644
index 0000000..4f9e9f6
--- /dev/null
+++ b/style/ltugboat.el
@@ -0,0 +1,283 @@
+;;; ltugboat.el --- AUCTeX style for `ltugboat.cls' (v2.21)
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2019-05-11
+;; 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 `ltugboat.cls' (v2.21) from 2018/12/14.
+;; `ltugboat.cls' is part of TeXLive.
+
+;;; Code:
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                 "font-latex"
+                 (keywords class))
+
+(defun LaTeX-env-ltugboat-verbatim (environment)
+  "Insert verbatim environment with an optional argument."
+  (let* ((crm-separator (regexp-quote TeX-esc))
+        (opts (mapconcat #'identity
+                         (TeX-completing-read-multiple
+                          (TeX-argument-prompt t nil "command(s)")
+                          '("\\tiny"  "\\scriptsize" "\\footnotesize"
+                            "\\small" "\\normalsize" "\\large"
+                            "\\Large" "\\LARGE"      "\\huge"
+                            "\\Huge"  "\\makevmeta"  "\\ruled")
+                          nil nil TeX-esc)
+                         TeX-esc)))
+    (LaTeX-insert-environment environment
+                             (when (and opts
+                                        (not (string= opts "")))
+                               (concat LaTeX-optop opts LaTeX-optcl)))))
+
+(TeX-add-style-hook
+ "ltugboat"
+ (lambda ()
+
+   ;; Run the style hook for mflogo in order to define the macros \MF
+   ;; and \MP:
+   (TeX-run-style-hooks "mflogo")
+
+   ;; Preliminaries: ltugboat.cls suppresses \part & \subparagraph
+   (LaTeX-largest-level-set "section")
+   (LaTeX-add-counters "section" "subsection" "subsubsection" "paragraph"
+                      "figure" "table")
+
+   ;; 6 Divisions of the paper
+   (TeX-add-symbols
+    '("nameref" TeX-arg-ref))
+
+   (setq TeX-complete-list
+        (append
+         '(("\\\\nameref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}"))
+         TeX-complete-list))
+
+   ;; 6.1 Abstracts
+   (LaTeX-add-environments '("abstract")
+                          '("longabstract"))
+
+   ;; 6.2 Appendices: Cater for appendix environment and don't indent
+   ;; the content
+   (LaTeX-add-environments '("appendix"))
+
+   (unless (string-match-p "appendix" LaTeX-document-regexp)
+     (set (make-local-variable 'LaTeX-document-regexp)
+         (concat LaTeX-document-regexp "\\|" "appendix")))
+
+   (TeX-add-symbols
+    ;; 7 Titles, addresses and so on
+    '("shortTitle"  "Short title")
+    '("shortAuthor" LaTeX-arg-author)
+    '("address"     "Address")
+    '("netaddress"  "Email address")
+    '("personalURL" "Web page")
+    '("ORCID"       "Digital identifier")
+
+    ;; 7.1 Compilation articles
+    '("contributor" "Contributor")
+    '("makesignature" 0))
+
+   ;; 8 Verbatim text
+   (LaTeX-add-environments
+    '("verbatim" LaTeX-env-ltugboat-verbatim))
+
+   ;; 10.1 Acronyms and logos
+   (TeX-add-symbols
+    '("acro" "Acronym")
+    "AMS"
+    "AmS"
+    "AmSLaTeX"
+    "AmSTeX"
+    "ANSI"
+    "API"
+    "ASCII"
+    "aw"
+    "AW"
+    "BibLaTeX"
+    "BibTeX"
+    "BSD"
+    "CandT"
+    "ConTeXt"
+    "CMkIV"
+    "Cplusplus"
+    "CPU"
+    "CSczabbr"
+    "CSS"
+    "CSTUG"
+    "CSV"
+    "CTAN"
+    "DTD"
+    "DTK"
+    "DVD"
+    "DVI"
+    "DVIPDFMx"
+    "DVItoVDU"
+    "ECMS"
+    "EPS"
+    "eTeX"
+    "ExTeX"
+    "FAQ"
+    "FTP"
+    "Ghostscript"
+    "GNU"
+    "GUI"
+    "Hawaii"
+    "HTML"
+    "HTTP"
+    "IDE"
+    "IEEE"
+    "ISBN"
+    "ISO"
+    "ISSN"
+    "JPEG"
+    "JTeX"
+    "JoT"
+    "KOMAScript"
+    "LAMSTeX"
+    "LyX"
+    "MacOSX"
+    "MathML"
+    "mf"
+    "MFB"
+    "MkIV"
+    "mp"
+    "NTG"
+    "NTS"
+    "OMEGA"
+    "OCP"
+    "OOXML"
+    "OTF"
+    "OTP"
+    "mtex"
+    "Pas"
+    "pcMF"
+    "PCteX"
+    "pcTeX"
+    "PDF"
+    "PGF"
+    "PHP"
+    "PiCTeX"
+    "plain"
+    "PNG"
+    "POBox"
+    "PS"
+    "PSTricks"
+    "RTF"
+    "SC"
+    "SGML"
+    "SliTeX"
+    "SQL"
+    "stTeX"
+    "STIX"
+    "SVG"
+    "TANGLE"
+    "TB"
+    "TIFF"
+    "TP"
+    "TeXhax"
+    "TeXMaG"
+    "TeXtures"
+    "Textures"
+    "TeXworks"
+    "TeXXeT"
+    "TFM"
+    "Thanh"
+    "TikZ"
+    "ttn"
+    "TTN"
+    "TUB"
+    "TUG"
+    "tug"
+    "UG"
+    "UNIX"
+    "VAX"
+    "VnTeX"
+    "VorTeX"
+    "XML"
+    "WEB"
+    "WEAVE"
+    "WYSIWYG"
+    "XeTeX"
+    "XeLaTeX"
+    "XHTML"
+    "XSL"
+    "XSLFO"
+    "XSLT"
+
+    ;; 10.2 Other special typesetting
+    '("Dash" 0)
+    '("cs" (TeX-arg-eval let ((macro (completing-read
+                                     (TeX-argument-prompt optional nil
+                                                          "Command")
+                                     (TeX-symbol-list))))
+                        (format "%s" macro)))
+    '("env" (TeX-arg-eval let ((env (completing-read
+                                    (TeX-argument-prompt optional nil
+                                                         "Environment")
+                                    (LaTeX-environment-list))))
+                         (format "%s" env)))
+    '("meta"      "Text")
+    '("tubbraced" "Text")
+    '("nth"       "Number")
+
+    ;; 12 Bibliography
+    '("SetBibJustification"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Justification")
+                   '("\\raggedright"  "\\sloppy"))))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("shortTitle"   "{")
+                               ("shortAuthor"  "{")
+                               ("netaddress"   "{")
+                               ("personalURL"  "{")
+                               ("ORCID"        "{")
+                               ("contributor"  "{")
+                               ("acro"         "{")
+                               ("cs"           "{")
+                               ("env"          "{")
+                               ("meta"         "{")
+                               ("tubbraced"    "{")
+                               ("nth"          "{"))
+                             'textual)
+     (font-latex-add-keywords '(("makesignature"   "")
+                               ("SetBibJustification"  "{"))
+                             'function)
+     (font-latex-add-keywords '(("nameref" "{"))
+                             'reference)))
+ LaTeX-dialect)
+
+(defvar LaTeX-ltugboat-class-options
+  '("draft" "final" "preprint"
+    "extralabel" "harvardcite" "noextralabel" "nonumber" "numbersec"
+    "onecolumn" "rawcite" "runningfull" "runningminimal" "runningoff"
+    "a4paper" "a5paper" "b5paper" "letterpaper" "legalpaper" "executivepaper"
+    "titlepage" "notitlepage" "twocolumn" "leqno" "fleqn" "openbib")
+  "Package options for the ltugboat class.")
+
+;;; ltugboat.el ends here
diff --git a/style/mflogo.el b/style/mflogo.el
index 1d4b96d..52fa44b 100644
--- a/style/mflogo.el
+++ b/style/mflogo.el
@@ -1,5 +1,7 @@
 ;;; mflogo.el --- AUCTeX style for `mflogo.sty'
 
+;; Copyright (C) 2012, 2019 Free Software Foundation, Inc.
+
 ;; Author: Mads Jensen <address@hidden>
 ;; Maintainer: address@hidden
 ;; Created: 2011-02-02
@@ -37,15 +39,18 @@
  "mflogo"
  (lambda ()
    (TeX-add-symbols
-    '("textlogo" 1)
-    '("logofamily" 1))
+    '("textlogo"   "Text")
+    '("logofamily" -1)
+    '("MF"          0)
+    '("MP"          0))
 
    ;; Fontification
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("logofamily" "{")
-                               ("textlogo" "{"))
-                             'function)))
+     (font-latex-add-keywords '(("textlogo" "{"))
+                             'type-command)
+     (font-latex-add-keywords '(("logofamily" ""))
+                             'type-declaration)))
  LaTeX-dialect)
 
 (defvar LaTeX-mflogo-package-options nil
diff --git a/style/mflogo.el b/style/multitoc.el
similarity index 58%
copy from style/mflogo.el
copy to style/multitoc.el
index 1d4b96d..43fa817 100644
--- a/style/mflogo.el
+++ b/style/multitoc.el
@@ -1,8 +1,10 @@
-;;; mflogo.el --- AUCTeX style for `mflogo.sty'
+;;; multitoc.el --- AUCTeX style for `multitoc.sty' (v2.01)
 
-;; Author: Mads Jensen <address@hidden>
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
-;; Created: 2011-02-02
+;; Created: 2019-09-07
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -24,31 +26,23 @@
 
 ;;; Commentary:
 
-;; This file adds support for `mflogo.sty'.
+;; This file adds support for `multitoc.sty' (v2.01) from 1999/06/08.
+;; `multitoc.sty' is part of TeXLive.
 
 ;;; Code:
 
-;; Silence the compiler:
-(declare-function font-latex-add-keywords
-                 "font-latex"
-                 (keywords class))
-
 (TeX-add-style-hook
- "mflogo"
+ "multitoc"
  (lambda ()
+   (TeX-run-style-hooks "multicol" "ifthen")
    (TeX-add-symbols
-    '("textlogo" 1)
-    '("logofamily" 1))
-
-   ;; Fontification
-   (when (and (featurep 'font-latex)
-             (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("logofamily" "{")
-                               ("textlogo" "{"))
-                             'function)))
+    "multicolumntoc"
+    "multicolumnlot"
+    "multicolumnlof"))
  LaTeX-dialect)
 
-(defvar LaTeX-mflogo-package-options nil
-  "Package options for the mflogo package.")
+(defvar LaTeX-multitoc-package-options
+  '("toc" "lof" "lot")
+  "Package options for the multitoc package.")
 
-;;; mflogo.el ends here
+;;; multitoc.el ends here
diff --git a/style/paracol.el b/style/paracol.el
index 308ac46..3eef88a 100644
--- a/style/paracol.el
+++ b/style/paracol.el
@@ -1,6 +1,6 @@
-;;; paracol.el --- AUCTeX style for `paracol.sty' (v1.32)
+;;; paracol.el --- AUCTeX style for `paracol.sty' (v1.35)
 
-;; Copyright (C) 2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `paracol.sty' (v1.32) from 2015/10/10.
+;; This file adds support for `paracol.sty' (v1.35) from 2018/12/31.
 ;; `paracol.sty' is part of TeXLive.
 
 ;; `paracol.sty' provides an environment (paracol) and a command
@@ -118,6 +118,7 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
     '("switchcolumn" [ "Column" ] )
     '("switchcolumn*" [ TeX-arg-paracol-switchcolumn* ] )
     '("thecolumn")
+    '("definecolumnpreamble" "Column" t)
     '("ensurevspace" TeX-arg-length)
 
     ;; 7.3 Commands for Column and Gap Width
@@ -181,7 +182,7 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
     ;; the command only here but not for fontification
     '("columncolor" (TeX-arg-conditional (member "xcolor" (TeX-style-list))
                                         (TeX-arg-xcolor)
-                                      (TeX-arg-color))
+                                        (TeX-arg-color))
       [ "Column" ] )
 
     ;; \normalcolumncolor[col]
@@ -193,7 +194,7 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
     ;; \normalcolseprulecolor[col]
     '("colseprulecolor" (TeX-arg-conditional (member "xcolor" (TeX-style-list))
                                             (TeX-arg-xcolor)
-                                          (TeX-arg-color))
+                                            (TeX-arg-color))
       [ "Column" ] )
     '("normalcolseprulecolor" [ "Column" ] )
 
@@ -208,7 +209,7 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
                      "C" "G" "S" "F" "N" "P" "T" "B" "L" "R"))
       (TeX-arg-conditional (member "xcolor" (TeX-style-list))
                           (TeX-arg-xcolor)
-                        (TeX-arg-color)))
+                          (TeX-arg-color)))
 
     ;; \nobackgroundcolor{region}
     '("nobackgroundcolor"
@@ -228,20 +229,25 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
                    '("toc" "lof" "lot"))
       "Column")
 
+    ;; 7.10 Page Flushing Commands
     '("flushpage" 0))
 
-   ; \switchcolumn should get its own line:
+   ;; \belowfootnoteskip is a length:
+   (LaTeX-add-lengths "belowfootnoteskip")
+
+   ;; \switchcolumn should get its own line:
    (LaTeX-paragraph-commands-add-locally "switchcolumn")
 
    ;; Fontification
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
-                             ;; FIXME: Syntax is \switchcolumn[num]*[text].
+     (font-latex-add-keywords '(("switchcolumn"                        "*["))
+                             ;; FIXME: Syntax is
+                             ;; \switchcolumn[num]*[text].
                              ;; font-latex.el doesn't handle the case
                              ;; where `*' comes after the first `['.
                              ;; Therefore, we use this compromise to
                              ;; get something fontified at least.
-     (font-latex-add-keywords '(("switchcolumn"                        "*["))
                              'textual)
      (font-latex-add-keywords '(("flushpage"                   "*["))
                              'warning)
@@ -249,7 +255,8 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
                                ("footnotemark"                 "*[")
                                ("footnotetext"                 "*[{"))
                              'reference)
-     (font-latex-add-keywords '(("ensurevspace"                        "{")
+     (font-latex-add-keywords '(("definecolumnpreamble"         "{{")
+                               ("ensurevspace"                 "{")
                                ("columnratio"                  "{[")
                                ("setcolumnwidth"               "{[")
                                ("twosided"                     "[")
diff --git a/style/pst-plot.el b/style/pst-plot.el
index d4ddfe5..0942c6e 100644
--- a/style/pst-plot.el
+++ b/style/pst-plot.el
@@ -1,6 +1,6 @@
 ;;; pst-plot.el --- AUCTeX style for `pst-plot.sty'
 
-;; Copyright (C) 2007, 2014, 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2014, 2015, 2019 Free Software Foundation, Inc.
 
 ;; Author: Holger Sparr <address@hidden>
 ;; Created: 21 Jun 2007
@@ -53,11 +53,11 @@
     "ticksize" "tickstyle")
   "A list of parameters' name in pst-plot.")
 
+(defvaralias 'LaTeX-pst-labels-list 'LaTeX-pst-ticks-list)
+
 (defvar LaTeX-pst-ticks-list '(t "none" "all" "x" "y")
   "A list of values for ticks in pst-plot.")
 
-(defvaralias 'LaTeX-pst-labels-list 'LaTeX-pst-ticks-list)
-
 (defvar LaTeX-pst-plotstyle-list
   '(t "dots" "line" "polygon" "curve" "ecurve" "ccurve")
   "A list of values for tickstyles in pst-plot.")
diff --git a/style/ragged2e.el b/style/ragged2e.el
index 2b7050e..fd6fd1b 100644
--- a/style/ragged2e.el
+++ b/style/ragged2e.el
@@ -1,6 +1,6 @@
 ;;; ragged2e.el --- AUCTeX style for `ragged2e.sty'
 
-;; Copyright (C) 2011, 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2015, 2019 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <address@hidden>
 ;; Created: 2011-04-16
@@ -54,10 +54,19 @@
     ;; \justifying
     "JustifyingParfillskip" "JustifyingParindent")
 
-   (TeX-run-style-hooks "footmisc" "everysel"))
+   (TeX-run-style-hooks "footmisc" "everysel")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("Centering"    "")
+                               ("justifying"   "")
+                               ("RaggedRight"  "")
+                               ("RaggedLeft"   ""))
+                             'function)))
  LaTeX-dialect)
 
-(defvar LaTeX-ragged2e-package-options 
+(defvar LaTeX-ragged2e-package-options
   '("originalcommands" "newcommands" "originalparameters" "document"
     "newparameters" "footnotes" "raggedrightboxes")
   "Package options for the ragged2e package.")
diff --git a/style/subcaption.el b/style/subcaption.el
index 8bffa8a..1914a14 100644
--- a/style/subcaption.el
+++ b/style/subcaption.el
@@ -1,6 +1,6 @@
-;;; subcaption.el --- AUCTeX style for `subcaption.sty' (v1.1-100)
+;;; subcaption.el --- AUCTeX style for `subcaption.sty' (v1.3)
 
-;; Copyright (C) 2015--2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,8 +26,8 @@
 
 ;;; Commentary:
 
-;; This file adds support for `subcaption.sty' (v1.1-100) from
-;; 2015-09-15.  `subcaption.sty' is part of TeXLive.
+;; This file adds support for `subcaption.sty' (v1.3) from 2019-08-31.
+;; `subcaption.sty' is part of TeXLive.
 
 ;;; Code:
 
@@ -130,7 +130,8 @@ caption, insert only a caption."
     ;; check if hyperref.el is loaded and make it available directly.
     '("subref*"        TeX-arg-ref)
     '("phantomcaption"    0)
-    '("phantomsubcaption" 0))
+    '("phantomsubcaption" 0)
+    '("subfloat" [ "List entry" ] [ "Sub-caption" ] t))
 
    ;; The next 2 macros are part of the kernel of caption.sty, but we
    ;; load them within subcaption.el.
@@ -151,8 +152,9 @@ caption, insert only a caption."
                    (TeX-argument-prompt nil nil "Type")
                    '("figure" "table"))))
 
-   ;; \subcaption(box)? macros should get their own lines
-   (LaTeX-paragraph-commands-add-locally '("subcaption" "subcaptionbox"))
+   ;; \subcaption(box)? and \subfloat macros should get their own lines
+   (LaTeX-paragraph-commands-add-locally
+    '("subcaption" "subcaptionbox" "subfloat"))
 
    ;; The subfigure & subtable environments
    (LaTeX-add-environments
@@ -175,7 +177,8 @@ caption, insert only a caption."
      (font-latex-add-keywords '(("subcaption"            "*[{")
                                ("subcaptionbox"         "*[{[[")
                                ("phantomcaption"        "")
-                               ("phantomsubcaption"     ""))
+                               ("phantomsubcaption"     "")
+                               ("subfloat"              "[["))
                              'textual)
      (font-latex-add-keywords '(("subref"                "*{"))
                              'reference)
diff --git a/style/tcolorbox.el b/style/tcolorbox.el
index d8e9ffb..cae2662 100644
--- a/style/tcolorbox.el
+++ b/style/tcolorbox.el
@@ -46,6 +46,7 @@
 
 ;; Needed for auto-parsing:
 (require 'tex)
+(require 'latex)
 
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
@@ -405,13 +406,9 @@
 (defvar LaTeX-tcolorbox-newtcolorbox-regexp
   `(,(concat "\\\\\\(re\\)?newtcolorbox"
             "[ \t\n\r%]*"
-            "\\(?:\\[[^][]*"
-              "\\(?:{[^}{]*"
-                "\\(?:{[^}{]*"
-                  "\\(?:{[^}{]*}[^}{]*\\)*"
-                "}[^}{]*\\)*"
-              "}[^][]*\\)*"
-            "\\]\\)?"
+            "\\(?:"
+            (LaTeX-extract-key-value-label 'none)
+            "\\)?"
             "[ \t\n\r%]*"
             "{\\([a-zA-Z0-9]+\\)}"
             "[ \t\n\r%]*"
@@ -427,13 +424,9 @@
 (defvar LaTeX-tcolorbox-newtcbox-regexp
   `(,(concat "\\\\\\(re\\)?newtcbox"
             "[ \t\n\r%]*"
-            "\\(?:\\[[^][]*"
-              "\\(?:{[^}{]*"
-                "\\(?:{[^}{]*"
-                  "\\(?:{[^}{]*}[^}{]*\\)*"
-                "}[^}{]*\\)*"
-              "}[^][]*\\)*"
-            "\\]\\)?"
+            "\\(?:"
+            (LaTeX-extract-key-value-label 'none)
+            "\\)?"
             "[ \t\n\r%]*"
             "{\\\\\\([a-zA-Z]+\\)}"
             "[ \t\n\r%]*"
diff --git a/style/thmtools.el b/style/thmtools.el
index b344c62..20ddb69 100644
--- a/style/thmtools.el
+++ b/style/thmtools.el
@@ -1,6 +1,6 @@
-;;; thmtools.el --- AUCTeX style for `thmtools.sty' (v66)
+;;; thmtools.el --- AUCTeX style for `thmtools.sty' (v67)
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018, 2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `thmtools.sty' (v66) from 2014/04/21.
+;; This file adds support for `thmtools.sty' (v67) from 2019/07/31.
 ;; `thmtools.sty' is part of TeXLive.
 
 ;;; Code:
@@ -38,6 +38,7 @@
 
 ;; Needed for auto-parsing:
 (require 'tex)
+(require 'latex)
 
 ;; Setup for \declaretheoremstyle:
 (TeX-auto-add-type "thmtools-declaretheoremstyle" "LaTeX")
@@ -45,13 +46,9 @@
 (defvar LaTeX-thmtools-declaretheoremstyle-regexp
   `(,(concat "\\\\declaretheoremstyle"
             "[ \t\n\r%]*"
-            "\\(?:\\[[^][]*"
-              "\\(?:{[^}{]*"
-                "\\(?:{[^}{]*"
-                  "\\(?:{[^}{]*}[^}{]*\\)*"
-                "}[^}{]*\\)*"
-              "}[^][]*\\)*"
-            "\\]\\)?"
+            "\\(?:"
+            (LaTeX-extract-key-value-label 'none)
+            "\\)?"
             "[ \t\n\r%]*"
             "{\\([^}]+\\)}")
     1 LaTeX-auto-thmtools-declaretheoremstyle)
@@ -63,13 +60,9 @@
 (defvar LaTeX-thmtools-declaretheorem-regexp
   `(,(concat "\\\\declaretheorem"
             "[ \t\n\r%]*"
-            "\\(?:\\[[^][]*"
-              "\\(?:{[^}{]*"
-                "\\(?:{[^}{]*"
-                  "\\(?:{[^}{]*}[^}{]*\\)*"
-                "}[^}{]*\\)*"
-              "}[^][]*\\)*"
-            "\\]\\)?"
+            "\\(?:"
+            (LaTeX-extract-key-value-label 'none)
+            "\\)?"
             "[ \t\n\r%]*"
             "{\\([^}]+\\)}")
     1 LaTeX-auto-thmtools-declaretheorem)
@@ -210,7 +203,8 @@ minibuffer.  PROMPT replaces the standard one."
        ("onlynamed" ,thms)
        ("show" ,thms)
        ("ignoreall" ("true" "false"))
-       ("showall" ("true" "false"))))))
+       ("showall" ("true" "false"))
+       ("title")))))
 
 (defun LaTeX-arg-thmtools-listoftheorems (optional &optional prompt)
   "Insert the key=val to \\listoftheorems macro.
@@ -301,4 +295,9 @@ RefTeX users should customize or add ENVIRONMENT to
                              'function)))
  LaTeX-dialect)
 
+;; The package has only one option `debug'.  We ignore that in order
+;; to make loading faster:
+(defvar LaTeX-thmtools-package-options nil
+  "Package options for the thmtools package.")
+
 ;;; thmtools.el ends here
diff --git a/style/titlesec.el b/style/titlesec.el
index 519ce4e..e8922af 100644
--- a/style/titlesec.el
+++ b/style/titlesec.el
@@ -1,6 +1,6 @@
-;;; titlesec.el --- AUCTeX style for `titlesec.sty' (v2.10.0)
+;;; titlesec.el --- AUCTeX style for `titlesec.sty' (v2.11)
 
-;; Copyright (C) 2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,8 +26,8 @@
 
 ;;; Commentary:
 
-;; This file adds support for `titlesec.sty' (v2.10.0) from
-;; 2011/12/15.  `titlesec.sty' is part of TeXLive.
+;; This file adds support for `titlesec.sty' (v2.11) from
+;; 2019/07/16.  `titlesec.sty' is part of TeXLive.
 
 ;;; Code:
 
@@ -121,11 +121,11 @@ insert the argument in brackets."
     '("titleformat"
       (LaTeX-arg-titlesec-titlespec)
       [TeX-arg-eval completing-read
-                    (TeX-argument-prompt optional nil "Shape")
-                    LaTeX-titlesec-section-shape-list]
+                   (TeX-argument-prompt optional nil "Shape")
+                   LaTeX-titlesec-section-shape-list]
       (TeX-arg-conditional (y-or-n-p "With optional after-code? ")
                           (4 [nil])
-                        (4)))
+                          (4)))
 
     '("chaptertitlename" 0)
 
@@ -152,7 +152,8 @@ insert the argument in brackets."
     '("fillast"   0)
     '("filinner"  0)
     '("filouter"  0)
-    '("wordsep"          0)
+    '("wordsep"   0)
+    '("nostruts"  0)
 
     ;; 3.4. Rules
     '("titleline"
@@ -240,6 +241,7 @@ insert the argument in brackets."
     "rigidchapters" "rubberchapters"
     "bottomtitles"  "nobottomtitles" "nobottomtitles*"
     "aftersep"      "largestsep"     "pageatnewline"
+    "nostruts"
 
     ;; 3.4. Rules
     "calcwidth"
diff --git a/style/varioref.el b/style/varioref.el
index ce840e7..d5e7e0d 100644
--- a/style/varioref.el
+++ b/style/varioref.el
@@ -1,6 +1,6 @@
-;;; varioref.el --- AUCTeX style file with support for varioref.sty
+;;; varioref.el --- AUCTeX style for `varioref.sty' (v1.6b)
 
-;; Copyright (C) 1999, 2013, 2015, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2013, 2015, 2018, 2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;;         Mads Jensen <address@hidden>
@@ -23,6 +23,11 @@
 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 ;; 02110-1301, USA.
 
+;;; Commentary:
+
+;; This file adds support for `varioref.sty' (v1.6b) from 2019/09/08.
+;; `varioref.sty' is a standard LaTeX package and part of TeXLive.
+
 ;;; Code:
 
 ;; Silence the compiler:
@@ -30,73 +35,75 @@
                  "font-latex"
                  (keywords class))
 
-(TeX-add-style-hook "varioref"
-   (lambda ()
-
-     (TeX-add-symbols
-
-      ;; The macros with label arguments
-      '("vref" TeX-arg-ref)
-      '("Vref" TeX-arg-ref)
-      '("vrefrange" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
-      '("vrefrange*" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
-      '("vref*" TeX-arg-ref)
-      '("Vref" TeX-arg-ref)
-      '("Ref" TeX-arg-ref)
-      '("vpageref" [ "Same page text" ] [ "Different page text" ] TeX-arg-ref)
-      '("vpageref*" [ "Same page text" ] [ "Different page text" ]
-        TeX-arg-ref)
-      '("fullref" TeX-arg-ref)
-      '("labelformat" TeX-arg-counter t)
-
-      '("vpagerefrange" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
-      '("vpagerefrange*" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
-
-      ;; And the other macros used for customization
-      "reftextbefore" "reftextfacebefore"
-      "reftextafter"  "reftextfaceafter" "reftexlabelrange"
-      "reftextfaraway" "vreftextvario" "vrefwarning"
-      "vpagerefnum" "vrefshowerrors")
-
-     ;; Install completion for labels.  Only offer completion for
-     ;; commands that take only one reference as an argument
-     (setq TeX-complete-list
-          (append
-           '(("\\\\[Vv]ref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-              ("\\\\vref\\*?{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-              ("\\\\Ref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-              ("\\\\vref\\*{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-              ("\\\\fullref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-              ("\\\\vpageref\\*?\\(\\[[^]]*\\]\\)*{\\([^{}\n\r\\%,]*\\)"
-              2 LaTeX-label-list "}"))
-           TeX-complete-list))
-
-     ;; Fontification
-     (when (and (fboundp 'font-latex-add-keywords)
-               (eq TeX-install-font-lock 'font-latex-setup))
-       (font-latex-add-keywords '(;; vref is already in font-latex.el,
-                                 ;; so don't add it here again
-                                 ("Vref"          "*{")
-                                 ("vpageref"      "*[[{")
-                                 ("vrefrange"     "*[{{")
-                                 ("Ref"           "{")
-                                 ("fullref"       "{")
-                                 ("vpagerefrange" "*[{{"))
-                               'reference))
-
-     ;; Activate RefTeX reference style.
-     (and LaTeX-reftex-ref-style-auto-activate
-         (fboundp 'reftex-ref-style-activate)
-         (reftex-ref-style-activate "Varioref")))
-   LaTeX-dialect)
+(TeX-add-style-hook
+ "varioref"
+ (lambda ()
+
+   (TeX-add-symbols
+    ;; 3 The user interface
+    '("vref" TeX-arg-ref)
+    '("vpageref" [ "Same page text" ] [ "Different page text" ] TeX-arg-ref)
+    '("vrefrange" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
+    '("vpagerefrange" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
+    "vpagerefnum"
+    '("vpagerefcompare" 4)
+    '("vpagerefnearby"  3)
+    '("vref*" TeX-arg-ref)
+    '("vpageref*" [ "Same page text" ] [ "Different page text" ] TeX-arg-ref)
+    '("vrefrange*" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
+    '("vpagerefrange*" [ "Same page text" ] TeX-arg-ref TeX-arg-ref)
+
+    '("Vref" TeX-arg-ref)
+    '("Vref*" TeX-arg-ref)
+
+    ;; 5 Customization
+    "reftextbefore" "reftextfacebefore"
+    "reftextafter"  "reftextfaceafter"
+    "reftextfaraway" "vreftextvario"
+    "reftextpagerange" "reftexlabelrange"
+    "vrefwarning"  "vrefshowerrors"
+    '("fullref" TeX-arg-ref))
+
+   ;; Install completion for labels.  Only offer completion for
+   ;; commands that take only one reference as an argument
+   ;; FIXME: The first 3 entries can be reduced to
+   ;; ("\\\\[Vv]ref\\*?{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")  ???
+   (setq TeX-complete-list
+        (append
+         '(("\\\\[Vv]ref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
+           ("\\\\vref\\*?{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
+           ("\\\\vref\\*{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
+           ("\\\\fullref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
+           ("\\\\vpageref\\*?\\(\\[[^]]*\\]\\)*{\\([^{}\n\r\\%,]*\\)"
+            2 LaTeX-label-list "}"))
+         TeX-complete-list))
+
+   ;; Fontification
+   (when (and (fboundp 'font-latex-add-keywords)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(;; vref is already in font-latex.el,
+                               ;; so don't add it here again
+                               ("vpageref"      "*[[{")
+                               ("vrefrange"     "*[{{")
+                               ("vpagerefrange" "*[{{")
+                               ("Vref"          "*{")
+                               ("fullref"       "{"))
+                             'reference))
+
+   ;; Activate RefTeX reference style.
+   (and LaTeX-reftex-ref-style-auto-activate
+       (fboundp 'reftex-ref-style-activate)
+       (reftex-ref-style-activate "Varioref")))
+ LaTeX-dialect)
 
 (defvar LaTeX-varioref-package-options
-  '("draft" "final" "afrikaans" "american" "austrian" "naustrian" "basque"
-    "brazil" "breton" "bahasam" "catalan" "croatian" "czech" "danish"
-    "dutch" "english" "esperanto" "finnish" "french" "galician" "german"
-    "icelandic" "ngerman" "greek" "italian" "magyar" "norsk" "nynorsk"
-    "polish" "portuges" "romanian" "russian" "slovak" "slovene"
-    "spanish" "swedish" "turkish" "ukrainian" "francais" "germanb")
+  '("afrikaans" "american" "arabic" "austrian" "naustrian" "basque"
+    "bahasam" "brazil" "breton" "bulgarian" "catalan" "croatian"
+    "czech" "danish" "dutch" "english" "esperanto" "finnish" "french"
+    "galician" "german" "ngerman" "greek" "icelandic" "italian" "magyar"
+    "norsk" "nynorsk" "polish" "portuges" "romanian" "russian"
+    "slovak" "slovene" "spanish" "swedish" "turkish" "ukrainian"
+    "francais" "germanb" "draft" "final" "space" "nospace")
   "Package options for the varioref package.")
 
 ;;; varioref.el ends here
diff --git a/style/xcolor.el b/style/xcolor.el
index db820c7..43c5637 100644
--- a/style/xcolor.el
+++ b/style/xcolor.el
@@ -1,6 +1,6 @@
 ;; xcolor.el --- AUCTeX style for `xcolor.sty' (v2.12)
 
-;; Copyright (C) 2016--2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2019 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -44,8 +44,8 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'latex))
+;; Needed for compiling `LaTeX-check-insert-macro-default-style':
+(require 'latex)
 
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
@@ -350,7 +350,8 @@ xcolor package.")
                     (TeX-argument-prompt t nil "(Frame) Color model")
                     LaTeX-xcolor-color-models)))
         ;; Set `last-optional-rejected' acc. to `xfrmodel'
-        (last-optional-rejected (and xfrmodel (string= xfrmodel "")))
+        (last-optional-rejected (or (not xfrmodel)
+                                    (and xfrmodel (string= xfrmodel ""))))
         (xfrspec  (if (or (null xfrmodel)
                           (string= xfrmodel "")
                           (string= xfrmodel "named"))
diff --git a/style/xparse.el b/style/xparse.el
index a65f2d1..271ec61 100644
--- a/style/xparse.el
+++ b/style/xparse.el
@@ -100,11 +100,11 @@
    ;; Fontification
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("DeclareDocumentCommand" "|{{{")
-                               ("NewDocumentCommand" "|{{{")
-                               ("RenewDocumentCommand" "|{{{")
-                               ("ProvideDocumentCommand" "|{{{")
-                               ("DeclareExpandableDocumentCommand" "|{{{")
+     (font-latex-add-keywords '(("DeclareDocumentCommand" "|{\\{{")
+                               ("NewDocumentCommand" "|{\\{{")
+                               ("RenewDocumentCommand" "|{\\{{")
+                               ("ProvideDocumentCommand" "|{\\{{")
+                               ("DeclareExpandableDocumentCommand" "|{\\{{")
                                ("DeclareDocumentEnvironment" "{{{{")
                                ("NewDocumentEnvironment" "{{{{")
                                ("RenewDocumentEnvironment" "{{{{")
diff --git a/tests/latex/preview-latex-test.el 
b/tests/latex/preview-latex-test.el
index 0249683..ecc05fe 100644
--- a/tests/latex/preview-latex-test.el
+++ b/tests/latex/preview-latex-test.el
@@ -42,7 +42,7 @@ emacs' coding system later."
   (dolist (str '("prim\xC3\xA1rias" "prim^^c3\xA1rias" "prim^^c3^^a1rias"))
     (should (string= (preview--decode-^^ab str 'utf-8) "primárias"))))
 
-;;; preview-latex.el ends here
+;;; preview-latex-test.el ends here
 
 ;; Local Variables:
 ;; coding: utf-8
diff --git a/tests/tex/navigation.el b/tests/tex/navigation.el
new file mode 100644
index 0000000..daf1840
--- /dev/null
+++ b/tests/tex/navigation.el
@@ -0,0 +1,54 @@
+;;; navigation.el --- tests for navigation function in TeX buffer
+
+;; Copyright (C) 2019 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 'tex)
+
+(defun TeX-check-f-m-e-h (string &optional position)
+  "Check whether `TeX-find-macro-end-helper' works for exceptional case."
+  (with-temp-buffer
+    (insert string)
+    (should (= (or position (point-max))
+              (TeX-find-macro-end-helper (point-min))))))
+
+(ert-deftest TeX-find-macro-end-helper-single ()
+  ;; single macro ending at EOB
+  (TeX-check-f-m-e-h "\\foo"))
+
+(ert-deftest TeX-find-macro-end-helper-curly ()
+  ;; curly braces ending at EOB
+  (TeX-check-f-m-e-h "\\foo{bar}"))
+
+(ert-deftest TeX-find-macro-end-helper-curly-fail ()
+  ;; curly brace failing to close at EOB
+  (TeX-check-f-m-e-h "\\foo{bar"))
+
+(ert-deftest TeX-find-macro-end-helper-square ()
+  ;; square brackets ending at EOB
+  (TeX-check-f-m-e-h "\\foo{bar}[baz]"))
+
+(ert-deftest TeX-find-macro-end-helper-square-fail ()
+  ;; square bracket failing to close at EOB
+  (TeX-check-f-m-e-h "\\foo{bar}[baz" (1+ (length "\\foo{bar}"))))
+
+;;; navigation.el ends here
diff --git a/tests/tex/path-expansion.el b/tests/tex/path-expansion.el
index 3a1d72e..42eb665 100644
--- a/tests/tex/path-expansion.el
+++ b/tests/tex/path-expansion.el
@@ -32,4 +32,4 @@
     (TeX-search-files-by-type 'abc 'global)
     (should (equal var '("str1" "str2")))))
 
-;;; command-expansion.el ends here
+;;; path-expansion.el ends here
diff --git a/tex-buf.el b/tex-buf.el
index e89df51..9aaa585 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1,6 +1,6 @@
 ;;; tex-buf.el --- External commands for AUCTeX.
 
-;; Copyright (C) 1991-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex, wp
@@ -547,8 +547,6 @@ without further expansion."
   (let (pat
        pos ;;FIXME: Should this be dynamically scoped?
        entry TeX-command-text TeX-command-pos
-       (orig-file file)
-       (file #'TeX--master-or-region-file-with-extra-quotes)
         expansion-res case-fold-search string expansion arguments)
     (setq list (cons
                (list "%%" (lambda nil
@@ -556,6 +554,17 @@ without further expansion."
                             "%"))
                (or list (TeX-expand-list)))
          pat (regexp-opt (mapcar #'car list)))
+    ;; `TeX-command-expand' is called with `file' argument being one
+    ;; of `TeX-master-file', `TeX-region-file' and
+    ;; `TeX-active-master'.  The return value of these functions
+    ;; sometimes needs suitable "decorations" for an argument for
+    ;; underlying shell or latex executable, or both, when the
+    ;; relavant file name involves some special characters such as
+    ;; space and multibyte characters.  Hence embed that function in a
+    ;; template prepared for that purpose.
+    (setq file (apply-partially
+               #'TeX--master-or-region-file-with-extra-quotes
+               file))
     (while (setq pos (string-match pat command pos))
       (setq string (match-string 0 command)
            entry (assoc string list)
@@ -587,24 +596,29 @@ without further expansion."
   command)
 
 (defun TeX--master-or-region-file-with-extra-quotes
-    (&optional extension nondirectory ask extra)
+    (file-fn &optional extension nondirectory ask extra)
   "Return file name with quote for shell.
-Wrapper for `TeX-master-file', `TeX-region-file' or
-`TeX-active-master' to be used in `TeX-command-expand'.
-It is assumed that `orig-file' has dynamic binding of the value
-of `TeX-master-file', `TeX-region-file' or `TeX-active-master'.
-Pass EXTENSION, NONDIRECTORY and ASK to that function as-is, and
-arrange the returned file name for use with command shell.
-Enclose the file name with space within quotes `\"' first when
-\" \\input\" is supplemented (indicated by dynamically binded
-variable `TeX-command-text' having string value.)
-Enclose the file name within \\detokenize{} when the following three
+Helper function of `TeX-command-expand'.
+
+This is a kind of template.  How to use:
+Fix, by `apply-partially', the first argument FILE-FN as one of
+the three functions `TeX-master-file', `TeX-region-file' or
+`TeX-active-master'.  Then the result is just a wrapper for that
+function suitable in `TeX-command-expand'.
+
+As a wrapper described above, it passes EXTENSION, NONDIRECTORY
+and ASK to the \"bare\" function as-is, and arranges the returned
+file name for use with command shell.  I.e. it encloses the file
+name with space within quotes `\"' first when \" \\input\" is
+supplemented (indicated by dynamically binded variable
+`TeX-command-text' having string value.)  It also encloses the
+file name within \\detokenize{} when the following three
 conditions are met:
 1. compiling with standard (pdf)LaTeX or upLaTeX
 2. \" \\input\" is supplemented
-3. EXTRA is non-nil. (default when expanding \"%T\")"
+3. EXTRA is non-nil (default when expanding \"%T\")"
   (shell-quote-argument
-   (let* ((raw (funcall orig-file extension nondirectory ask))
+   (let* ((raw (funcall file-fn extension nondirectory ask))
          ;; String `TeX-command-text' means that the file name is
          ;; given through \input command.
          (quote-for-space (if (and (stringp TeX-command-text)
@@ -1279,7 +1293,21 @@ run of `TeX-run-TeX', use
 (defun TeX-run-compile (_name command _file)
   "Ignore first and third argument, start compile with second argument."
   (let ((default-directory (TeX-master-directory)))
-    (setq TeX-command-buffer (compile command))))
+    (setq TeX-command-buffer (compile command)))
+  ;; Make `compilation-mode' recognize file names with spaces.
+  ;; (bug#36483)
+  ;; FIXME: This is just an ad-hoc workaround and it's better to fix
+  ;; the regular expression in compile.el properly, if possible.  But
+  ;; there was no response to such request in address@hidden.
+  (with-current-buffer TeX-command-buffer
+    (make-local-variable 'compilation-error-regexp-alist)
+    ;; Add slightly modified entry of the one associated with `comma'
+    ;; in `compilation-error-regexp-alist-alist' to pick up file names
+    ;; with spaces.
+    (add-to-list 'compilation-error-regexp-alist
+                '("^\"\\([^,\"\n\t]+\\)\", line \\([0-9]+\\)\
+\\(?:[(. pos]+\\([0-9]+\\))?\\)?[:.,; (-]\\( warning:\\|[-0-9 ]*(W)\\)?" 1 2 3 
(4))
+                t)))
 
 (defun TeX-run-shell (_name command _file)
   "Ignore first and third argument, start shell-command with second argument."
diff --git a/tex-info.el b/tex-info.el
index b1fd236..4f8165d 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -664,6 +664,8 @@ value of `Texinfo-mode-hook'."
 
   (set (make-local-variable 'font-lock-defaults)
        '(texinfo-font-lock-keywords nil nil nil backward-paragraph))
+  (set (make-local-variable 'syntax-propertize-function)
+       texinfo-syntax-propertize-function)
 
   ;; Outline settings.
   (set (make-local-variable 'outline-regexp)
@@ -702,8 +704,8 @@ value of `Texinfo-mode-hook'."
 
   (when (and (boundp 'add-log-current-defun-function)
             (fboundp 'texinfo-current-defun-name))
-    (setq add-log-current-defun-function
-         #'texinfo-current-defun-name))
+    (set (make-local-variable 'add-log-current-defun-function)
+        #'texinfo-current-defun-name))
 
   (TeX-add-symbols
    '("acronym" "Acronym")
diff --git a/tex-jp.el b/tex-jp.el
index c20e62d..dff1b11 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -41,7 +41,8 @@
 
 (defgroup AUCTeX-jp nil
   "Japanese support in AUCTeX."
-  :group 'AUCTeX)
+  :group 'AUCTeX
+  :link '(custom-manual "(auctex)Japanese"))
 
 (defcustom japanese-TeX-engine-default 'ptex
   "Default TeX engine for Japanese TeX."
diff --git a/tex.el b/tex.el
index 3c3f176..95448d8 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
 ;;; tex.el --- Support for TeX documents.
 
-;; Copyright (C) 1985-1987, 1991, 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1991, 1993-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -136,27 +136,41 @@ If nil, none is specified."
     ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
      TeX-run-TeX nil
      (context-mode) :help "Run ConTeXt until completion")
-    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX")
-    ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber")
+    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode
+                    context-mode)
+     :help "Run BibTeX")
+    ("Biber" "biber %s" TeX-run-Biber nil
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     :help "Run Biber")
     ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
     ("Print" "%p" TeX-run-command t t :help "Print the file")
     ("Queue" "%q" TeX-run-background nil t :help "View the printer queue"
      :visible TeX-queue-command)
-    ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t t
+    ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
      :help "Generate PostScript file")
-    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil t
+    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
      :help "Convert DVI file to PostScript")
-    ("Dvipdfmx" "dvipdfmx %d" TeX-run-dvipdfmx nil t
+    ("Dvipdfmx" "dvipdfmx %d" TeX-run-dvipdfmx nil
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
      :help "Convert DVI file to PDF with dvipdfmx")
-    ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil t
+    ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
      :help "Convert PostScript file to PDF")
     ("Glossaries" "makeglossaries %s" TeX-run-command nil
-     t :help "Run makeglossaries to create glossary file")
-    ("Index" "makeindex %s" TeX-run-index nil t
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     :help "Run makeglossaries to create glossary
+     file")
+    ("Index" "makeindex %s" TeX-run-index nil
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
      :help "Run makeindex to create index file")
-    ("upMendex" "upmendex %s" TeX-run-index t t
+    ("upMendex" "upmendex %s" TeX-run-index t
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
      :help "Run upmendex to create index file")
-    ("Xindy" "texindy %s" TeX-run-command nil t
+    ("Xindy" "texindy %s" TeX-run-command nil
+     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
      :help "Run xindy to create index file")
     ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
      :help "Check LaTeX file for correctness")
@@ -541,8 +555,9 @@ string."
                  (concat TeX-command-text " \"\\input\""))
              "")))
     ;; The fourth argument of t is actually for wrapper function
-    ;; `TeX--master-or-region-file-with-extra-quotes', temporally set
-    ;; as value of `file' in `TeX-command-expand'.
+    ;; provided by `TeX--master-or-region-file-with-extra-quotes'.
+    ;; See its doc string as well as the comments in
+    ;; `TeX-command-expand'.
     ("%T" file t t nil t)
     ("%n" TeX-current-line)
     ("%d" file "dvi" t)
@@ -1163,8 +1178,6 @@ focus."
   :group 'TeX-view
   :type 'boolean)
 
-(defvar url-unreserved-chars)
-
 (defun TeX-evince-sync-view-1 (de app)
   "Focus the focused page/paragraph in Evince with the position
 of point in emacs by using Evince's DBUS API.  Used by default
@@ -1253,6 +1266,7 @@ viewer."
                 (paper-letter "-y=Letter ")
                 (paper-executive "-y=Executive ")
                 "%d" (mode-io-correlate " \"# %n '%b'\"")) "dviout")
+      ("PDF Tools" TeX-pdf-tools-sync-view)
       ("SumatraPDF"
        ("SumatraPDF -reuse-instance"
        (mode-io-correlate " -forward-search \"%b\" %n") " %o")
@@ -1262,6 +1276,7 @@ viewer."
    ((eq system-type 'darwin)
     '(("Preview.app" "open -a Preview.app %o" "open")
       ("Skim" "open -a Skim.app %o" "open")
+      ("PDF Tools" TeX-pdf-tools-sync-view)
       ("displayline" "displayline %n %o %b" "displayline")
       ("open" "open %o" "open")))
    (t
@@ -1579,7 +1594,9 @@ For available TYPEs, see variable `TeX-engine'."
     (setq type (intern type)))
   (setq TeX-engine type)
   ;; Automatically enable or disable TeX PDF mode as a convenience
-  (cond ((eq type 'xetex) (TeX-PDF-mode 1))
+  (cond ((eq type 'xetex)
+        (TeX-PDF-mode 1)
+        (setq TeX-PDF-from-DVI nil))
        ((eq type 'omega) (TeX-PDF-mode 0))))
 
 (define-minor-mode TeX-Omega-mode
@@ -2441,11 +2458,12 @@ Get `major-mode' from master file and enable it."
         comment-prefix "mode: " mode-string "\n"
         comment-prefix "TeX-master: " (prin1-to-string TeX-master) "\n"
         comment-prefix "End:\n")
-       (funcall mode)
-       ;; TeX modes run `VirTeX-common-initialization' which kills all local
-       ;; variables, thus `TeX-master' will be forgotten after `(funcall
-       ;; mode)'.  Reparse local variables in order to bring it back.
-       (hack-local-variables)))))
+       (unless (eq mode major-mode)
+         (funcall mode)
+         ;; TeX modes run `VirTeX-common-initialization' which kills all local
+         ;; variables, thus `TeX-master' will be forgotten after `(funcall
+         ;; mode)'.  Reparse local variables in order to bring it back.
+         (hack-local-variables))))))
 
 (defun TeX-local-master-p ()
   "Return non-nil if there is a `TeX-master' entry in local variables spec.
@@ -3109,7 +3127,11 @@ Or alternatively:
     (when entry
       (if (numberp (nth 1 entry))
          (let* ((sub (nth 1 entry))
-                (close (nth 3 entry))
+                (close (if (and (nth 3 entry)
+                                 (listp (nth 3 entry))
+                                 (symbolp (car (nth 3 entry))))
+                            (eval (nth 3 entry))
+                          (nth 3 entry)))
                 (begin (match-beginning sub))
                 (end (match-end sub))
                 (pattern (TeX-match-buffer 0))
@@ -5465,10 +5487,12 @@ those will be considered part of it."
                           ;; If we cannot find a regular end, use the
                           ;; next whitespace.
                           (save-excursion (skip-chars-forward "^ \t\n")
-                                          (point))))
-           (when (eobp) (throw 'found (point))))
+                                          (point)))))
           (t
-           (throw 'found (point)))))))))
+           (throw 'found (point)))))
+       ;; Make sure that this function does not return nil, even
+       ;; when the above `while' loop is totally skipped. (bug#35638)
+       (throw 'found (point))))))
 
 (defun TeX-find-macro-start (&optional limit)
   "Return the start of a macro.
@@ -6569,6 +6593,58 @@ Used as function for validating a variable's 
`safe-local-variable' property."
           (setq lst (cdr lst)))
         all-strings)))
 
+;; add-log.el: This function is a variation of
+;; `tex-current-defun-name' defined in `tex-mode.el'.  In `latex.el',
+;; the variable `add-log-current-defun-function' is set to this
+;; function.
+(defun TeX-current-defun-name ()
+  "Return the name of the TeX section/paragraph/chapter at point, or nil."
+  (save-excursion
+    (let (s1 e1 s2 e2)
+      ;; If we are now precisely at the beginning of a sectioning
+      ;; command, move forward and make sure `re-search-backward'
+      ;;  finds this one rather than the previous one:
+      (or (eobp) (progn
+                   (when (looking-at-p "\\\\")
+                     (forward-char))
+                   (unless (eolp)
+                     (forward-sexp))))
+      ;; Search backward for sectioning command.  If
+      ;; `LaTeX-section-label' is buffer-local, assume that a style
+      ;; has changed the value and recalculate the string.  Otherwise
+      ;; take the standard one:
+      (when (re-search-backward
+             (if (local-variable-p 'LaTeX-section-label)
+                 (concat "\\\\"
+                        (regexp-opt
+                          (remove "part" (mapcar #'car LaTeX-section-label)))
+                         "\\*?")
+               "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)\\*?")
+             nil t)
+        ;; Skip over the backslash:
+        (setq s1 (1+ (point)))
+        ;; Skip over the sectioning command, incl. the *:
+        (setq e1 (goto-char (match-end 0)))
+        ;; Skip over the optional argument, if any:
+        (when (looking-at-p "[ \t]*\\[")
+          (forward-sexp))
+        ;; Skip over any chars until the mandatory argument:
+        (skip-chars-forward "^{")
+        ;; Remember the points for the mandatory argument:
+        (setq s2 (point))
+        (setq e2 (progn (forward-sexp)
+                        (point)))
+        ;; Now pick the content: For one-line title, return it
+        ;; incl. the closing brace.  For multi-line, return the first
+        ;; line of the mandatory argument incl. ellipsis and a brace;
+        (concat
+         (buffer-substring-no-properties s1 e1)
+         (buffer-substring-no-properties
+          (goto-char s2)
+          (min (line-end-position) e2))
+         (when (> e2 (line-end-position))
+           (concat "..." TeX-grcl)))))))
+
 (provide 'tex)
 
 ;; Local Variables:
diff --git a/texmathp.el b/texmathp.el
index 9f32179..ba5aba3 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -237,8 +237,8 @@ empty lines we go back to fix the search limit."
 
 (defcustom texmathp-allow-detached-args nil
   "*Non-nil means, allow arguments of macros to be detached by whitespace.
-When this is t, `aaa' will be interpreted as an argument of \bb in the
-following construct:  \bbb [xxx] {aaa}
+When this is t, `aaa' will be interpreted as an argument of \\bbb in the
+following construct:  \\bbb [xxx] {aaa}
 This is legal in TeX.  The disadvantage is that any number of braces 
expressions
 will be considered arguments of the macro independent of its definition."
   :group 'texmathp
@@ -247,7 +247,7 @@ will be considered arguments of the macro independent of 
its definition."
 (defvar texmathp-why nil
   "After a call to `texmathp' this variable shows why math-mode is on or off.
 The value is a cons cell (MATCH . POSITION).
-MATCH is a string like a car of an entry in `texmathp-tex-commands', e.q.
+MATCH is a string like a car of an entry in `texmathp-tex-commands', e.g.
 \"equation\" or \"\\ensuremath\" or \"\\=\\[\" or \"$\".
 POSITION is the buffer position of the match.  If there was no match,
 it points to the limit used for searches, usually two paragraphs up.")



reply via email to

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