auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] [elpa] externals/auctex 2ee9a07 71/71: Merge remote-track


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 2ee9a07 71/71: Merge remote-tracking branch 'origin/master' into externals/auctex
Date: Fri, 17 Dec 2021 15:00:39 -0500 (EST)

branch: externals/auctex
commit 2ee9a0740a82b5fd254c04e8b45fe7114f992c3b
Merge: 46c464b f6edd15
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Merge remote-tracking branch 'origin/master' into externals/auctex
---
 Makefile.in                       | 106 +-----
 RELEASE                           | 176 +++++++---
 auctex.spec                       | 223 ------------
 configure.ac                      |   2 +-
 context-en.el                     |   8 +-
 context-nl.el                     |   6 +-
 context.el                        |  59 ++--
 doc/auctex.texi                   |  90 ++++-
 doc/changes.texi                  |  33 ++
 doc/preview-latex.texi            |   4 +-
 doc/preview-problems.texi         |   6 +-
 doc/preview-readme.texi           |   6 +-
 doc/tex-ref.tex                   |  10 +-
 doc/todo.texi                     |  27 +-
 font-latex.el                     |  15 +-
 latex.el                          | 559 +++++++++++++++++-------------
 latex/preview.dtx                 |   4 +-
 plain-tex.el                      |   8 +-
 preview-latex.spec                | 260 --------------
 style/acro.el                     |   4 +-
 style/amsthm.el                   |   2 +-
 style/arabxetex.el                |   7 +-
 style/babel.el                    |  63 ++--
 style/backref.el                  |  94 +++++
 style/bidi.el                     |   8 +-
 style/booktabs.el                 |   4 +-
 style/cancel.el                   |  63 ++++
 style/caption.el                  | 207 +++++------
 style/cuted.el                    |  73 ++++
 style/empheq.el                   | 110 +++---
 style/enumitem.el                 | 260 +++++++-------
 style/fancyvrb.el                 | 112 ++++--
 style/floatpag.el                 |  75 ++++
 style/floatrow.el                 | 152 +++++----
 style/flushend.el                 |  77 +++++
 style/fontspec.el                 | 292 +++++++++-------
 style/fvextra.el                  |  51 +--
 style/graphicx.el                 |   3 +-
 style/hologo.el                   |  24 +-
 style/hyperref.el                 |  17 +-
 style/kpfonts.el                  |  12 +-
 style/listings.el                 |  88 ++---
 style/mdframed.el                 | 139 ++++----
 style/midfloat.el                 |  51 +++
 style/minted.el                   |  77 ++---
 style/multicol.el                 |  35 +-
 style/newfloat.el                 |  30 +-
 style/ntheorem.el                 |   2 +-
 style/polyglossia.el              |   2 -
 style/pythontex.el                |  29 +-
 style/rotating.el                 |  87 +++++
 style/sidecap.el                  | 160 +++++++++
 style/siunitx.el                  | 702 +++++++++++++++-----------------------
 style/stabular.el                 |  63 ++++
 style/stfloats.el                 |  65 ++++
 style/subcaption.el               |  19 +-
 style/tabulary.el                 |   9 +-
 style/tcolorbox.el                | 133 ++++----
 style/tcolorboxlib-raster.el      |  24 +-
 style/tex-live.el                 |   5 +-
 style/theorem.el                  |   6 +-
 style/thmtools.el                 |   2 +-
 style/unicodefonttable.el         | 134 ++++++++
 style/url.el                      | 181 ++++++++--
 style/xparse.el                   | 104 ++++--
 style/xr-hyper.el                 |  73 ++++
 style/xr.el                       |  68 ++++
 tests/latex/latex-filling-in.tex  |  42 +++
 tests/latex/latex-filling-out.tex |  52 +++
 tests/latex/latex-test.el         |  59 +++-
 tex-bar.el                        |   6 -
 tex-buf.el                        |  48 +--
 tex-fold.el                       |   6 +-
 tex-info.el                       |  17 +-
 tex-jp.el                         |   2 +-
 tex.el                            |  56 +--
 texmathp.el                       |   4 +-
 77 files changed, 3459 insertions(+), 2433 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 5b5a49d..3ef294c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -78,8 +78,6 @@ WWWDIR = $(DIST_PREFIX)/www
 CTANDIR = $(DIST_PREFIX)/ctan
 PREVIEW_BUILD_DIR = preview-build
 COMMITTER="`git config --get user.name`\ \ \<`git config --get user.email`\>"
-RPMROOT = /usr/src/redhat
-RPM_SIGN = --sign
 
 AUCSRC = tex.el tex-buf.el tex-style.el plain-tex.el latex.el tex-info.el \
        texmathp.el multi-prompt.el tex-mik.el font-latex.el tex-font.el \
@@ -176,7 +174,11 @@ STYLESRC = style/prosper.el \
           style/appendix.el  style/scholax.el   style/extramarks.el \
           style/truncate.el  style/changes.el   style/footnotehyper.el \
           style/brazil.el    style/brazilian.el style/portuguese.el \
-          style/portuges.el
+          style/portuges.el  style/backref.el   style/xr-hyper.el \
+          style/xr.el        style/cancel.el    style/unicodefonttable.el \
+          style/cuted.el     style/floatpag.el  style/flushend.el \
+          style/midfloat.el  style/stabular.el  style/stfloats.el \
+          style/rotating.el  style/sidecap.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
@@ -216,7 +218,7 @@ all: texmf lisp docs
        install-docs install-auto install-startup                       \
        clean distclean maintainer-clean extraclean                     \
        tar-ball-clean check-tag check release-commit dist snapshot     \
-       patch tar-ball rpm-packages wc windows-package  \
+       patch tar-ball wc \
        release-sign release-upload preview-ball uninstall
 
 texmf: latex/Makefile
@@ -476,22 +478,17 @@ change-history-commit:
 # 3) dist TAG=<tag>
 #    Create the tar ball and other release files and put them into $FTPDIR.
 #
-# 4) windows-package WEMACSVER=<emacs-version> TAG=<tag>
-#    Create the precompiled AUCTeX package for Windows.
-#    This requires a compiled Emacs of the same version at location $WEMACS.
-#    NOTA BENE: you may need to use bash shell for this recipe to work.
-#
-# 5) release-sign TAG=<tag>
+# 4) release-sign TAG=<tag>
 #    Sign the tar ball and create directive files for upload.  NOTA BENE: you
 #    may need to use bash shell for this recipe to work.
 #
-# 6) release-upload
+# 5) release-upload
 #    Upload files to GNU FTP server.
 #
-# 7) www-doc TAG=<tag>
+# 6) www-doc TAG=<tag>
 #    Create documentation for AUCTeX home page.
 #
-# 8) preview-ball TAG=<tag>
+# 7) preview-ball TAG=<tag>
 #    Create preview package.  (Not for GNU FTP server but for CTAN.)
 
 dist: check-tag tar-ball
@@ -547,93 +544,10 @@ tar-ball: doc/Makefile
        $(CP) doc/auctex.ps doc/auctex.pdf doc/tex-ref.ps doc/tex-ref.pdf 
$(FTPDIR)
        $(CP) $(CHANGELOG_N) $(FTPDIR)
 
-rpm-packages:
-       rpmbuild -ta $(RPM_SIGN) $(FTPDIR)/auctex-$(TAG).tar.gz
-       $(CP) 
$(RPMROOT)/{RPMS/noarch/{auctex-emacs,preview-tetex},SRPMS/auctex}-$(TAG)[.-]* 
$(FTPDIR)
-       @echo "If you need to prepare RPM on some other system, you need to add"
-       @echo "them in $(FTPDIR) before 'make release-sign'."
-       sleep 2
-
 patch:
        diff -u auctex-$(OLD) auctex-$(TAG) | gzip --best \
                >$(FTPDIR)/auctex-$(OLD)-to-$(TAG).patch.gz
 
-# Pre-compiled AUCTeX package for Emacs on Windows
-WBUILDDIR=$(PWD)/windows-package
-WEMACS=/usr/src/emacs-$(WEMACSVER)/src/emacs
-WPACKAGE=auctex-$(TAG)-e$(WEMACSVER)-msw.zip
-# Starting from Emacs 24.4, the name of the Windows package and the tree
-# structure of the package have been changed.  The following variables cater 
for
-# these differences.
-ifeq ($(shell echo "$(WEMACSVER)" | grep '\(2[2-3].[1-4]\|24.[1-3]\)' 
-),$(WEMACSVER))
-       WEMACSDATAROOTDIR=""
-       WEMACSEXTRACTDIR=""
-       WEMACSPACKAGE="emacs-$(WEMACSVER)-bin-i386.zip"
-       WEMACSSITELISP="site-lisp"
-else
-       WEMACSDATAROOTDIR="share/"
-       WEMACSEXTRACTDIR="emacs-$(WEMACSVER)"
-# And just to add more complexity, the package name changed again with Emacs
-# 24.5.  Actually, we don't really need to keep track of all these changes as 
we
-# should support only the latest Emacs version, but unless something else
-# changes again again in the near future we can keep them (and it's useful to
-# reproduce old AUCTeX packages!).
-       ifeq (24.4,$(WEMACSVER))
-               WEMACSPACKAGE="emacs-$(WEMACSVER)-bin-i686-pc-mingw32.zip"
-       else
-               WEMACSPACKAGE="emacs-$(WEMACSVER)-bin-i686-mingw32.zip"
-       endif
-       WEMACSSITELISP="$(WEMACSDATAROOTDIR)/emacs/site-lisp"
-endif
-WPACKAGEFILES=$(WEMACSSITELISP)/auctex $(WEMACSSITELISP)/site-start.d \
-       $(WEMACSSITELISP)/site-start.el $(WEMACSSITELISP)/tex-site.el \
-       var/auctex $(WEMACSDOC) $(WEMACSDATAROOTDIR)doc 
$(WEMACSDATAROOTDIR)info/dir \
-       $(WEMACSDATAROOTDIR)info/auctex.info* 
$(WEMACSDATAROOTDIR)info/preview-latex.info*
-windows-package: check-tag
-       @if [ "X$(WEMACSVER)" = "X" ]; then \
-         echo "*** Error: No Emacs version (WEMACSVER) ***"; \
-         exit 1; \
-       fi
-# Make sure the prerequisites are available
-       test -d $(WBUILDDIR) || mkdir $(WBUILDDIR)
-       test -f $(WBUILDDIR)/$(WEMACSPACKAGE) \
-       || { cd $(WBUILDDIR) \
-       && wget https://ftp.gnu.org/gnu/emacs/windows/$(WEMACSPACKAGE); }
-       test -f $(WBUILDDIR)/auctex-$(TAG).zip \
-       || { test -f $(FTPDIR)/auctex-$(TAG).zip \
-         && $(CP) $(FTPDIR)/auctex-$(TAG).zip $(WBUILDDIR); } \
-       || { cd $(WBUILDDIR) \
-         && wget https://ftp.gnu.org/gnu/auctex/auctex-$(TAG).zip; }
-# Reset to clean state
-       cd $(WBUILDDIR) \
-       && rm -rf emacs-$(WEMACSVER) \
-       && rm -rf auctex-$(TAG) \
-       && unzip -d "$(WEMACSEXTRACTDIR)" $(WEMACSPACKAGE) \
-       && unzip auctex-$(TAG).zip
-       rm -f $(WPACKAGE)
-# Create site-start.el and site-start.d
-       cd $(WBUILDDIR)/emacs-$(WEMACSVER)/$(WEMACSSITELISP) \
-       && echo -e ";; Load files in \`site-start.d' directory.\
-\n(dolist (file (directory-files\
-\n            (concat (file-name-directory load-file-name) \"site-start.d\")\
-\n            t \"\\\\\\\\.el\\\\\\\\'\"))\
-\n  (load file nil t t))" > site-start.el \
-       && mkdir site-start.d
-# Build and install AUCTeX
-       cd $(WBUILDDIR)/auctex-$(TAG) \
-       && ./configure --prefix=$(WBUILDDIR)/emacs-$(WEMACSVER) \
-         --without-texmf-dir --with-emacs=$(WEMACS) \
-         --with-lispdir=$(WBUILDDIR)/emacs-$(WEMACSVER)/$(WEMACSSITELISP) \
-         --datarootdir=$(WBUILDDIR)/emacs-$(WEMACSVER)/$(WEMACSDATAROOTDIR) \
-       && $(MAKE) \
-       && sed -i -e 's/"\/[^\n]\+/(expand-file-name "..\/var\/auctex" 
(file-name-directory load-file-name))/' tex-site.el \
-       && $(MAKE) install
-# Create the package
-       test -d $(FTPDIR) || mkdir -p $(FTPDIR)
-       rm -f $(FTPDIR)/$(WPACKAGE)
-       cd $(WBUILDDIR)/emacs-$(WEMACSVER) \
-       && zip -r $(FTPDIR)/$(WPACKAGE) $(WPACKAGEFILES)
-
 release-sign: check-tag
        rm -f $(FTPDIR)/*.{directive,asc,sig}
        if [ "x$$GPG_AGENT_INFO" = "x" ]; then \
diff --git a/RELEASE b/RELEASE
index daa276a..954fe73 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1,4 +1,4 @@
-Release notes for AUCTeX 12.3 with preview-latex
+Release notes for AUCTeX 13.1 with preview-latex
 ================================================
 
 AUCTeX provides by far the most wide-spread and sophisticated
@@ -24,53 +24,122 @@ sleuth work, testing.
 New features and fixed bugs in this release
 -------------------------------------------
 
-Support for 'PSTricks' is now PDF-oriented.  AUCTeX no longer turns
-off PDF mode for 'PSTricks' documents even without 'pst-pdf'.  It
-now sets up 'TeX-PDF-from-DVI' option so that PDF output is
-generated when 'TeX-PDF-mode' is enabled (default).  Users who want
-DVI output should disable PDF mode explicitly by file local
-variable, or customize 'TeX-PDF-mode' to 'nil'.
-
-The function 'font-latex-update-font-lock' has been obsoleted in
-order to fix 'bug#37945'.  That function was used by several style
-files in order to refresh fontification after adding new symbols or
-verbatim constructs.  It is better to call 'font-lock-flush' in the
-former case and 'font-latex-set-syntactic-keywords' in the latter
-case.  The function 'font-latex-update-font-lock' still exists as a
-no-op which only shows a warning explaining how to update font-lock
-as mentioned above.
-
-Math expression highlighting was improved.  Highlighting for
-documents with a lot of inline math expressions '$...$' won't get
-scrambled now ('bug#33139').
-
-There is small incompatibility due to this fix.  When odd number of
-dollar signs are in a comment, the subsequent lines are highlighted
-as math until another '$' appears.  You can insert a commented
-dollar sign ('%$') at the next suitable end of line as a
-workaround.
-
-In addition, it is no longer recommended to customize
-'font-latex-math-environments'.  Use 'texmathp-tex-commands'
-instead.
-
-AUCTeX tracks changes in LaTeX2e 2020-02-02 release.  AUCTeX
-supports the improvements to LaTeX font selection mechanism (NFSS).
-New macros like '\textsw' or '\textulc' are added to font insertion
-keyboard commands.  See the section for inserting font specifiers
-for details.  Further, the entries in the menu LaTeX, Insert Font
-are reorganized and adjusted accordingly.
-
-Macros previously provided by 'textcomp.sty' are now part of LaTeX
-kernel.  AUCTeX tracks this change as well and support for the new
-macro '\legacyoldstylenums' is added.
-
-Insertion of environments in LaTeX documents (i.e.  'C-c C-e') was
-improved.  The former code had a few bugs, which sometimes resulted
-in either spurious empty line or spurious comment prefix, or both,
-especially when the region is active.  Those bugs are now fixed.
-
-More bugs fixed, other minor features implemented.
+Now two commands 'Texindex' and 'Texi2dvi' are available when you
+type 'C-c C-c' in Texinfo mode.  The command 'Texindex' runs
+'texindex' on index files and 'Texi2dvi' runs 'pdftexi2dvi' or
+'texi2dvi' according to the value of 'TeX-PDF-mode'.
+
+So you can typeset Texinfo documents into PDF or DVI format from
+within AUCTeX.
+
+AUCTeX's own help messages for LaTeX errors are now shown only for
+LaTeX runs.  AUCTeX shows raw error/warning messages found in
+'.log' files for runs of formats other than LaTeX, such as plain
+TeX, ConTeXt and Texinfo, as it does even for LaTeX runs when it
+can't find a matching entry in its own help message catalogue.
+
+Due to this change, customize option 'TeX-error-description-list'
+can no longer have a fallback entry that matches any error.  If
+your customized value includes such entry, typically '(".*" . "No
+help available")', please remove it.
+
+Two functions 'TeX-split-string' and 'TeX-assoc' are now obsolete
+and will be removed in future release.  If your personal code uses
+these functions, use 'split-string' and 'assoc-string' instead.
+
+The function 'TeX-read-key-val' now accepts a function call as
+second argument.  This change should help AUCTeX style writers who
+use 'TeX-arg-key-val' and have to deal with dynamic key-values.
+Example of usage:
+     (TeX-add-style-hook "foo"
+      (lambda ()
+        (TeX-add-symbols
+         '("bar" (TeX-arg-key-val (function-returning-key-val))))))
+
+Since AUCTeX 12.2, 'C-x C-w' accidentally disabled the parse on
+save in that buffer, even when you enabled 'TeX-auto-save' option.
+This bug was fixed.
+
+AUCTeX now requires GNU Emacs 24.3 or higher.
+
+Old implementations for viewers were discarded, as announced long
+before.  The variables 'TeX-output-view-style' and 'TeX-view-style'
+have no effect now.  The former placeholders '%v' and '%vv' in
+'TeX-command-list' are ignored.
+
+AUCTeX now uses lexical binding which has been introduced in Emacs
+24.  This change should have no user-visible effect and require no
+manual adaptions except in the following cases.
+
+   - Entries added to the customization variable 'TeX-expand-list'
+     also had access to variables 'command' and 'pos'.  Those are
+     now properly declared and named 'TeX-expand-command' and
+     'TeX-expand-pos'.
+
+   - Entries added to the customization variable 'TeX-expand-list'
+     had access to a variable 'file' which was bound to
+     'TeX-active-master', i.e., it evaluated to either the master
+     or region file.  This usage must be replaced with either
+     'TeX-active-master' or 'TeX-active-master-with-quotes'.
+
+   - Viewer entries in 'TeX-view-program-list' also had access to a
+     variable 'file' which was bound to the name of the master or
+     region file without extension.  Instead, the function
+     'TeX-active-master' has to be used now.
+
+   - Macro argument parsing functions could set a variable
+     'exit-mark' to the buffer position where point should be left
+     after all arguments have been read.  This variable is now
+     named 'TeX-exit-mark'.
+
+   - The functions in 'LaTeX-section-hook' had access or modified
+     the previously undeclared variables 'title', 'name', 'level',
+     'done-mark', and 'toc'.  These variables are now properly
+     declared and have the 'LaTeX-' prefix, e.g.,
+     'LaTeX-done-mark'.
+
+   - The functions in 'ConTeXt-numbered-section-hook' and
+     'ConTeXt-unnumbered-section-hook' had access or modified the
+     previously undeclared variables 'title', 'name', 'level',
+     'done-mark', and 'reference'.  These variables are now
+     properly declared and have the 'ConTeXt-' prefix, e.g.,
+     'ConTeXt-title'.
+
+   - The functions in 'TeX-translate-location-hook' could access
+     and modify the free variables 'file', 'line', 'error',
+     'offset', 'context', and 'string'.  Those are now properly
+     declared variables with the prefix 'TeX-translate-location-',
+     e.g., 'TeX-translate-location-file'.
+
+The constant 'LaTeX-dialect' has been renamed to 'TeX-dialect' and
+moved from 'latex.el' to 'tex.el'.  'LaTeX-dialect' now is an
+obsolete alias.
+
+The style 'latexinfo.el' is removed from AUCTeX.  'latexinfo.el'
+was meant to support latexinfo which in return was a LaTeX-2.09
+extension of Texinfo, but didn't manage to replace Texinfo.
+
+The style 'siunitx.el' is updated to support package version 3.
+Key-value options provided by older package versions are removed,
+deprecated macros and units are not supported anymore.
+
+AUCTeX has preliminary support for LaTeX-hooks.  Hooks provided by
+LaTeX kernel are known and available for completion in
+'\AddToHook', '\RemoveFromHook' and '\AddToHookNext'.
+
+AUCTeX is now able to place all generated output files, including
+those that are produced by applications running under AUCTeX,
+temporary files related to region processing and preview-latex
+files, in an output directory.  To use this feature, set the new
+user option 'TeX-output-dir' to the absolute path of the output
+directory or a relative path which would be interpreted as being
+relative to the master file in a multifile document.
+
+Note that this feature doesn't work if the document includes sub
+file placed in sub directory below the main file via '\include'
+command.
+
+Many other bugs were fixed.
 
 Requirements
 ------------
@@ -125,11 +194,12 @@ Mohammad Hossein Bateni, Fabrice Ben Hamouda, Thomas 
Baumann, Vincent
 Bela�che, Berend de Boer, Alex Branham, Uwe Brauer, Ken Brown, Joshua
 Buhl, Jean-Fran�ois Burnol, Patrice Dumas, Arash Esbati, Werner Fink,
 Miguel Frasson, Peter S. Galbraith, Mos� Giordano, Patrick Gundlach,
-Jobst Hoffmann, Tassilo Horn, Yvon Hevel, Orlando Iovino, Mads Jensen,
-Arne J�rgensen, David Kastrup, Ikumi Keita, Philip Kime, Oleh Krehel,
-Joost Kremers, Frank K�ster, Jan-�ke Larsson, Matthew Leach, Antoine
-Levitt, Leo Liu, Vladimir Lomov, Stefan Monnier, Dan Nicolaescu, Piet
-van Oostrum, Pieter Pareit, Nicolas Richard, Augusto Ritter Stoffel,
+Abdul-Lateef Haji-Ali, Jobst Hoffmann, Tassilo Horn, Yvon Hevel,
+Orlando Iovino, Mads Jensen, Arne J�rgensen, Philip Kaludercic, David
+Kastrup, Ikumi Keita, Philip Kime, Oleh Krehel, Joost Kremers, Frank
+K�ster, Jan-�ke Larsson, Matthew Leach, Brian Leung, Antoine Levitt,
+Leo Liu, Vladimir Lomov, Stefan Monnier, Dan Nicolaescu, Piet van
+Oostrum, Pieter Pareit, Nicolas Richard, Augusto Ritter Stoffel,
 Florent Rougon, Santiago Saavedra, Davide G. M. Salvetti, R�diger
 Sonderfeld, Holger Sparr, Mike Sperber, Reiner Steib, Christian
 Schlauer, Shiro Takeda, Mark Trettin (Please accept our apologies if
diff --git a/auctex.spec b/auctex.spec
deleted file mode 100644
index 286dd4b..0000000
--- a/auctex.spec
+++ /dev/null
@@ -1,223 +0,0 @@
-# Spec file for AUCTeX
-
-# Maintainer: auctex-devel@gnu.org
-
-# Copyright (C) 2002, 2004-2006, 2018 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 Street, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-
-%define FOR_SUSE    %{?suse_version:1}%{!?suse_version:0}
-
-%if %{FOR_SUSE}
-%define distri       .suse
-%define commongroup  Productivity/Editors/Emacs
-%define texgroup     Productivity/Publishing/TeX/Utilities
-%else
-%define distri       .fedora
-%define commongroup  Applications/Editors
-%define texgroup     Applications/Publishing
-%endif
-
-Summary:       Enhanced TeX modes for Emacsen
-Name:          auctex
-Version:       12.1
-Release:       1%{distri}
-License:       GPL
-Group:                 %{commongroup}
-URL:           https://www.gnu.org/software/auctex/
-Source0:        https://ftp.gnu.org/pub/gnu/auctex/%{name}-%{version}.tar.gz
-BuildArchitectures: noarch
-BuildRoot:     %{_tmppath}/%{name}-root
-
-%description
-AUCTeX is an extensible package that supports writing and formatting TeX files
-for most variants of Emacs.  
-
-AUCTeX supports many different TeX macro packages, including AMS-TeX, LaTeX,
-Texinfo and basic support for ConTeXt.  Documentation can be found under
-/usr/share/doc, e.g. the reference card (tex-ref.pdf) and the FAQ.  The AUCTeX
-manual is available in Emacs info (C-h i d m AUCTeX RET).  On the AUCTeX home
-page, we provide manuals in various formats.
-
-This version of AUCTeX comes with preview-latex, an addictive productivity
-tool providing a fine-grained interactive folding WYSIWYG display in the
-source buffer.
-
-%package emacs
-Summary:       Enhanced TeX modes for GNU Emacs
-Group:          %{commongroup}
-Requires:      emacs >= 24
-Obsoletes:      ge_auc emacs-auctex auctex preview-latex-emacs
-Conflicts:      emacspeak < 18
-Provides:       auctex
-
-%description emacs
-AUCTeX is an extensible package that supports writing and formatting TeX files
-for most variants of Emacs.  
-
-AUCTeX supports many different TeX macro packages, including AMS-TeX, LaTeX,
-Texinfo and basic support for ConTeXt.  Documentation can be found under
-/usr/share/doc, e.g. the reference card (tex-ref.pdf) and the FAQ.  The AUCTeX
-manual is available in Emacs info (C-h i d m AUCTeX RET).  On the AUCTeX home
-page, we provide manuals in various formats.
-
-This package is for GNU Emacs.  XEmacs is no longer supported.
-
-The package enables AUCTeX modes system-wide.  The README file
-contains information how users may override this choice.
-
-%package -n preview-tetex
-Summary:       LaTeX files for preview.sty
-Group:         %{texgroup}
-Requires:      tetex
-Obsoletes:     preview-latex-common
-Provides:      preview-tetex preview-latex-common
-
-%description -n preview-tetex
-The LaTeX package preview.sty can be used for extracting selected
-parts of LaTeX documents into graphics of their own.  Various TeX and
-editing applications use this as a subsystem.  AUCTeX by now comes
-with its own integrated version of preview-latex and the style files
-and does not require this package, and newer versions of teTeX might
-already contain preview.sty (in which case the resulting conflict is
-probably best solved by not installing this package).
-
-%prep
-%setup
-
-%build
-# The below will make the package build from a tar straight from Git
-# NOT RECOMMENDED, but useful for testing!
-test -f ./configure || ./autogen.sh
-%configure --with-emacs INSTALL_INFO=: --without-texmf-dir
-make
-pushd doc
-make tex-ref.pdf
-popd
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}{%{_datadir}/emacs/site-lisp,%{_infodir}}
-%if %{FOR_SUSE}
-cat <<EOFA > %{buildroot}%{_datadir}/emacs/site-lisp/suse-start-auctex.el
-;; suse-start-auctex.el
-;; This file enables AUCTeX globally:
-(load "auctex.el" nil t t)
-;; See (info "(auctex)Introduction") on how to disable AUCTeX.
-EOFA
-cat <<EOFP > 
%{buildroot}%{_datadir}/emacs/site-lisp/suse-start-preview-latex.el
-;; suse-start-preview-latex.el
-;; This file enables preview-latex globally:
-(load "preview-latex.el" nil t t)
-EOFP
-%else
-mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp/site-start.d
-%endif
-%makeinstall install-docs
-mkdir -p %{buildroot}%{_datadir}/texmf/tex/latex/preview
-cp -p preview/latex/*.{sty,def,cfg} 
%{buildroot}%{_datadir}/texmf/tex/latex/preview
-mkdir -p %{buildroot}%{_datadir}/texmf/doc/latex/styles
-cp -p preview/latex/preview.dvi %{buildroot}%{_datadir}/texmf/doc/latex/styles
-
-%post emacs
-/sbin/install-info --info-dir=%{_infodir} %{_infodir}/auctex.info
-/sbin/install-info --info-dir=%{_infodir} %{_infodir}/preview-latex.info
-
-%preun emacs
-# $1 is the number of versions of this package installed
-# after this uninstallation
-if [ $1 -eq 0 ]; then
-  /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/auctex.info
-  /sbin/install-info --delete --info-dir=%{_infodir} 
%{_infodir}/preview-latex.info
-fi
-%clean
-rm -rf %{buildroot}
-
-%post -n preview-tetex
-/usr/bin/mktexlsr %{_datadir}/texmf
-
-%postun -n preview-tetex
-/usr/bin/mktexlsr %{_datadir}/texmf
-
-%files -n preview-tetex
-%defattr(-,root,root)
-%{_datadir}/texmf/tex/latex/preview
-%config %{_datadir}/texmf/tex/latex/preview/prauctex.cfg
-%{_datadir}/texmf/doc/latex/styles/preview.dvi
-
-%files emacs
-%defattr(-,root,root)
-%doc RELEASE COPYING INSTALL README TODO FAQ CHANGES
-%doc doc/tex-ref.pdf
-# %doc --parents preview/RELEASE preview/README preview/INSTALL preview/TODO 
preview/FAQ
-%doc %{_infodir}/*
-# %exclude %{_infodir}/dir
-%{_datadir}/emacs/site-lisp/%{name}
-%{_localstatedir}/%{name}
-%config %{_datadir}/emacs/site-lisp/tex-site.el
-%if %{FOR_SUSE}
-%{_datadir}/emacs/site-lisp/auctex.el
-%{_datadir}/emacs/site-lisp/preview-latex.el
-%{_datadir}/emacs/site-lisp/suse-start-auctex.el
-%{_datadir}/emacs/site-lisp/suse-start-preview-latex.el
-%else
-%{_datadir}/emacs/site-lisp/site-start.d/auctex.el
-%{_datadir}/emacs/site-lisp/site-start.d/preview-latex.el
-%endif
-
-
-%changelog
-# Shouldn't changelog include changes in the package instead of changes in the
-# spec file?
-
-* Tue Jun  6 2006 Reiner Steib  <Reiner.Steib@gmx.de>
-- Update to AUCTeX 11.83
-
-* Wed Dec 28 2005 Reiner Steib  <Reiner.Steib@gmx.de>
-- Remove bogus preview directory.  Add preview-latex in description.
-
-* Sat Dec 17 2005 Reiner Steib  <Reiner.Steib@gmx.de>
-- Update for AUCTeX 11.82.
-
-* Tue May  3 2005 David Kastrup <dak@gnu.org>
-- include preview-latex, so outdate other stuff.
-
-* Fri Jan 21 2005 David Kastrup <dak@gnu.org>
-- Conflict with outdated Emacspeak versions
-
-* Fri Jan 14 2005 David Kastrup <dak@gnu.org>
-- Install and remove auctex.info, not auctex
-
-* Thu Aug 19 2004 David Kastrup <dak@gnu.org>
-- Change tex-site.el to overwriting config file mode.  New naming scheme.
-
-* Mon Aug 16 2004 David Kastrup <dak@gnu.org>
-- Attempt a bit of SuSEism.  Might work if we are lucky.
-
-* Sat Dec  7 2002 David Kastrup <David.Kastrup@t-online.de>
-- Change addresses to fit move to Savannah.
-
-* Mon Apr 15 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Adjusted TeX-macro-global and put autoactivation in preinstall
-  script so that it can be chosen at install time.
-
-* Tue Feb 19 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Added site-start.el support
-
-* Sat Feb 16 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Prerelease 11.11
diff --git a/configure.ac b/configure.ac
index f035c77..a435cb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl along with AUCTeX; see the file COPYING.  If not, write 
to the Free
 dnl Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 dnl MA 02110-1301, USA.
 
-AC_INIT(auctex,12.3,bug-auctex@gnu.org)
+AC_INIT(auctex,13.1,bug-auctex@gnu.org)
 
 AC_CHECK_PROGS_REQUIRED(MAKECMD, make, [make not found, aborting!])
 AC_PROG_MAKE_SET
diff --git a/context-en.el b/context-en.el
index d79158c..f4b8fdf 100644
--- a/context-en.el
+++ b/context-en.el
@@ -75,7 +75,7 @@
     "indenting" "label"
     "logo" "overlay"
     "palet" "program" "startstop" "type" "typing")
-  "List of the names of ConTeXt en interface  macro's that define things.")
+  "List of the names of ConTeXt en interface macro's that define things.")
 
 (defvar ConTeXt-setup-list-en
   '("align" "arranging" "background" "backgrounds" "blackrules"
@@ -94,7 +94,7 @@
     "screens" "section" "sectionblock" "sorting" "spacing"
     "subpagenumber" "synonyms" "text" "textrules" "texttexts" "thinrules"
     "tolerance" "top" "toptexts" "type" "typing" "underbar" "whitespace")
-  "List of the names of ConTeXt en interface  macro's that setup things.")
+  "List of the names of ConTeXt en interface macro's that setup things.")
 
 ;; referencing in ConTeXt
 (defvar ConTeXt-referencing-list-en
@@ -208,8 +208,8 @@ Special commands:
 \\{ConTeXt-mode-map}
 
 Entering `context-mode' calls the value of `text-mode-hook',
-then the value of TeX-mode-hook, and then the value
-of context-mode-hook."
+then the value of `TeX-mode-hook', and then the value
+of `ConTeXt-mode-hook'."
   (interactive)
   ;; set the ConTeXt interface
   (setq ConTeXt-current-interface "en")
diff --git a/context-nl.el b/context-nl.el
index 5be65f6..9b49cce 100644
--- a/context-nl.el
+++ b/context-nl.el
@@ -92,7 +92,7 @@
 ;; referencing in ConTeXt
 (defvar ConTeXt-referencing-list-nl
   '("in" "op" "over" "paginareferentie" "tekstreferentie" "referentie")
-  "List of ConTeXt en macro's that are used for referencing."
+  "List of ConTeXt nl macro's that are used for referencing."
 )
 
 (defvar ConTeXt-other-macro-list-nl
@@ -183,8 +183,8 @@ Special commands:
 \\{ConTeXt-mode-map}
 
 Entering `context-mode' calls the value of `text-mode-hook',
-then the value of TeX-mode-hook, and then the value
-of context-mode-hook."
+then the value of `TeX-mode-hook', and then the value
+of `ConTeXt-mode-hook'."
   (interactive)
 
   ;; set the ConTeXt interface
diff --git a/context.el b/context.el
index eac68e4..1396635 100644
--- a/context.el
+++ b/context.el
@@ -137,14 +137,14 @@
 ;; Referencing ConTeXt macro's
 
 (defvar ConTeXt-referencing-list ()
-  "Calls ConTeXt-XX-other-macro-list where XX is the current interface.")
+  "Calls ConTeXt-XX-referencing-list where XX is the current interface.")
 
 (defun ConTeXt-referencing-command (what)
   "The ConTeXt macro to call WHAT is itself, no interface specific calls."
   what)
 
 (defun ConTeXt-insert-referencing (what)
-  "Insert the ConTeXt referencing SETUP."
+  "Insert the ConTeXt referencing WHAT."
   (insert TeX-esc (ConTeXt-referencing-command what))
   (newline)
   (indent-according-to-mode)
@@ -174,7 +174,8 @@
   "Calls ConTeXt-XX-project-structure where XX is the current interface.")
 
 (defun ConTeXt-project-structure (N)
-  "Insert a ConTeXt project structure where N is in index into 
`ConTeXt-project-structure-list'."
+  "Insert a ConTeXt project structure.
+N is in index into `ConTeXt-project-structure-list'."
   (funcall (intern(concat
                    "ConTeXt-project-"
                    (nth N ConTeXt-project-structure-list)
@@ -352,10 +353,10 @@ section."
         (ConTeXt-up-section (1- arg))))))
 
 (defvar ConTeXt-numbered-section-list ()
-  "ConTeXt-XX-section-list where XX is the current interface.")
+  "ConTeXt-XX-numbered-section-list where XX is the current interface.")
 
 (defvar ConTeXt-unnumbered-section-list ()
-  "ConTeXt-XX-section-list where XX is the current interface.")
+  "ConTeXt-XX-unnumbered-section-list where XX is the current interface.")
 
 (defvar ConTeXt-section-list
   (append ConTeXt-numbered-section-list ConTeXt-unnumbered-section-list)
@@ -387,7 +388,7 @@ section."
 
 (defun ConTeXt-unnumbered-section-level (name)
   "Return the level of the section NAME."
-  (let ((entry (TeX-member name ConTeXt-numbered-section-list
+  (let ((entry (TeX-member name ConTeXt-unnumbered-section-list
                            (function (lambda (a b) (equal a (nth 0 b)))))))
     (if entry
         (nth 1 entry)
@@ -408,7 +409,7 @@ The following variables are set before the hooks are run
 `ConTeXt-level'     - numeric section level, see the documentation of
                       `ConTeXt-section'.
 `ConTeXt-name'      - name of the sectioning command, derived from
-                      `level'.
+                      `ConTeXt-level'.
 `ConTeXt-title'     - The title of the section, default to an empty
                       string.
 `ConTeXt-done-mark' - Position of point afterwards, default nil
@@ -509,8 +510,9 @@ in your .emacs file."
 
 (defun ConTeXt-numbered-section-heading ()
   "Hook to prompt for ConTeXt section name.
-Insert this hook into `ConTeXt-numbered-section-hook' to allow the user to 
change
-the name of the sectioning command inserted with `\\[ConTeXt-section]'."
+Insert this hook into `ConTeXt-numbered-section-hook' to allow
+the user to change the name of the sectioning command inserted
+with `\\[ConTeXt-section]'."
   (let ((string (completing-read
                  (concat "Select level (default " ConTeXt-name "): ")
                  ConTeXt-numbered-section-list
@@ -521,8 +523,9 @@ the name of the sectioning command inserted with 
`\\[ConTeXt-section]'."
 
 (defun ConTeXt-unnumbered-section-heading ()
   "Hook to prompt for ConTeXt section name.
-Insert this hook into `ConTeXt-unnumbered-section-hook' to allow the user to 
change
-the name of the sectioning command inserted with `\\[ConTeXt-section]'."
+Insert this hook into `ConTeXt-unnumbered-section-hook' to allow
+the user to change the name of the sectioning command inserted
+with `\\[ConTeXt-section]'."
   (let ((string (completing-read
                  (concat "Select level (default " ConTeXt-name "): ")
                  ConTeXt-unnumbered-section-list
@@ -533,8 +536,9 @@ the name of the sectioning command inserted with 
`\\[ConTeXt-section]'."
 
 (defun ConTeXt-section-title ()
   "Hook to prompt for ConTeXt section title.
-Insert this hook into `ConTeXt-(un)numbered-section-hook' to allow the user to 
change
-the title of the section inserted with `\\[ConTeXt-section]."
+Insert this hook into `ConTeXt-(un)numbered-section-hook' to
+allow the user to change the title of the section inserted with
+`\\[ConTeXt-section]."
   (setq ConTeXt-title (TeX-read-string "What title: ")))
 
 (defun ConTeXt-section-section ()
@@ -562,8 +566,8 @@ assumes the section already is inserted."
 
 (defun ConTeXt-section-ref ()
   "Hook to insert a reference after the sectioning command.
-Insert this hook into `ConTeXt-numbered-section-hook' to prompt for a label to 
be
-inserted after the sectioning command."
+Insert this hook into `ConTeXt-numbered-section-hook' to prompt
+for a label to be inserted after the sectioning command."
   (setq ConTeXt-reference
         (completing-read
          (TeX-argument-prompt t nil
@@ -860,7 +864,8 @@ An entry looks like: (\"environment\" . function)")
       (buffer-substring beg (point)))))
 
 (defun ConTeXt-last-unended-start ()
-  "Leave point at the beginning of the last `\\start...' that is unstopped 
looking from the current cursor."
+  "Leave point at the beginning of the last unstopped `\\start...'.
+Look back from the current cursor."
   (while (and (re-search-backward "\\\\start[a-zA-Z]*\\|\\\\stop[a-zA-Z]*")
               (looking-at "\\\\stop[a-zA-Z]*"))
     (ConTeXt-last-unended-start)))
@@ -1345,20 +1350,20 @@ else.  There might be text before point."
 (defvar ConTeXt-environment-menu-name "Insert Environment   (C-c C-e)")
 
 (defun ConTeXt-environment-menu-entry (entry)
-  "Create an entry for the environment menu."
+  "Create an ENTRY for the environment menu."
   (vector (car entry) (list 'ConTeXt-environment-menu (car entry)) t))
 
 (defvar ConTeXt-environment-modify-menu-name "Change Environment   (C-u C-c 
C-e)")
 
 (defun ConTeXt-environment-modify-menu-entry (entry)
-  "Create an entry for the change environment menu."
+  "Create an ENTRY for the change environment menu."
   (vector (car entry) (list 'ConTeXt-modify-environment (car entry)) t))
 
 ;; ConTeXt define macros
 (defvar ConTeXt-define-menu-name "Define")
 
 (defun ConTeXt-define-menu-entry (entry)
-  "Create an entry for the define menu."
+  "Create an ENTRY for the define menu."
   (vector entry (list 'ConTeXt-define-menu entry)))
 
 (defun ConTeXt-define-menu (define)
@@ -1369,7 +1374,7 @@ else.  There might be text before point."
 (defvar ConTeXt-setup-menu-name "Setup")
 
 (defun ConTeXt-setup-menu-entry (entry)
-  "Create an entry for the setup menu."
+  "Create an ENTRY for the setup menu."
   (vector entry (list 'ConTeXt-setup-menu entry)))
 
 (defun ConTeXt-setup-menu (setup)
@@ -1380,7 +1385,7 @@ else.  There might be text before point."
 (defvar ConTeXt-referencing-menu-name "Referencing")
 
 (defun ConTeXt-referencing-menu-entry (entry)
-  "Create an entry for the referencing menu."
+  "Create an ENTRY for the referencing menu."
   (vector entry (list 'ConTeXt-referencing-menu entry)))
 
 (defun ConTeXt-referencing-menu (referencing)
@@ -1391,7 +1396,7 @@ else.  There might be text before point."
 (defvar ConTeXt-other-macro-menu-name "Other macro")
 
 (defun ConTeXt-other-macro-menu-entry (entry)
-  "Create an entry for the other macro menu."
+  "Create an ENTRY for the other macro menu."
   (vector entry (list 'ConTeXt-other-macro-menu entry)))
 
 (defun ConTeXt-other-macro-menu (other-macro)
@@ -1404,7 +1409,7 @@ else.  There might be text before point."
 (defvar ConTeXt-project-structure-menu-name "Project Structure")
 
 (defun ConTeXt-project-structure-menu (project-structure)
-  "Insert project structure from menu."
+  "Insert PROJECT-STRUCTURE from menu."
   (ConTeXt-project-structure
    (let ((l ConTeXt-project-structure-list))
      (- (length l) (length (member project-structure l))))))
@@ -1419,7 +1424,7 @@ else.  There might be text before point."
 (defvar ConTeXt-section-block-menu-name "Section Block")
 
 (defun ConTeXt-section-block-menu (section-block)
-  "Insert section block from menu."
+  "Insert SECTION-BLOCK from menu."
   (ConTeXt-section-block section-block))
 
 (defun ConTeXt-section-block-menu-entry (entry)
@@ -1693,7 +1698,7 @@ file, or any mode derived thereof. See variable
     "-mprun\\.mp" "-mprun\\.mpd" "-mprun\\.mpo" "-mprun\\.mpy")
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
@@ -1701,7 +1706,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
   '("\\.dvi" "\\.pdf" "\\.ps")
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
@@ -1820,7 +1825,7 @@ Special commands:
 
 Entering `context-mode' calls the value of `text-mode-hook',
 then the value of `TeX-mode-hook', and then the value
-of ConTeXt-mode-hook."
+of `ConTeXt-mode-hook'."
   (interactive)
   (context-guess-current-interface)
   (require (intern (concat "context-" ConTeXt-current-interface)))
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 5f8df63..8723bb6 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -1366,8 +1366,7 @@ called with prefix argument (@kbd{C-u}), it's the other 
way round.
 @c other way round" means.
 
 Note that for some macros, there are special mechanisms, e.g.@:
-@code{LaTeX-includegraphics-options-alist} and
-@code{TeX-arg-cite-note-p}.
+@code{TeX-arg-cite-note-p} and @code{LaTeX-includegraphics-options-alist}.
 @end defopt
 
 
@@ -2713,7 +2712,7 @@ expression matching a header, and the second is the level 
of the header.
 A @samp{^} is automatically prepended to the regular expressions in the
 list, so they must match text at the beginning of the line.
 
-See @code{LaTeX-section-list} or @code{ConTeXt-INTERFACE-section-list}
+See @code{LaTeX-section-list} or @code{ConTeXt-@var{interface}-section-list}
 for existing header levels.
 @end defvar
 
@@ -3023,7 +3022,8 @@ following form.
 @lisp
 (eval-after-load "tex"
   '(add-to-list 'TeX-command-list
-                '("Foo" "foo %s" TeX-run-command t t :help "Run foo") t))
+                '("Foo" "foo %s" TeX-run-command t t :help "Run foo")
+                t))
 @end lisp
 
 As mentioned before, @AUCTeX{} will try to guess what command you want
@@ -3637,6 +3637,22 @@ bring it to front and display the output page 
corresponding to the
 position of point in the source file.  @AUCTeX{} will automatically pass
 the necessary command line options to the viewer for this to happen.
 
+@vindex TeX-source-correlate-map
+@findex TeX-view-mouse
+You can also make special mouse event do forward search at the clicked
+position.  Use @code{TeX-source-correlate-map}@footnote{The keymap name is
+@code{TeX-source-correlate-map}, not @code{TeX-source-correlate-mode-map}.
+Actually, this keymap isn't implemented as minor mode map of
+@code{TeX-source-correlate-mode}, in order that its bindings don't affect
+buffers outside of @AUCTeX{}.} and @code{TeX-view-mouse} like this:
+@lisp
+(eval-after-load "tex"
+  '(define-key TeX-source-correlate-map [C-down-mouse-1]
+               #'TeX-view-mouse))
+@end lisp
+This example binds @kbd{C-down-mouse-1}, which usually opens a concise
+menu to select buffer, to the command to do forward search.
+
 @vindex TeX-source-correlate-start-server
 Upon opening the viewer you will be asked if you want to start a server
 process (Gnuserv or Emacs server) which is necessary for inverse search.
@@ -4103,7 +4119,7 @@ functions and hooks.
 @vindex LaTeX-mode-hook
 @findex ams-tex-mode
 @vindex AmS-TeX-mode-hook
-@findex ConTeXt-mode
+@findex context-mode
 @vindex ConTeXt-mode-hook
 @findex texinfo-mode
 @vindex Texinfo-mode-hook
@@ -5610,6 +5626,8 @@ Expert environments are completed depending on 
@code{TeX-complete-expert-command
 @cindex Bibliographies, adding
 @cindex Examining package/class options
 @cindex package/class options, Examining
+@cindex Adding support for completion of package/class options
+@cindex support for completion of package/class options, Adding
 @cindex Viewer predicates
 @cindex Defining bibliographies in style hooks
 @cindex Adding labels
@@ -5633,10 +5651,10 @@ Add each @var{bibliography} to list of loaded 
bibliographies.
 Add each @var{label} to the list of known labels.
 @end defun
 
-@subsubsection Examining package/class options
+@subsubsection Examining Package/Class Options
 
 In @LaTeX{} documents, style hooks can find the package names and those
-options given as optional argument(s) of @code{\usepackage} in
+options given as optional argument(s) of @samp{\usepackage} in
 @code{LaTeX-provided-package-options}.
 
 @defvar LaTeX-provided-package-options
@@ -5645,7 +5663,7 @@ packages.  Each element is a cons cell 
@code{(@var{package}
 . @var{option-list})}.  For example, its value will be
 @lisp
   (("babel" . ("german"))
-   ("geometry" . ("a4paper" "top=2cm" "bottom=2cm" "left=2.5cm" "right=2.5cm"))
+   ("geometry" . ("a4paper" "top=2cm" "left=2.5cm" "right=2.5cm"))
    ...)
 @end lisp
 @end defvar
@@ -5685,6 +5703,62 @@ first found class option matching @var{regexp}, or nil 
if not found.
 These functions are also useful to implement customized predicate(s) in
 @code{TeX-view-predicate-list}.  @xref{Starting Viewers}.
 
+@subsubsection Adding Support for Option Completion
+When the user inserts @samp{\usepackage} by @kbd{C-c C-m}, @AUCTeX{} asks
+for the optional arguments after the package name is given.  The style
+file of that package can provide completion support for the optional
+arguments.
+
+@defvar LaTeX-@var{packagename}-package-options
+List of optional arguments available for the package.
+@end defvar
+
+Here is an excerption from @samp{acronym.el}:
+@lisp
+(defvar LaTeX-acronym-package-options
+  '("footnote" "nohyperlinks" "printonlyused" "withpage"
+    "smaller" "dua" "nolist")
+  "Package options for the acronym package.")
+@end lisp
+
+When the package accepts key-value style optional arguments, more
+sophisticated completion support is needed.  The package style file can
+provide dynamic completion support by custom elisp function.
+
+@defun LaTeX-@var{packagename}-package-options
+This function should ask the user for optional arguments and return them
+as a string, instead of built-in option query facility.  When this function
+is defined, @AUCTeX{} calls it with no argument.
+@end defun
+
+Here is an excerption from @samp{acro.el}:
+@lisp
+(defun LaTeX-acro-package-options ()
+  "Prompt for package options for the acro package."
+  (TeX-read-key-val t LaTeX-acro-package-options-list))
+@end lisp
+
+As you can see in the above example, a utility function
+@code{TeX-read-key-val} is available to read key-value pair(s) from users.
+
+Note that @code{defvar} or @code{defun} of
+@code{LaTeX-@var{packagename}-package-options} should be at the top level
+of the style file and not inside the style hook, because the style hook is
+not yet called when the user inputs the optional arguments in response to
+@kbd{C-c C-m}.
+
+There are similar facilities for class options.  When the user inserts
+@samp{\documentclass} by @kbd{C-c C-e}, the respective class style file
+can provide completion support for the optional arguments.
+
+@defvar LaTeX-@var{classname}-class-options
+List of optional arguments available for the class.
+@end defvar
+
+@defun LaTeX-@var{classname}-class-options
+Which see.
+@end defun
+
 @node Hacking the Parser
 @subsection Automatic Extraction of New Things
 @cindex Parsing new macros
diff --git a/doc/changes.texi b/doc/changes.texi
index 64bf838..a377d45 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -12,6 +12,16 @@
 
 @itemize @bullet
 @item
+Now two commands @samp{Texindex} and @samp{Texi2dvi} are available when
+you type @kbd{C-c C-c} in Texinfo mode.  The command @samp{Texindex} runs
+@command{texindex} on index files and @samp{Texi2dvi} runs
+@command{pdftexi2dvi} or @command{texi2dvi} according to the value of
+@code{TeX-PDF-mode}.
+
+So you can typeset Texinfo documents into @acronym{PDF} or @acronym{DVI}
+format from within @AUCTeX{}.
+
+@item
 @AUCTeX{}'s own help messages for @LaTeX{} errors are now shown only for
 @LaTeX{} runs.  @AUCTeX{} shows raw error/warning messages found in
 @file{.log} files for runs of formats other than @LaTeX{}, such as plain
@@ -30,6 +40,18 @@ uses these functions, use @code{split-string} and 
@code{assoc-string}
 instead.
 
 @item
+The function @code{TeX-read-key-val} now accepts a function call as second
+argument.  This change should help @AUCTeX{} style writers who use
+@code{TeX-arg-key-val} and have to deal with dynamic key-values.  Example
+of usage:
+@lisp
+(TeX-add-style-hook "foo"
+ (lambda ()
+   (TeX-add-symbols
+    '("bar" (TeX-arg-key-val (function-returning-key-val))))))
+@end lisp
+
+@item
 Since @AUCTeX{} 12.2, @kbd{C-x C-w} accidentally disabled the parse on
 save in that buffer, even when you enabled @code{TeX-auto-save} option.
 This bug was fixed.
@@ -107,6 +129,11 @@ The style @file{latexinfo.el} is removed from @AUCTeX{}.
 @LaTeX{}-2.09 extension of Texinfo, but didn't manage to replace Texinfo.
 
 @item
+The style @file{siunitx.el} is updated to support package version 3.
+Key-value options provided by older package versions are removed,
+deprecated macros and units are not supported anymore.
+
+@item
 @AUCTeX{} has preliminary support for @LaTeX{}-hooks.  Hooks provided by
 @LaTeX{} kernel are known and available for completion in
 @samp{\AddToHook}, @samp{\RemoveFromHook} and @samp{\AddToHookNext}.
@@ -119,6 +146,12 @@ directory.  To use this feature, set the new user option
 @code{TeX-output-dir} to the absolute path of the output directory or a
 relative path which would be interpreted as being relative to the master
 file in a multifile document.
+
+Note that this feature doesn't work if the document includes sub file
+placed in sub directory below the main file via @samp{\include} command.
+
+@item
+Many other bugs were fixed.
 @end itemize
 
 @heading News in 12.3
diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index 25577e5..26adb89 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -135,7 +135,7 @@ Installation is now being covered in
 
 @cindex Menu entries
 @previewlatex{} adds key bindings starting with @kbd{C-c C-p} to the
-supported modes of @AUCTeX{} (@inforef{Key Index,,auctex}).  It will
+supported modes of @AUCTeX{} (@xref{Key Index,,,auctex}).  It will
 also add its own @samp{Preview} menu in the menu bar, as well as an icon
 in the toolbar.
 
@@ -638,7 +638,7 @@ the two commands gets used depends on the setting of
 @code{preview-fast-conversion}.  The printer specified here
 is @option{-Pwww} by default, which will usually get you scalable fonts
 where available.  If you are experiencing problems, you might want to try
-playing around with Dvips options (@inforef{Command-line options,,dvips}).
+playing around with Dvips options (@xref{Command-line options,,,dvips}).
 
 The conversion of the previews into PostScript or @acronym{EPS} files
 gets started after the @LaTeX{} run completes when Emacs recognizes the
diff --git a/doc/preview-problems.texi b/doc/preview-problems.texi
index 282bd1a..e40ff42 100644
--- a/doc/preview-problems.texi
+++ b/doc/preview-problems.texi
@@ -109,16 +109,16 @@ PSTricks, which Dvips would otherwise reserve no space 
for.
 Thanks to the work of Christoph Wedler, starting with version
 @samp{4.0h/beta} of x-symbol, the line parsing of @AUCTeX{} and
 @previewlatex{} is fully supported.  Earlier versions exhibit problems.
-However, versions before 4.2.2 will cause a drastic slowdown of
+However, versions before @samp{4.2.2} will cause a drastic slowdown of
 @previewlatex{}'s parsing pass, so we don't recommend to use versions
 earlier than that.
 
 If you wonder what x-symbol is, it is a package that transforms various
 tokens and subscripts to a more readable form while editing and offers a
 few input methods handy especially for dealing with math. Take a look at
-@uref{http://x-symbol.sourceforge.net}.
+@uref{http://x-symbol.sourceforge.net/}.
 
-x-symbol versions up to 4.5.1-beta at least require an 8bit-clean @TeX{}
+x-symbol versions up to @samp{4.5.1-beta} at least require an 8bit-clean @TeX{}
 implementation (meaning that its terminal output should not use
 @samp{^^}-started escape sequences) for cooperation with
 @previewlatex{}.  Later versions may get along without it, like
diff --git a/doc/preview-readme.texi b/doc/preview-readme.texi
index 70fd0c2..8d4c565 100644
--- a/doc/preview-readme.texi
+++ b/doc/preview-readme.texi
@@ -196,8 +196,10 @@ project page}.  You can get its files from the
 @w{@AUCTeX{} 11.81}, @previewlatex{} should already be integrated into
 @AUCTeX{}, so no separate download will be necessary.
 
-You will also find @file{.rpm} files there for Fedora and possibly
-SuSE.  Anonymous Git is available as well.
+Anonymous Git is available at @uref{git://git.savannah.gnu.org/auctex.git}
+or @uref{https://git.savannah.gnu.org/git/auctex.git}.  You can also
+@uref{https://git.savannah.gnu.org/cgit/auctex.git,browse the repository}
+via web interface.
 
 @node  Contacts,  , Availability, Introduction
 @section Contacts
diff --git a/doc/tex-ref.tex b/doc/tex-ref.tex
index 2affa85..d725eb5 100644
--- a/doc/tex-ref.tex
+++ b/doc/tex-ref.tex
@@ -1,4 +1,4 @@
-% Reference Card for AUCTeX version 12.3
+% Reference Card for AUCTeX version 13.1
 %**start of header
 \newcount\columnsperpage
 
@@ -42,9 +42,9 @@
 % Paul Rubin, Bob Chassell, Len Tower, and Richard Mlynarik
 % for creating the GNU Emacs Reference Card from which this was mutated
 
-\def\versionnumber{12.3}
-\def\year{2020}
-\def\version{October \year\ v\versionnumber}
+\def\versionnumber{13.1}
+\def\year{2021}
+\def\version{December \year\ v\versionnumber}
 
 \def\shortcopyrightnotice{\vskip 1ex plus 2 fill
   \centerline{\small \copyright\ \year\ Free Software Foundation, Inc.
@@ -53,7 +53,7 @@
 \def\copyrightnotice{%
 \vskip 1ex plus 2 fill\begingroup\small
 \centerline{Copyright \copyright\ 1987, 1992-1994, 2004-2006, 2008, 2010,}
-\centerline{2012, 2014-2017, 2019-2020 Free Software Foundation, Inc.}
+\centerline{2012, 2014-2017, 2019-2021 Free Software Foundation, Inc.}
 \centerline{for AUC\TeX\ version \versionnumber}
 
 Permission is granted to make and distribute copies of
diff --git a/doc/todo.texi b/doc/todo.texi
index 3c0c13f..2f09f29 100644
--- a/doc/todo.texi
+++ b/doc/todo.texi
@@ -61,27 +61,34 @@ using Ref@TeX{}.
 
 @item Fix remove-style feature
 
-Currently @code{TeX-remove-style} implementation isn't good. It is
-common practice that major mode functions directly add macros and
-environments via @code{TeX-add-symbols} and
-@code{LaTeX-add-environments}, but those macros and environments are
-lost once @code{TeX-remove-style} runs. It is necessary to run major
-mode function, by e.g.@: @code{normal-mode}, again to recover them, but
-that makes no point in running @code{TeX-remove-style} itself because
-major mode function kills all buffer-local variables.
+Currently @code{TeX-remove-style} implementation isn't good.  It is common
+practice that major mode functions directly add macros and environments
+via @code{TeX-add-symbols} and @code{LaTeX-add-environments}, but those
+macros and environments are lost once @code{TeX-remove-style} runs.  It is
+necessary to run major mode function, by e.g.@: @code{normal-mode}, again
+to recover them, but that makes no point in running
+@code{TeX-remove-style} itself because major mode function kills all
+buffer-local variables.
 
 As of @AUCTeX{} 12.3, @code{TeX-remove-style} is no longer used by any
 other codes.
 
 @item
-Document @code{LaTeX-insert-into-commments} and
-@code{TeX-translate-location-hook}.
+Document @code{LaTeX-insert-into-commments},
+@code{TeX-translate-location-hook}, and usage of @ConTeXt{} mode.
 @end itemize
 
 @node Wishlist
 @section Wishlist
 
 @itemize @bullet
+@item
+Simplify tool bar implementation.  The library @file{toolbar-x.el} was
+developed as an abstraction layer to absorb difference between XEmacs
+and @acronym{GNU} Emacs.  Now that XEmacs is no longer supported, the
+library, together with @file{tex-bar.el} as a whole, can be much
+simplified (or even unified).
+
 @item Documentation lookup for macros
 
 A parser could gather information about which macros are defined in
diff --git a/font-latex.el b/font-latex.el
index 18c04d5..5f1f888 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -240,13 +240,14 @@ variable `font-latex-fontify-sectioning'." ',num)
   '(("warning"
      ("nopagebreak" "pagebreak" "newpage" "clearpage" "cleardoublepage"
       "enlargethispage" "nolinebreak" "linebreak" "newline" "-" "\\" "\\*"
-      "appendix" "displaybreak" "allowdisplaybreaks" "include")
+      "appendix" "displaybreak" "allowdisplaybreaks" "tabularnewline" 
"include")
      font-latex-warning-face 1 noarg)
     ("variable"
      (("setlength" "|{\\{") ("settowidth" "|{\\{") ("settoheight" "{{")
       ("settodepth" "{{") ("setcounter" "{|{\\")
       ("addtolength" "|{\\{") ("addtocounter" "{|{\\")
       ("stepcounter" "{") ("refstepcounter" "{")
+      ("counterwithin" "*[{{") ("counterwithout" "*[{{")
       ("arabic" "{") ("roman" "{") ("Roman" "{") ("alph" "{") ("Alph" "{")
       ("fnsymbol" "{"))
      font-lock-variable-name-face 2 command)
@@ -733,9 +734,9 @@ keywords, a face and a specifier for the type of macro to be
 highlighted.
 
 When adding new entries, you have to use unique values for the
-class names, i.e. they must not clash with names of the built-in
-keyword classes or other names given by you.  Additionally the
-names must not contain spaces.
+class names, that is, they must not clash with names of the
+built-in keyword classes or other names given by you.
+Additionally the names must not contain spaces.
 
 The list of keywords defines which commands and declarations
 should be covered by the keyword class.  A keyword can either be
@@ -918,8 +919,8 @@ locking machinery will be triggered."
 
 By default, super/subscripts are raised/lowered if this variable
 is non-nil.  This fontification only affects one level of
-scripts, e.g., in x^{y^z}, the y and the z have the same size and
-are equally raised over x.
+scripts, for example in x^{y^z}, the y and the z have the same
+size and are equally raised over x.
 
 If this variable is set to the symbol `multi-level', then y is
 raised above x, and z is raised above y.  With many script
@@ -1316,7 +1317,7 @@ If SYNTACTIC-KWS is non-nil, also update
 It is obsolete and going to be removed.
 If you have called `font-latex-add-keywords' and want to refresh fontification,
 call `font-lock-flush' instead.
-If you changed syntactic fontification, e.g., one of the variables
+If you changed syntactic fontification, for example, one of the variables
 - `LaTeX-verbatim-macros-with-delims'
 - `LaTeX-verbatim-macros-with-delims-local'
 - `LaTeX-verbatim-macros-with-braces'
diff --git a/latex.el b/latex.el
index 8ce8c6e..6d25559 100644
--- a/latex.el
+++ b/latex.el
@@ -1229,9 +1229,7 @@ If SHORT-CAPTION is non-nil pass it as an optional 
argument to
               (LaTeX-newline)
               (indent-according-to-mode)))
         ;; bottom caption (default)
-        (when active-mark
-          (goto-char end-marker)
-          (set-marker end-marker nil))
+        (when active-mark (goto-char end-marker))
         (save-excursion
           (LaTeX-newline)
           (indent-according-to-mode)
@@ -1249,6 +1247,8 @@ If SHORT-CAPTION is non-nil pass it as an optional 
argument to
         ;; Insert an empty line between caption and marked region, if any.
         (when active-mark (LaTeX-newline) (forward-line -1))
         (indent-according-to-mode)))
+    (when (markerp end-marker)
+      (set-marker end-marker nil))
     (when (and (member environment '("table" "table*"))
                ;; Suppose an existing tabular environment should just
                ;; be wrapped into a table if there is an active region.
@@ -1524,7 +1524,7 @@ The number is calculated from REGEXP and FUNC.
 Example 1:
 Consider the case that the current environment begins with
 \\begin{array}[t]{|lcr|}
-.  REGEXP must be chosen to match \"[t]\", i.e., the text between just
+.  REGEXP must be chosen to match \"[t]\", that is, the text between just
 after \"\\begin{array}\" and just before \"{|lcr|}\", which encloses
 the column specification.  FUNC must return the number of ampersands to
 be inserted, which is 2 since this example specifies three columns.
@@ -1818,7 +1818,7 @@ The input string may include LaTeX comments and newlines."
 For each element, the CAR is the name of the class, the CDR is
 the list of options provided to it.
 
-E.g., its value will be
+For example, its value will be
   \(\(\"book\" \"a4paper\" \"11pt\" \"openany\" \"fleqn\"\)
    ...\)
 See also `LaTeX-provided-package-options'.")
@@ -1841,7 +1841,7 @@ Return first found class option matching REGEXP, or nil 
if not found."
 For each element, the CAR is the name of the package, the CDR is
 the list of options provided to it.
 
-E.g., its value will be
+For example, its value will be
   \(\(\"babel\" \"german\"\)
    \(\"geometry\" \"a4paper\" \"top=2cm\" \"bottom=2cm\" \"left=2.5cm\" 
\"right=2.5cm\"\)
    ...\)
@@ -2037,13 +2037,14 @@ argument, otherwise as a mandatory one."
   "Prompt for a label completing with known labels and return it.
 This function always returns a string depending on user input:
 the returned value can be an empty string \"\", the value of
-`TeX-read-label-prefix' if present (e.g. \"fig:\") or a complete
-label input (e.g. \"fig:foo\").  If OPTIONAL is non-nil, indicate
-optional as part of prompt in minibuffer.  Use PROMPT as the
-prompt string.  If DEFINITION is non-nil, add the chosen label to
-the list of defined labels.  `TeX-read-label-prefix' is used as
-initial input for the label.  Also check if label is already
-defined and ask user for confirmation before proceeding."
+`TeX-read-label-prefix' if present (for example, \"fig:\") or a
+complete label input (for example, \"fig:foo\").  If OPTIONAL is
+non-nil, indicate optional as part of prompt in minibuffer.  Use
+PROMPT as the prompt string.  If DEFINITION is non-nil, add the
+chosen label to the list of defined labels.
+`TeX-read-label-prefix' is used as initial input for the label.
+Also check if label is already defined and ask user for
+confirmation before proceeding."
   (let (label valid)
     (while (not valid)
       (setq label
@@ -3097,12 +3098,21 @@ If OPTIONAL is non-nil, indicate in the prompt that we 
are
 reading an optional argument.  KEY-VAL-ALIST is an alist.  The
 car of each element should be a string representing a key and the
 optional cdr should be a list with strings to be used as values
-for the key.  Use PROMPT as the prompt string."
+for the key.  KEY-VAL-ALIST can be a symbol or a function call
+returning an alist.  Use PROMPT as the prompt string."
   (multi-prompt-key-value
    (TeX-argument-prompt optional prompt "Options (k=v)")
-   (if (symbolp key-val-alist)
-       (eval key-val-alist t)
-     key-val-alist)))
+   (cond ((and (symbolp key-val-alist)
+              (boundp key-val-alist))
+         (symbol-value key-val-alist))
+        ((and (listp key-val-alist)
+              (symbolp (car key-val-alist))
+              (fboundp (car key-val-alist)))
+         (let ((head (car key-val-alist))
+               (tail (cdr key-val-alist)))
+           (apply head tail)))
+        (t
+         key-val-alist))))
 
 (defun TeX-arg-key-val (optional key-val-alist &optional prompt)
   "Prompt for keys and values in KEY-VAL-ALIST.
@@ -3117,161 +3127,184 @@ as values for the key.  Use PROMPT as the prompt 
string."
 (defun TeX-read-hook ()
   "Read a LaTeX hook and return it as a string."
   (let* ((hook (completing-read
-               (TeX-argument-prompt nil nil "Hook")
-               '("cmd"
-                 "env"
-                 ;; From ltfilehook-doc.pdf
-                 "file/before"        "file/after"
-                 "include/before"     "include/end"   "include/after"
-                 "class/before"       "class/after"
-                 "package/before"     "package/after"
-                 ;; From lthooks-doc.pdf
-                 "begindocument"
-                 "begindocument/before"
-                 "begindocument/end"
-                 "enddocument"
-                 "enddocument/afterlastpage"
-                 "enddocument/afteraux"
-                 "enddocument/info"
-                 "enddocument/end"
-                 "rmfamily"           "sffamily"
-                 "ttfamily"           "normalfont"
-                 "bfseries"           "bfseries/defaults"
-                 "mdseries"           "mdseries/defaults"
-                 ;; From ltshipout-doc.pdf
-                 "shipout/before"     "shipout/after"
-                 "shipout/foreground" "shipout/background"
-                 "shipout/firstpage"  "shipout/lastpage"
-                 ;; From ltpara-doc.pdf
-                 "para/before"         "para/begin"
-                 "para/end"            "para/after")))
-        (place (lambda ()
-                 (completing-read
-                  (TeX-argument-prompt nil nil "Where")
-                  (if (string= hook "cmd")
-                      '("after" "before")
-                    '("before" "begin" "end" "after")))))
-        (search (lambda ()
-                  (if (eq TeX-arg-input-file-search 'ask)
-                      (not (y-or-n-p "Find file yourself? "))
-                    TeX-arg-input-file-search)))
-        name where files ); result
+                (TeX-argument-prompt nil nil "Hook")
+                '("cmd"
+                  "env"
+                  ;; From ltfilehook-doc.pdf
+                  "file" "include" "class" "package"
+                  ;; From lthooks-doc.pdf
+                  "begindocument"  "enddocument"
+                  "rmfamily"       "sffamily"
+                  "ttfamily"       "normalfont"
+                  "bfseries"       "mdseries"
+                  ;; From ltshipout-doc.pdf
+                  "shipout"
+                  ;; From ltpara-doc.pdf
+                  "para")))
+         (place (lambda (&optional opt pr)
+                  (completing-read
+                   (TeX-argument-prompt opt pr "Where")
+                   (cond ((member hook '("env" "para"))
+                          '("after" "before" "begin" "end"))
+                         ((string= hook "include")
+                          '("after" "before" "end"))
+                         ((string= hook "begindocument")
+                          '("before" "end"))
+                         ((string= hook "enddocument")
+                          '("afterlastpage" "afteraux" "info" "end"))
+                         ((member hook '("bfseries" "mdseries"))
+                          '("defaults"))
+                         ((string= hook "shipout")
+                          '("before"     "after"
+                            "foreground" "background"
+                            "firstpage"  "lastpage"))
+                         (t
+                          '("after" "before"))))))
+         (search (lambda ()
+                   (if (eq TeX-arg-input-file-search 'ask)
+                       (not (y-or-n-p "Find file yourself? "))
+                     TeX-arg-input-file-search)))
+         name where files)
     (cond ((string= hook "cmd")
-          ;; cmd/<name>/<where>
-          (setq name (completing-read
-                      (TeX-argument-prompt nil nil "Command")
-                      (TeX-symbol-list)))
-          (setq where (funcall place)))
-
-         ;; env/<name>/<where>
-         ((string= hook "env")
-          (setq name (completing-read
-                      (TeX-argument-prompt nil nil "Environment")
-                      (LaTeX-environment-list)))
-          (setq where (funcall place)))
-
-         ;; file/(before|after)/<file-name.xxx> where <file-name> is
-         ;; optional and must be with extension
-         ((member hook '("file/before" "file/after"))
-          (if (funcall search)
-              (progn
-                (unless TeX-global-input-files-with-extension
-                  (setq TeX-global-input-files-with-extension
-                        (prog2
-                            (message "Searching for files...")
-                            (mapcar #'list
-                                    (TeX-search-files-by-type 'texinputs
-                                                              'global
-                                                              t nil))
-                          (message "Searching for files...done"))))
-                (setq name
-                      (completing-read
-                       (TeX-argument-prompt t nil "File")
-                       TeX-global-input-files-with-extension)))
-            (setq name
-                  (file-name-nondirectory
-                   (read-file-name
-                    (TeX-argument-prompt t nil "File")
-                    nil "")))))
-
-         ;; include/(before|after|end)/<file-name> where <file-name>
-         ;; is optional
-         ((member hook '("include/before" "include/end" "include/after"))
-          (if (funcall search)
-              (progn
-                (setq files
-                      (prog2
-                          (message "Searching for files...")
-                          ;; \include looks for files with TeX content,
-                          ;; so limit the search:
-                          (let* ((TeX-file-extensions '("tex" "ltx")))
-                            (TeX-search-files-by-type 'texinputs 'local t t))
-                        (message "Searching for files...done")))
-                (setq name (completing-read
-                            (TeX-argument-prompt t nil "File")
-                            files)))
-            (setq name
-                  (file-name-base
-                   (read-file-name
-                    (TeX-argument-prompt t nil "File")
-                    nil "")))))
-
-         ;; class/(before|after)/<doc-class> where <doc-class> is
-         ;; optional
-         ((member hook '("class/before" "class/after"))
-          (if (funcall search)
-              (progn
-                (unless LaTeX-global-class-files
-                  (setq LaTeX-global-class-files
-                        (prog2
-                            (message "Searching for LaTeX classes...")
-                            (let* ((TeX-file-extensions '("cls")))
-                              (mapcar #'list
-                                      (TeX-search-files-by-type 'texinputs
-                                                                'global
-                                                                t t)))
-                          (message "Searching for LaTeX classes...done"))))
-                (setq name (completing-read
-                            (TeX-argument-prompt t nil "Document class")
-                            LaTeX-global-class-files)))
-            (setq name
-                  (file-name-base
-                   (read-file-name
-                    (TeX-argument-prompt t nil "File")
-                    nil "")))))
-
-         ;; package/(before|after)/<pack-name> where
-         ;; <pack-name> is optional
-         ((member hook '("package/before" "package/after"))
-          (if (funcall search)
-              (progn
-                (unless LaTeX-global-package-files
-                  (setq LaTeX-global-package-files
-                        (prog2
-                            (message "Searching for LaTeX packages...")
-                            (let* ((TeX-file-extensions '("sty")))
-                              (mapcar #'list
-                                      (TeX-search-files-by-type 'texinputs
-                                                                'global
-                                                                t t)))
-                          (message "Searching for LaTeX packages...done"))))
-                (setq name (completing-read
-                            (TeX-argument-prompt t nil "Package")
-                            LaTeX-global-package-files)))
-            (setq name (file-name-base
-                        (read-file-name
-                         (TeX-argument-prompt t nil "File")
-                         nil "")))))
-
-         ;; User specific input for the hook, do nothing:
-         (t nil))
-    ;; Process the input: For cmd or env, concat the elements with a
-    ;; slash.  For other hooks, check if the optional name is given
-    ;; and append it with a backslash to the hook:
-    (if (member hook '("cmd" "env"))
-       (concat hook "/" name "/" where)
-      (concat hook (when (and name (not (string= name "")))
-                    (concat "/" name))))))
+           ;; cmd/<name>/<where>: <where> is one of (before|after)
+           (setq name (completing-read
+                       (TeX-argument-prompt nil nil "Command")
+                       (TeX-symbol-list)))
+           (setq where (funcall place)))
+
+          ;; env/<name>/<where>: <where> is one of (before|after|begin|end)
+          ((string= hook "env")
+           (setq name (completing-read
+                       (TeX-argument-prompt nil nil "Environment")
+                       (LaTeX-environment-list)))
+           (setq where (funcall place)))
+
+          ;; file/<file-name.xxx>/<where>: <file-name> is optional and
+          ;; must be with extension and <where> is one of
+          ;; (before|after)
+          ((string= hook "file")
+           (if (funcall search)
+               (progn
+                 (unless TeX-global-input-files-with-extension
+                   (setq TeX-global-input-files-with-extension
+                         (prog2
+                             (message "Searching for files...")
+                             (mapcar #'list
+                                     (TeX-search-files-by-type 'texinputs
+                                                               'global
+                                                               t nil))
+                           (message "Searching for files...done"))))
+                 (setq name
+                       (completing-read
+                        (TeX-argument-prompt t nil "File")
+                        TeX-global-input-files-with-extension)))
+             (setq name
+                   (file-name-nondirectory
+                    (read-file-name
+                     (TeX-argument-prompt t nil "File")
+                     nil ""))))
+           (setq where (funcall place)))
+
+          ;; include/<file-name>/<where>: <file-name> is optional and
+          ;; <where> is one of (before|after|end)
+          ((string= hook "include")
+           (if (funcall search)
+               (progn
+                 (setq files
+                       (prog2
+                           (message "Searching for files...")
+                           ;; \include looks for files with TeX content,
+                           ;; so limit the search:
+                           (let* ((TeX-file-extensions '("tex" "ltx")))
+                             (TeX-search-files-by-type 'texinputs 'local t t))
+                         (message "Searching for files...done")))
+                 (setq name (completing-read
+                             (TeX-argument-prompt t nil "File")
+                             files)))
+             (setq name
+                   (file-name-base
+                    (read-file-name
+                     (TeX-argument-prompt t nil "File")
+                     nil ""))))
+           (setq where (funcall place)))
+
+          ;; class/<doc-class>/<where>: <doc-class> is optional and
+          ;; <where> is one of (before|after)
+          ((string= hook "class")
+           (if (funcall search)
+               (progn
+                 (unless LaTeX-global-class-files
+                   (setq LaTeX-global-class-files
+                         (prog2
+                             (message "Searching for LaTeX classes...")
+                             (let* ((TeX-file-extensions '("cls")))
+                               (mapcar #'list
+                                       (TeX-search-files-by-type 'texinputs
+                                                                 'global
+                                                                 t t)))
+                           (message "Searching for LaTeX classes...done"))))
+                 (setq name (completing-read
+                             (TeX-argument-prompt t nil "Document class")
+                             LaTeX-global-class-files)))
+             (setq name
+                   (file-name-base
+                    (read-file-name
+                     (TeX-argument-prompt t nil "Document class")
+                     nil ""))))
+           (setq where (funcall place)))
+
+          ;; package/<pack-name>/<where>: <pack-name> is optional and
+          ;; <where> is one of (before|after)
+          ((string= hook "package")
+           (if (funcall search)
+               (progn
+                 (unless LaTeX-global-package-files
+                   (setq LaTeX-global-package-files
+                         (prog2
+                             (message "Searching for LaTeX packages...")
+                             (let* ((TeX-file-extensions '("sty")))
+                               (mapcar #'list
+                                       (TeX-search-files-by-type 'texinputs
+                                                                 'global
+                                                                 t t)))
+                           (message "Searching for LaTeX packages...done"))))
+                 (setq name (completing-read
+                             (TeX-argument-prompt t nil "Package")
+                             LaTeX-global-package-files)))
+             (setq name (file-name-base
+                         (read-file-name
+                          (TeX-argument-prompt t nil "Package")
+                          nil ""))))
+           (setq where (funcall place)))
+
+          ;; begindocument/<where>: <where> is empty or one of
+          ;; (before|end)
+          ((string= hook "begindocument")
+           (setq where (funcall place t)))
+
+          ;; enddocument/<where>: <where> is empty or one of
+          ;; (afterlastpage|afteraux|info|end)
+          ((string= hook "enddocument")
+           (setq where (funcall place t)))
+
+          ;; bfseries|mdseries/<where>: <where> is empty or defaults
+          ((member hook '("bfseries" "mdseries"))
+           (setq where (funcall place t)))
+
+          ;; shipout/<where>: <where> is one of
+          ;; (before|after|foreground|background|firstpage|lastpage)
+          ((string= hook "shipout")
+           (setq where (funcall place)))
+
+          ;; Other hooks or user specific input, do nothing:
+          (t nil))
+
+    ;; Process the input: Concat the given parts and return it
+    (concat hook
+            (when (and name (not (string= name "")))
+              (concat "/" name))
+            (when (and where (not (string= where "")))
+              (concat "/" where)))))
 
 (defun TeX-arg-hook (optional)
   "Prompt for a LaTeX hook.
@@ -3343,7 +3376,7 @@ buffer-local keyword additions via
   :type '(repeat (string)))
 
 (defvar LaTeX-verbatim-environments-local nil
-  "Buffer-local variable for inline verbatim environments.
+  "Buffer-local variable for verbatim environments.
 
 Style files should add constructs to this variable and not to
 `LaTeX-verbatim-environments'.
@@ -3418,7 +3451,7 @@ non-parenthetical delimiters, like \\verb+foo+, are 
recognized."
         (goto-char (car macro-boundaries))
         (forward-char (length TeX-esc))
         (buffer-substring-no-properties
-         (point) (progn (skip-chars-forward "@A-Za-z") (point)))))))
+         (point) (progn (skip-chars-forward "@A-Za-z*") (point)))))))
 
 (defun LaTeX-verbatim-p (&optional pos)
   "Return non-nil if position POS is in a verbatim-like construct."
@@ -3541,13 +3574,6 @@ functions, see `LaTeX-fill-region-as-paragraph'."
   :group 'LaTeX-indentation
   :type 'regexp)
 
-(defcustom LaTeX-verbatim-regexp "verbatim\\*?"
-  "Regexp matching environments with indentation at col 0 for begin/end."
-  :group 'LaTeX-indentation
-  :type 'regexp)
-(make-obsolete-variable 'LaTeX-verbatim-regexp 
'LaTeX-verbatim-environments-local
-                        "2014-12-19")
-
 (defcustom LaTeX-begin-regexp "begin\\b\\|\\["
   "Regexp matching macros considered begins."
   :group 'LaTeX-indentation
@@ -3569,8 +3595,8 @@ This means, we just count the LaTeX tokens \\left, 
\\right, \\begin,
 and \\end up to the first occurence of text matching this regexp.
 Thus, the default \"%\" stops counting the tokens at a comment.  A
 value of \"%[^>]\" would allow you to alter the indentation with
-comments, e.g. with comment `%> \\begin'.
-Lines which start with `%' are not considered at all, regardless if this
+comments, for example with comment `%> \\begin'.
+Lines which start with `%' are not considered at all, regardless of this
 value."
   :group 'LaTeX-indentation
   :type 'regexp)
@@ -3658,9 +3684,12 @@ Lines starting with an item is given an extra 
indentation of
   (delete-region (line-beginning-position) (point))
   (indent-to outer-indent))
 
-(defun LaTeX-verbatim-regexp ()
-  "Calculate the verbatim env regex from `LaTeX-verbatim-environments'."
-  (regexp-opt (LaTeX-verbatim-environments)))
+(defun LaTeX-verbatim-regexp (&optional comment)
+  "Calculate the verbatim env regex from `LaTeX-verbatim-environments'.
+If optional argument COMMENT is non-nil, include comment env from
+`LaTeX-comment-env-list'."
+  (regexp-opt (append (LaTeX-verbatim-environments)
+                      (if comment LaTeX-comment-env-list))))
 
 (defun LaTeX-indent-calculate (&optional force-type)
   "Return the indentation of a line of LaTeX source.
@@ -3692,9 +3721,9 @@ outer indentation in case of a commented line.  The 
symbols
                                     (length comment-padding)))
                (nth 1 entry)))
             ((looking-at (concat (regexp-quote TeX-esc)
-                                 "\\(begin\\|end\\){\\("
-                                 (LaTeX-verbatim-regexp)
-                                 "\\)}"))
+                                 "\\(begin\\|end\\){"
+                                 (LaTeX-verbatim-regexp t)
+                                 "}"))
              ;; \end{verbatim} must be flush left, otherwise an unwanted
              ;; empty line appears in LaTeX's output.
              0)
@@ -3824,21 +3853,24 @@ outer indentation in case of a commented line.  The 
symbols
            ;; environment.
            0)
           ((looking-at (concat (regexp-quote TeX-esc)
-                               "begin *{\\("
+                               "begin *{"
+                               ;; Don't give optional argument here
+                               ;; because indent would be disabled
+                               ;; inside comment env otherwise.
                                (LaTeX-verbatim-regexp)
-                               "\\)}"))
+                               "}"))
            0)
           ((looking-at (concat (regexp-quote TeX-esc)
-                               "end *{\\("
-                               (LaTeX-verbatim-regexp)
-                               "\\)}"))
+                               "end *{"
+                               (LaTeX-verbatim-regexp t)
+                               "}"))
            ;; If I see an \end{verbatim} in the previous line I skip
            ;; back to the preceding \begin{verbatim}.
            (save-excursion
              (if (re-search-backward (concat (regexp-quote TeX-esc)
-                                             "begin *{\\("
-                                             (LaTeX-verbatim-regexp)
-                                             "\\)}") 0 t)
+                                             "begin *{"
+                                             (LaTeX-verbatim-regexp t)
+                                             "}") 0 t)
                  (LaTeX-indent-calculate-last force-type)
                0)))
           (t (+ (LaTeX-current-indentation force-type)
@@ -3897,7 +3929,7 @@ outer indentation in case of a commented line.  The 
symbols
 If it is commented and comments are formatted syntax-aware move
 point to the first non-whitespace character after the comment
 character(s), but only if `this-command' is not a newline
-command, i.e., `TeX-newline' or the value of
+command, that is, `TeX-newline' or the value of
 `TeX-newline-function'.  The optional argument FORCE-TYPE can be
 used to force point being moved to the inner or outer indentation
 in case of a commented line.  The symbols 'inner and 'outer are
@@ -3972,7 +4004,7 @@ You can disable filling inside a specific environment by 
adding
 it to `LaTeX-indent-environment-list', only indentation is
 performed in that case."
   (interactive "*r\nP")
-  (let ((end-marker (save-excursion (goto-char to) (point-marker))))
+  (let ((end-marker (copy-marker to)) has-code-comment has-regexp-match)
     (if (or (assoc (LaTeX-current-environment) LaTeX-indent-environment-list)
             (member (TeX-current-macro) LaTeX-fill-excluded-macros)
             ;; This could be generalized, if there are more cases where
@@ -3984,30 +4016,65 @@ performed in that case."
                                                        "Local Variables:")))))
         ;; Filling disabled, only do indentation.
         (indent-region from to nil)
+      ;; XXX: This `save-restriction' is a leftover of older codes and
+      ;; can now be removed.
       (save-restriction
         (goto-char from)
         (while (< (point) end-marker)
-          (if (re-search-forward
-               (concat "\\("
-                       ;; Code comments.
-                       "\\([^ \r\n%\\]\\|\\\\%\\)\\([ \t]\\|\\\\\\\\\\)*"
-                       TeX-comment-start-regexp
-                       "\\|"
-                       ;; Lines ending with `\par'.
-                       "\\(\\=\\|[^" TeX-esc "\n]\\)\\("
-                       (regexp-quote (concat TeX-esc TeX-esc))
-                       "\\)*"
-                       (regexp-quote TeX-esc) "par[ \t]*"
-                       "\\({[ \t]*}\\)?[ \t]*$"
-                       "\\)\\|\\("
-                       ;; Lines ending with `\\'.
-                       (regexp-quote TeX-esc)
-                       (regexp-quote TeX-esc)
-                       "\\(\\s-*\\*\\)?"
-                       "\\(\\s-*\\[[^]]*\\]\\)?"
-                       "\\s-*$\\)")
-               end-marker t)
+          ;; Code comments.
+          (catch 'found
+            (while (setq has-code-comment
+                         (TeX-search-forward-comment-start end-marker))
+              ;; See if there is at least one non-whitespace
+              ;; character before the comment starts.
+              (goto-char has-code-comment)
+              (skip-chars-backward " \t" (line-beginning-position))
+              (if (not (bolp))
+                  ;; A real code comment.
+                  (throw 'found t)
+                ;; Not a code comment.  Continue the loop.
+                (forward-line 1)
+                (if (> (point) end-marker)
+                    (goto-char end-marker)))))
+
+          ;; Go back to the former point for the next regexp search.
+          (goto-char from)
+
+          (when (setq has-regexp-match
+                      (re-search-forward
+                       (concat
+                        "\\("
+                        ;; Lines ending with `\par'.
+                        ;; XXX: Why exclude \n?  vv
+                        "\\(?:\\=\\|[^" TeX-esc "\n]\\)\\(?:"
+                        (regexp-quote (concat TeX-esc TeX-esc))
+                        "\\)*"
+                        (regexp-quote TeX-esc) "par[ \t]*"
+                        ;; XXX: What's this "whitespaces in braces" ?
+                        ;;    vvvvvvvv
+                        "\\(?:{[ \t]*}\\)?[ \t]*$"
+                        "\\)\\|"
+                        ;; Lines ending with `\\'.
+                        ;; XXX: This matches a line ending with "\\\ ".
+                        ;; Should we avoid such corner case?
+                        (regexp-quote (concat TeX-esc TeX-esc))
+                        ;; XXX: Why not just "\\s-*\\*?" ?
+                        "\\(?:\\s-*\\*\\)?"
+                        ;; XXX: Why not "\\s-*\\(?:\\[[^]]*\\]\\)?" ?
+                        "\\(?:\\s-*\\[[^]]*\\]\\)?"
+                        "\\s-*$")
+                       (or has-code-comment end-marker) t))
+            ;; The regexp matched before the code comment (if any).
+            (setq has-code-comment nil))
+
+          ;; Here no need to go back to the former position because
+          ;; "ELSE" part of the following `if' doesn't rely on the
+          ;; current point.
+          ;; (goto-char from)
+
+          (if (or has-code-comment has-regexp-match)
               (progn
+                (goto-char (or has-code-comment has-regexp-match))
                 (goto-char (line-end-position))
                 (delete-horizontal-space)
                 ;; I doubt very much if we want justify -
@@ -4020,7 +4087,8 @@ performed in that case."
                   ;; Code comments and lines ending with `\par' are
                   ;; included in filling.  Lines ending with `\\' are
                   ;; skipped.
-                  (if (match-string 1)
+                  (if (or has-code-comment
+                          (match-beginning 1))
                       (LaTeX-fill-region-as-para-do from (point) justify-flag)
                     (LaTeX-fill-region-as-para-do
                      from (line-beginning-position 0) justify-flag)
@@ -4442,7 +4510,7 @@ space does not end a sentence, so don't break a line 
there."
 (defun LaTeX-fill-paragraph (&optional justify)
   "Like `fill-paragraph', but handle LaTeX comments.
 If any of the current line is a comment, fill the comment or the
-paragraph of it that point is in.  Code comments, i.e. comments
+paragraph of it that point is in.  Code comments, that is, comments
 with uncommented code preceding them in the same line, will not
 be filled unless the cursor is placed on the line with the
 code comment.
@@ -4810,7 +4878,7 @@ value of NO-SUBSECTIONS."
 (defun LaTeX-paragraph-commands-regexp-make ()
   "Return a regular expression matching defined paragraph commands.
 Regexp part containing TeX control words is postfixed with `\\b'
-to avoid ambiguities (e.g. \\par vs. \\parencite)."
+to avoid ambiguities (for example, \\par vs. \\parencite)."
   (let (cmds symbs)
     (dolist (mac (append LaTeX-paragraph-commands
                          LaTeX-paragraph-commands-internal))
@@ -5653,8 +5721,8 @@ Each entry should be a list with up to four elements, 
KEY, VALUE,
 MENU and CHARACTER.
 
 KEY is the key (after `LaTeX-math-abbrev-prefix') to be redefined
-in math minor mode.  KEY can be a character (e.g. ?o) for a
-single stroke or a string (e.g. \"o a\") for a multi-stroke
+in math minor mode.  KEY can be a character (for example ?o) for a
+single stroke or a string (for example \"o a\") for a multi-stroke
 binding.  If KEY is nil, the symbol has no associated
 keystroke (it is available in the menu, though).  Note that
 predefined keys in `LaTeX-math-default' cannot be overridden in
@@ -5667,9 +5735,9 @@ or a function to be called.  The macro must be given 
without the
 leading backslash.
 
 The third element MENU is the name of the submenu where the
-command should be added.  MENU can be either a string
-\(e.g. \"greek\"), a list (e.g. (\"AMS\" \"Delimiters\")) or nil.
-If MENU is nil, no menu item will be created.
+command should be added.  MENU can be either a string (for
+example \"greek\"), a list (for example (\"AMS\" \"Delimiters\"))
+or nil.  If MENU is nil, no menu item will be created.
 
 The fourth element CHARACTER is a Unicode character position for
 menu display.  When nil, no character is shown.
@@ -6796,14 +6864,14 @@ runs the hooks in `docTeX-mode-hook'."
   TeX-clean-default-intermediate-suffixes
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
 (defcustom docTeX-clean-output-suffixes TeX-clean-default-output-suffixes
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
@@ -6813,14 +6881,14 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
           '("\\.acn" "\\.acr" "\\.alg" "\\.glg" "\\.ist"))
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
 (defcustom LaTeX-clean-output-suffixes TeX-clean-default-output-suffixes
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
@@ -7361,7 +7429,34 @@ function would return non-nil and `(match-string 1)' 
would return
      ;; LaTeX hook macros:
      '("AddToHook"      TeX-arg-hook [ "Label" ] t)
      '("RemoveFromHook" TeX-arg-hook [ "Label" ])
-     '("AddToHookNext"  TeX-arg-hook t)))
+     '("AddToHookNext"  TeX-arg-hook t)
+
+     ;; Added in LaTeX 2021-11-15
+     '("counterwithin"
+       [TeX-arg-eval completing-read
+                     (TeX-argument-prompt t nil "Format")
+                     '("\\arabic" "\\roman" "\\Roman" "\\alph" "\\Alph")]
+       (TeX-arg-counter)
+       (TeX-arg-counter "Within counter"))
+     '("counterwithin*"
+       [TeX-arg-eval completing-read
+                     (TeX-argument-prompt t nil "Format")
+                     '("\\arabic" "\\roman" "\\Roman" "\\alph" "\\Alph")]
+       (TeX-arg-counter)
+       (TeX-arg-counter "Within counter"))
+
+     '("counterwithout"
+       [TeX-arg-eval completing-read
+                     (TeX-argument-prompt t nil "Format")
+                     '("\\arabic" "\\roman" "\\Roman" "\\alph" "\\Alph")]
+       (TeX-arg-counter)
+       (TeX-arg-counter "Within counter"))
+     '("counterwithout*"
+       [TeX-arg-eval completing-read
+                     (TeX-argument-prompt t nil "Format")
+                     '("\\arabic" "\\roman" "\\Roman" "\\alph" "\\Alph")]
+       (TeX-arg-counter)
+       (TeX-arg-counter "Within counter"))))
 
   (TeX-run-style-hooks "LATEX")
 
@@ -7544,7 +7639,7 @@ function would return non-nil and `(match-string 1)' 
would return
     (cons (point) (current-column))))
 
 (defun LaTeX-hanging-ampersand-position ()
-  "Return indent column for a hanging ampersand (i.e. ^\\s-*&)."
+  "Return indent column for a hanging ampersand (that is, ^\\s-*&)."
   (cl-destructuring-bind
       (beg-pos . beg-col)
       (LaTeX-env-beginning-pos-col)
diff --git a/latex/preview.dtx b/latex/preview.dtx
index 080996b..ff686ce 100644
--- a/latex/preview.dtx
+++ b/latex/preview.dtx
@@ -3,7 +3,7 @@
 %%    Developed as part of AUCTeX <URL:https://www.gnu.org/software/auctex/>.
 %
 %     Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006,
-%                   2010, 2017-2020 Free Software Foundation
+%                   2010, 2017-2021 Free Software Foundation
 %
 %     This program is free software; you can redistribute it and/or modify
 %     it under the terms of the GNU General Public License as published by
@@ -439,7 +439,7 @@
 \NeedsTeXFormat{LaTeX2e} \def\reserved@a #1#2$#3:
 #4${\xdef#1{\reserved@c #2#4 $}} \def\reserved@c #1 #2${#1}
 \begingroup \catcode`\_=12
-\reserved@a\pr@version $Name: release_12_3 $ \ifx\pr@version\@empty
+\reserved@a\pr@version $Name: release_13_1 $ \ifx\pr@version\@empty
 \reserved@a\pr@version CVS-$Revision: 1.126 $ \endgroup \else
   \def\next release_{} \lccode`\_=`.
   \edef\next{\lowercase{\endgroup
diff --git a/plain-tex.el b/plain-tex.el
index 4c384f0..0d43fdb 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -254,14 +254,14 @@ of `plain-TeX-mode-hook'."
   TeX-clean-default-intermediate-suffixes
   "List of regexps matching suffixes of intermediate files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
 (defcustom plain-TeX-clean-output-suffixes TeX-clean-default-output-suffixes
   "List of regexps matching suffixes of output files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
@@ -315,14 +315,14 @@ of `AmS-TeX-mode-hook'."
   TeX-clean-default-intermediate-suffixes
   "List of regexps matching suffixes of intermediate files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
 (defcustom AmSTeX-clean-output-suffixes TeX-clean-default-output-suffixes
   "List of regexps matching suffixes of output files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
diff --git a/preview-latex.spec b/preview-latex.spec
deleted file mode 100644
index 0d1caae..0000000
--- a/preview-latex.spec
+++ /dev/null
@@ -1,260 +0,0 @@
-# Spec file for preview-latex
-
-# Maintainer: auctex-devel@gnu.org
-
-# Copyright (C) 2002, 2004, 2005 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 Street, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-
-%define HAVE_EMACS  %(which emacs  >/dev/null 2>/dev/null && echo 1 || echo 0)
-%define HAVE_XEMACS %(which xemacs >/dev/null 2>/dev/null && echo 1 || echo 0)
-
-%define FOR_SUSE    %{?suse_version:1}%{!?suse_version:0}
-
-%if %{FOR_SUSE}
-%define distri      .suse
-%define commongroup Productivity/Editors/Emacs
-# This is awful, but I don't have the clue to avoid it:
-%define xemacspkgdir %{_datadir}/xemacs/xemacs-packages
-%define xemacspkgconfdir ${datadir}/xemacs/xemacs-packages
-%else
-%define distri      .fedora
-%define commongroup Applications/Editors
-# This is awful, but I don't have the clue to avoid it:
-%define xemacspkgdir %{_datadir}/xemacs/xemacs-packages
-%define xemacspkgconfdir ${datadir}/xemacs/xemacs-packages
-%endif
-
-# we use xemacs-packages because the system packages can be found
-# here, and preview-latex is not yet a part of any sumo tarball or
-# similar.  The choice for AUCTeX would probably be site-packages
-# instead.
-
-Summary:       Emacs/LaTeX inline preview 
-Name:          preview-latex
-Version:       0.9.1
-Release:       1%{distri}
-License:        GPL
-BuildArchitectures: noarch
-URL:           http://www.gnu.org/software/auctex
-Source0:       ftp://ftp.gnu.org/pub/auctex/%{name}-%{version}.tar.gz
-Group:                 %{commongroup}
-BuildRoot:     %{_tmppath}/%{name}-root
-Prereq:                info
-Requires:      ghostscript >= 6.51
-Requires:      tetex tetex-dvips
-BuildRequires: texinfo >= 4.0
-
-%description
-Does your neck hurt from turning between previewer windows and the
-source too often? This Elisp/LaTeX package will render your displayed
-LaTeX equations right into the editing window where they belong. 
-
-%package common
-Summary:       Emacs/LaTeX inline preview (LaTeX style and docs)
-Group:                 %{commongroup}
-
-%description common
-Does your neck hurt from turning between previewer windows and the
-source too often? This Elisp/LaTeX package will render your displayed
-LaTeX equations right into the editing window where they belong. 
-
-This package contains the LaTeX style files and the documentation.
-
-%package emacs
-Summary:       Emacs/LaTeX inline preview (GNU Emacs lisp files)
-Group:                 %{commongroup}
-Requires:      %{name}-common = %{version}-%{release}
-Requires:      emacs >= 21.1
-Requires:      auctex >= 11.0
-Obsoletes:     preview-latex
-
-%description emacs
-Does your neck hurt from turning between previewer windows and the
-source too often? This Elisp/LaTeX package will render your displayed
-LaTeX equations right into the editing window where they belong. 
-
-This package contains the lisp modules for GNU Emacs 21.1 or higher.
-
-%package xemacs
-Summary:       Emacs/LaTeX inline preview (XEmacs lisp files)
-Group:                 %{commongroup}
-Requires:      %{name}-common = %{version}-%{release}
-Requires:      xemacs >= 21.4.9
-Conflicts:      xemacs = 21.4.16
-
-%description xemacs
-Does your neck hurt from turning between previewer windows and the
-source too often? This Elisp/LaTeX package will render your displayed
-LaTeX equations right into the editing window where they belong. 
-
-This package contains the lisp modules for XEmacs 21.4.9 or higher.  
-
-%prep
-%setup -c -q
-
-%if %{HAVE_EMACS}
-  mkdir emacs
-  pushd emacs
-  ln -sf ../%{name}-%{version}/* .
-  popd
-%endif
-
-%if %{HAVE_XEMACS}
-  mkdir xemacs
-  pushd xemacs
-  ln -sf ../%{name}-%{version}/* .
-  popd
-%endif
-
-%build
-
-for i in *emacs; do
-  pushd $i
-  # The below will make the package build from a tar straight from CVS
-  # NOT RECOMMENDED, but useful for testing!
-  test -f ./configure || ./autogen.sh
-  # --with-packagedir repairs RedHat XEmacs braindamage texmf-dir
-  # moves the installation to a location searched before the (possibly
-  # conflicting) system tree.  Unfortunately, this is the site-wide
-  # tree that we should not really be touching.  Sigh.
-  if [ $i = "emacs" ]; then
-    %configure '--with-lispdir=${datadir}/emacs/site-lisp/site-start.d' \
-      --with-packagelispdir=../preview 
'--with-texmf-dir=${prefix}/local/share/texmf'
-  else
-    %configure --with-xemacs '--with-packagedir=%{xemacspkgconfdir}' 
'--with-texmf-dir=${prefix}/local/share/texmf'
-  fi
-  make 'infodir=%{_infodir}'
-  cd doc
-  make preview-latex.pdf
-  popd
-done
-
-%install 
-
-rm -rf '%{buildroot}'
-for i in *emacs; do
-  pushd $i
-  if [ $i == "emacs" ]; then 
-    # Make directory non-searchable.
-    mkdir -p '%{buildroot}%{_datadir}/emacs/site-lisp/preview'
-    touch .nosearch
-    install -c -m 644 .nosearch \
-      '%{buildroot}%{_datadir}/emacs/site-lisp/preview'
-    %makeinstall TEXHASH=:
-  else
-    # XEmacs MANIFEST doesn't get created unless the target dir exists
-    mkdir -p %{buildroot}%{xemacspkgdir}/pkginfo
-    %makeinstall TEXHASH=:
-  fi
-  popd
-done
-
-# Package documentation in /usr/share/doc/preview-latex-n.n
-# rather than /usr/share/doc/preview-latex-common-n.n
-%define docs       %{_defaultdocdir}/%{name}-%{version}
-mkdir -p '%{buildroot}%{docs}'
-pushd %{name}-%{version}
-for i in ChangeLog circ.tex COPYING FAQ INSTALL PROBLEMS README \
-    RELEASE TODO doc/preview-latex.pdf; do
-  cp -R "$i" '%{buildroot}%{docs}'
-done
-cp latex/README '%{buildroot}%{docs}/README-preview'
-
-# Remove dir file that has been created by the makeinfo calls because this
-# file will not been included in the rpm distribution (make RPM 4.1+ happy)
-# Apparently RPM 4.2 removes the file itself?
-rm -f '%{buildroot}%{_infodir}/dir'
-
-%clean
-rm -rf '%{buildroot}'
-
-%post common
-/sbin/install-info '--info-dir=%{_infodir}' '%{_infodir}/preview-latex.info'
-texhash /usr/local/share/texmf
-
-%preun common
-# $1 is the number of versions of this package installed
-# after this uninstallation
-if [ $1 -eq 0 ]; then
-  /sbin/install-info '--info-dir=%{_infodir}' --delete \
-    '%{_infodir}/preview-latex.info'
-fi
-
-%files common
-%defattr(-,root,root)
-%dir %{_prefix}/local/share/texmf/tex/latex/preview
-%{_prefix}/local/share/texmf/tex/latex/preview/*.sty
-%{_prefix}/local/share/texmf/tex/latex/preview/*.def
-%config %{_prefix}/local/share/texmf/tex/latex/preview/*.cfg
-%doc %{_prefix}/local/share/texmf/doc/latex/styles/preview.dvi
-%doc %{_infodir}/preview-latex.info*
-%doc %{docs}
-
-%if %{HAVE_EMACS}
-%files emacs
-%defattr(-,root,root)
-%{_datadir}/emacs/site-lisp/preview
-%{_datadir}/emacs/site-lisp/site-start.d/preview-latex.el 
-%endif
-
-%if %{HAVE_XEMACS}
-%files xemacs
-%defattr(-,root,root)
-%{xemacspkgdir}/lisp/preview
-%{xemacspkgdir}/etc/preview
-%verify() %{xemacspkgdir}/pkginfo/MANIFEST.preview
-%endif
-
-%changelog
-* Wed Jul 28 2004 David Kastrup <dak@gnu.org>
-- Remove 8bit-test stuff, some changes to directories.
-
-* Mon Apr 12 2004 David Kastrup <dak@gnu.org>
-- bump XEmacs requirements to 21.4.9
-
-* Thu Jan 29 2004 Jan-�ke Larsson <jalar@mai.liu.se>
-- add support for SuSE 
-   (kudos to Martin V�th <vaeth@mathematik.uni-wuerzburg.de>)
-
-* Wed Aug  7 2002 David Kastrup <David.Kastrup@t-online.de>
-- add FAQ
-
-* Tue Apr 16 2002 David Kastrup <David.Kastrup@t-online.de>
-- allow split info file, docs now go in preview-latex-n.n
-
-* Mon Apr 15 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Docs now goes in preview-latex-n.n-n directory
-
-* Wed Apr 10 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Triple-rpm simplifications
-
-* Sun Mar 31 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Prepare for 0.7, initial triple rpm attempt
-
-* Sun Mar 10 2002 David Kastrup <David.Kastrup@t-online.de>
-- Prepare for 0.6.1
-
-* Tue Feb 19 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Added site-start.d support and prauctex.cfg config file
-
-* Thu Feb 14 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Adjusted for 0.6
-
-* Wed Jan 23 2002 Jan-Ake Larsson <jalar@imf.au.dk>
-- Initial build.
diff --git a/style/acro.el b/style/acro.el
index 6d80642..56291a1 100644
--- a/style/acro.el
+++ b/style/acro.el
@@ -141,12 +141,12 @@ string."
     ("alt-indefinite") ("extra") ("sort") ("class") ("cite") ("short-format")
     ("long-format") ("first-long-format") ("pdfstring") ("accsupp")
     ("index-sort") ("index") ("index-cmd"))
-  "List of keys accepted by `\DeclareAcronym' macro of `acro' package
+  "List of keys accepted by `\\DeclareAcronym' macro of `acro' package
 in its second mandatory argument.")
 
 (defvar LaTeX-acro-printacronyms-keys
   '(("include-classes") ("exclude-classes") ("name") ("header"))
-  "List of keys accepted by `\printacronyms' macro of `acro' package
+  "List of keys accepted by `\\printacronyms' macro of `acro' package
 in its optional argument.")
 
 (defun LaTeX-arg-acro-key-val (optional prompt key-val-alist)
diff --git a/style/amsthm.el b/style/amsthm.el
index 866951a..3ea8176 100644
--- a/style/amsthm.el
+++ b/style/amsthm.el
@@ -80,7 +80,7 @@ for label.  AUCTeX users should add ENVIRONMENT to
   (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
 
 RefTeX users should customize or add ENVIRONMENT to
-`LaTeX-label-alist' and `reftex-label-alist', e.g.
+`LaTeX-label-alist' and `reftex-label-alist', for example
 
   (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
   (add-to-list \\='reftex-label-alist
diff --git a/style/arabxetex.el b/style/arabxetex.el
index 05068a4..897b9cd 100644
--- a/style/arabxetex.el
+++ b/style/arabxetex.el
@@ -1,6 +1,6 @@
 ;;; arabxetex.el --- AUCTeX style for `arabxetex.sty' (v1.2.1)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2017--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -38,9 +38,6 @@
 (declare-function font-latex-add-keywords
                   "font-latex"
                   (keywords class))
-(declare-function TeX-check-engine-add-engines
-                  "tex-buf"
-                  (&rest engines))
 
 (TeX-add-style-hook
  "arabxetex"
@@ -50,8 +47,6 @@
    (TeX-run-style-hooks "amsmath" "fontspec" "bidi")
 
    ;; We need xelatex, so check for the engine here:
-   (unless (featurep 'tex-buf)
-     (require 'tex-buf))
    (TeX-check-engine-add-engines 'xetex)
 
    ;; New macros & environments:
diff --git a/style/babel.el b/style/babel.el
index 9206dac..d8d980e 100644
--- a/style/babel.el
+++ b/style/babel.el
@@ -154,7 +154,7 @@
       ;; also remove possible comment lines
       (setq results
             (replace-regexp-in-string
-             "\\(%.*$\\|[ \n\r\t]\\)" ""
+             "%.*\\'\\|[ \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:
@@ -286,15 +286,16 @@
     '("useshorthands"  "Character")
     '("useshorthands*" "Character")
     '("defineshorthand"
-      [ TeX-arg-eval mapconcat #'identity
-        (TeX-completing-read-multiple
-         (TeX-argument-prompt t nil "Language(s)")
-         (LaTeX-babel-active-languages)) ""]
+      [TeX-arg-eval mapconcat #'identity
+                    (TeX-completing-read-multiple
+                     (TeX-argument-prompt t nil "Language(s)")
+                     (LaTeX-babel-active-languages))
+                    ","]
       t nil)
-    '("aliasshorthand"   "Original" "Alias")
     '("languageshorthands" TeX-arg-babel-lang)
     '("babelshorthand"   "Short hand")
     '("ifbabelshorthand" "Character" t nil)
+    '("aliasshorthand"   "Original" "Alias")
 
     ;; 1.12 The base option
     '("AfterBabelLanguage"
@@ -305,62 +306,60 @@
 
     ;; 1.14 Selecting fonts
     '("babelfont"
-      [ TeX-arg-eval mapconcat #'identity
-        (TeX-completing-read-multiple
-         (TeX-argument-prompt t nil "Language(s)")
-         LaTeX-babel-language-list)
-        "," ]
+      [TeX-arg-eval mapconcat #'identity
+                    (TeX-completing-read-multiple
+                     (TeX-argument-prompt t nil "Language(s)")
+                     LaTeX-babel-language-list)
+                    ","]
       (TeX-arg-eval let ((fontfam (completing-read
                                    (TeX-argument-prompt nil 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.
+                    ;; Run `TeX-check-engine-add-engines' and then
+                    ;; load `fontspec.el' if not already loaded 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]
+      [TeX-arg-key-val (LaTeX-fontspec-font-features)]
       LaTeX-fontspec-arg-font)
 
     ;; 1.16 Creating a language
     '("babelprovide"
-      [ TeX-arg-key-val LaTeX-babel-babelprovide-key-val-options ]
+      [TeX-arg-key-val LaTeX-babel-babelprovide-key-val-options]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Language")
                     LaTeX-babel-language-list))
 
-    ;; 1.18 Getting the current language name
+    ;; 1.19 Accessing language info
     '("languagename" 0)
     '("iflanguage" TeX-arg-babel-lang t nil)
 
-    ;; 1.19 Hyphenation and line breaking
+    ;; 1.20 Hyphenation and line breaking
     '("babelhyphen"
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Type/Text")
-                    '("soft" "hard" "repeat" "empty")))
+                    '("soft" "hard" "repeat" "nobreak" "empty")))
     '("babelhyphen*"
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Type/Text")
-                    '("soft" "hard" "repeat" "empty")))
+                    '("soft" "hard" "repeat" "nobreak" "empty")))
 
     '("babelhyphenation"
-      [ TeX-arg-eval mapconcat #'identity
-        (TeX-completing-read-multiple
-         (TeX-argument-prompt nil nil "Language(s)")
-         LaTeX-babel-language-list)
-        "," ]
+      [TeX-arg-eval mapconcat #'identity
+                    (TeX-completing-read-multiple
+                     (TeX-argument-prompt nil nil "Language(s)")
+                     LaTeX-babel-language-list)
+                    ","]
       t)
 
-    ;; 1.20 Selecting scripts
+    ;; 1.23 Selecting scripts
     '("ensureascii" "Text")
 
-    ;; 1.22 Language attributes
+    ;; 1.25 Language attributes
     '("languageattribute" TeX-arg-babel-lang t))
 
    ;; New environments: 1.8 Auxiliary language selectors
@@ -420,10 +419,10 @@
                   "OT1" "OT2" "OT3" "OT4" "OT6"
                   "T1"  "T2A" "T2B" "T2C" "T3" "T4" "T5"
                   "X2"  "LY1" "LV1" "LGR"))
-      ("hyphenmap" ("off" "main" "select" "other" "other*"))
+      ("hyphenmap" ("off" "first" "select" "other" "other*"))
       ("bidi" ("default" "basic" "basic-r" "bidi-l" "bidi-r"))
-      ("layout" ("sectioning" "counters" "lists" "captions"
-                 "contents" "footnotes" "columns" "extras"))
+      ("layout" ("sectioning" "counters" "lists" "contents" "footnotes"
+                 "captions"  "columns" "graphics" "extras"))
       ("base"))
     (mapcar #'list LaTeX-babel-language-list))))
 
diff --git a/style/backref.el b/style/backref.el
new file mode 100644
index 0000000..a7a6ef1
--- /dev/null
+++ b/style/backref.el
@@ -0,0 +1,94 @@
+;;; backref.el --- AUCTeX style for `backref.sty'  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-02-06
+;; 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 Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
+
+;;; Commentary:
+
+;; This file adds support for `backref.sty' v1.41 form 2021-02-04.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "backref"
+ (lambda ()
+
+   (TeX-add-symbols
+    '("backrefsetup"
+      (TeX-arg-key-val (("verbose" ("true" "false"))
+                        ("enable" ("true" "false"))
+                        ("disable" ("true" "false")))))
+    "backrefparscanfalse"
+    "backrefparscantrue"
+    "backrefprint"
+    "backref"
+    "backrefalt"
+    "backrefsep"
+    "backreftwosep"
+    "backreflastsep"
+    "backrefentrycount")
+
+   ;; This is a hack: We want to have the 2 macros
+   ;; \backrefparscanfalse and \backrefparscantrue indented like
+   ;; \bibitem, hence we add them to a local version of
+   ;; `LaTeX-item-regexp':
+   (unless (string-match-p "backrefparscan" LaTeX-item-regexp)
+     (setq-local LaTeX-item-regexp
+                 (concat LaTeX-item-regexp
+                         "\\|" "backrefparscan\\(false\\|true\\)\\b")))
+
+   ;; Only add "backrefprint" here, "backrefparscan*" will be added
+   ;; via `LaTeX-item-regexp' when `LaTeX-set-paragraph-start' is
+   ;; called:
+   (LaTeX-paragraph-commands-add-locally '("backrefprint"))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("backrefsetup"        "{")
+                                ("backrefparscanfalse" "")
+                                ("backrefparscantrue"  "")
+                                ("backrefprint"        ""))
+                              'function)))
+ TeX-dialect)
+
+(defvar LaTeX-backref-package-options
+  '("ref" "pageref" "hyperref" "hyperpageref"
+    "enable" "disable" "verbose"
+    "english" "american" "australian" "british" "canadian"
+    "newzealand" "UKenglish" "USenglish"
+    "german" "ngerman" "austrian" "naustrian"
+    "french" "acadian" "canadien" "frenchb" "francais"
+    "spanish" "brazil" "brazilian" "afrikaans")
+  "Package options for the backref package.")
+
+;;; backref.el ends here
diff --git a/style/bidi.el b/style/bidi.el
index 6f1f0b3..1b17d60 100644
--- a/style/bidi.el
+++ b/style/bidi.el
@@ -1,6 +1,6 @@
 ;;; bidi.el --- AUCTeX style for the (XeLaTeX) bidi package  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2016--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2021 Free Software Foundation, Inc.
 
 ;; Author: Uwe Brauer <oub@mat.ucm.es>
 ;; Created: 2016-03-06
@@ -36,9 +36,6 @@
 (declare-function font-latex-add-keywords
                   "font-latex"
                   (keywords class))
-(declare-function TeX-check-engine-add-engines
-                  "tex-buf"
-                  (&rest engines))
 
 (defvar LaTeX-bidi-package-options
   '("RTLdocument" "rldocument" "extrafootnotefeatures")
@@ -55,9 +52,8 @@
 (TeX-add-style-hook
  "bidi"
  (lambda ()
+
    ;; bidi.sty requires xelatex, so set the engine
-   (unless (featurep 'tex-buf)
-     (require 'tex-buf))
    (TeX-check-engine-add-engines 'xetex)
 
    ;; 1.4 Turning TeX--XeT features on and off
diff --git a/style/booktabs.el b/style/booktabs.el
index 7de74b6..79571ea 100644
--- a/style/booktabs.el
+++ b/style/booktabs.el
@@ -41,8 +41,8 @@
   "Prompt for a value and use parentheses when it is inserted.
 If OPTIONAL is non-nil the parameter is labeled as optional.
 PROMPT is the value of the prompt to be shown."
-  (let ((TeX-arg-opening-brace "\(")
-        (TeX-arg-closing-brace "\)"))
+  (let ((TeX-arg-opening-brace "(")
+        (TeX-arg-closing-brace ")"))
     (TeX-parse-argument optional prompt)))
 
 (TeX-add-style-hook
diff --git a/style/cancel.el b/style/cancel.el
new file mode 100644
index 0000000..765fe68
--- /dev/null
+++ b/style/cancel.el
@@ -0,0 +1,63 @@
+;;; cancel.el --- AUCTeX style for `cancel.sty'  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-11-24
+;; 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 Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
+
+;;; Commentary:
+
+;; This file adds support for `cancel.sty' v2.2 form 2013-04-12.
+
+;;; Code:
+
+(require 'tex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "cancel"
+ (lambda ()
+   (TeX-add-symbols
+    '("cancel"   "Expression")
+    '("bcancel"  "Expression")
+    '("xcancel"  "Expression")
+    '("cancelto" "Value" "Expression")
+    "CancelColor")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("cancel"   "|{\\")
+                                ("bcancel"  "|{\\")
+                                ("xcancel"  "|{\\"))
+                              'textual)))
+ TeX-dialect)
+
+(defvar LaTeX-cancel-package-options
+  '("thicklines" "samesize" "smaller" "Smaller")
+  "Package options for the cancel package.")
+
+;;; cancel.el ends here
diff --git a/style/caption.el b/style/caption.el
index 988a9bb..134157a 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -1,6 +1,6 @@
 ;;; caption.el --- AUCTeX style for `caption.sty' (v3.4a)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -50,8 +50,11 @@
 
 (declare-function LaTeX-babel-active-languages "babel" ())
 (declare-function LaTeX-polyglossia-active-languages "polyglossia" ())
+(declare-function LaTeX-newfloat-DeclareFloatingEnvironment-list
+                  "newfloat" ())
 
 (defvar LaTeX-bicaption-key-val-options)
+(defvar LaTeX-subcaption-key-val-options)
 
 (defvar LaTeX-caption-key-val-options
   '(("aboveskip")
@@ -113,9 +116,93 @@
     ("width"))
   "Key=value options for caption macros.")
 
-(defvar LaTeX-caption-key-val-options-local nil
-  "Buffer-local key=value options for caption macros.")
-(make-variable-buffer-local 'LaTeX-caption-key-val-options-local)
+(defun LaTeX-caption-key-val-options ()
+  "Return an updated list of key=vals from caption package.
+The key=val list will also contain elements from subcaption
+package if loaded."
+  ;; Update the style list once so we don't run this function more
+  ;; than once:
+  (TeX-style-list)
+  (append
+   ;; Check if `subcaption.el' is loaded:
+   (when (member "subcaption" TeX-active-styles)
+     ;; If loaded, update also the entry for `subrefformat' when
+     ;; processing the `labelformat'.  `subrefformat' keys takes the
+     ;; same values as `labelformat'.  We have to check if we have an
+     ;; entry for `\DeclareCaptionLabelFormat', otherwise there is no
+     ;; need to run this procedure:
+     (if (and (LaTeX-caption-DeclareCaption-list)
+              (string-match
+               "\\\\DeclareCaptionLabelFormat"
+               (mapconcat #'identity
+                          (mapcar #'car
+                                  (LaTeX-caption-DeclareCaption-list))
+                          "|")))
+         (progn
+           (let (result)
+             (dolist (keyvals (LaTeX-caption-DeclareCaption-list) result)
+               (when (string-equal (nth 1 keyvals) "LabelFormat")
+                 (let* ((key "subrefformat")
+                        (val (nth 2 keyvals))
+                        (vals-predefined
+                         (cadr (assoc key
+                                      LaTeX-subcaption-key-val-options)))
+                        (vals-parsed
+                         (cadr (assoc key result))))
+                   (cl-pushnew (list key (TeX-delete-duplicate-strings
+                                          (append vals-predefined
+                                                  vals-parsed
+                                                  (list val))))
+                               result :test #'equal))))))
+       LaTeX-subcaption-key-val-options))
+   ;; Check if `bicaption.el' is loaded:
+   (when (member "bicaption" TeX-active-styles)
+     (append
+      (cond ((and (member "babel" TeX-active-styles)
+                  (LaTeX-babel-active-languages))
+             `(,(list "language"
+                      (butlast (LaTeX-babel-active-languages)))))
+            ((and (member "polyglossia" TeX-active-styles)
+                  (LaTeX-polyglossia-active-languages))
+             `(,(list "language"
+                      (butlast (LaTeX-polyglossia-active-languages)))))
+            (t nil))
+      LaTeX-bicaption-key-val-options))
+   ;; Support for environments defined with `newfloat.sty': These
+   ;; environments are added to `type' and `type*' keys:
+   (when (and (member "newfloat" TeX-active-styles)
+              (LaTeX-newfloat-DeclareFloatingEnvironment-list))
+     (let (result)
+       (dolist (key '("type" "type*") result)
+         (let ((val (mapcar #'car
+                            (LaTeX-newfloat-DeclareFloatingEnvironment-list)))
+               (vals-predefined
+                (cadr (assoc key LaTeX-caption-key-val-options))))
+           (cl-pushnew (list key (TeX-delete-duplicate-strings
+                                  (append vals-predefined
+                                          val)))
+                       result :test #'equal)))))
+   ;; Update to standard key-vals from `caption.el':
+   (when (LaTeX-caption-DeclareCaption-list)
+     (let (result)
+       (dolist (keyvals (LaTeX-caption-DeclareCaption-list) result)
+         (let* ((key (if (string-equal (nth 1 keyvals) "LabelSeparator")
+                         (downcase (substring (nth 1 keyvals) 0 8))
+                       (downcase (nth 1 keyvals))))
+                (val (nth 2 keyvals))
+                (vals-predefined
+                 (cadr (assoc key LaTeX-caption-key-val-options)))
+                (vals-parsed (cadr (assoc key result))))
+           ;; For `\DeclareCaptionOption', only add the value
+           ;; (remember:      key=^^^^^^, val="defined key")
+           (if (string-equal key "option")
+               (cl-pushnew (list val) result :test #'equal)
+             (cl-pushnew (list key (TeX-delete-duplicate-strings
+                                    (append vals-predefined
+                                            vals-parsed
+                                            (list val))))
+                         result :test #'equal))))))
+   LaTeX-caption-key-val-options))
 
 (defvar LaTeX-caption-supported-float-types
   '("figure" "table" "ContinuedFloat"   ; Standard caption.sty
@@ -130,9 +217,9 @@
     "SCfigure" "SCtable"                ; sidecap.sty
     "supertabular" "xtabular"           ; supertabular.sty & xtab.sty
     "threeparttable" "measuredfigure"   ; threeparttable.sty
-    "wrapfigure" "wraptable")           ; wrapfigure
-  "List of float types provided by other LaTeX packages and
-supported by `caption.sty'.")
+    "wrapfigure" "wraptable")           ; wrapfigure.sty
+  "List of float types supported by `caption.sty'.
+These types are provided by other LaTeX packages.")
 
 ;; Setup for various \DeclareCaption's:
 (TeX-auto-add-type "caption-DeclareCaption" "LaTeX")
@@ -149,8 +236,7 @@ supported by `caption.sty'.")
              "[ \t\n\r%]*"
              "{\\([^}]+\\)}")
     (0 1 2) LaTeX-auto-caption-DeclareCaption)
-  "Matches the arguments of different `\\DeclareCaption*' from
-`caption.sty'.")
+  "Matches the arguments of different `\\DeclareCaption*' from `caption.sty'.")
 
 (defun LaTeX-caption-auto-prepare ()
   "Clear `LaTeX-auto-caption-DeclareCaption' before parsing."
@@ -159,75 +245,14 @@ supported by `caption.sty'.")
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-caption-auto-prepare t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
-(defun LaTeX-caption-update-key-val-options ()
-  "Update the buffer-local key-val options before offering them
-in `caption'-completions."
-  (dolist (keyvals (LaTeX-caption-DeclareCaption-list))
-    (let* ((key (cond ((string-equal (nth 1 keyvals) "LabelSeparator")
-                       (downcase (substring (nth 1 keyvals) 0 8)))
-                      (t (downcase (nth 1 keyvals)))))
-           (val (nth 2 keyvals))
-           (val-match (cdr (assoc key LaTeX-caption-key-val-options-local)))
-           (temp (copy-alist LaTeX-caption-key-val-options-local))
-           ;; If `subcaption.el' is loaded, delete and update also the
-           ;; entry for `subrefformat' when processing the `labelformat'.
-           (opts (progn
-                   (when (and (string-equal key "labelformat")
-                              (boundp 'LaTeX-subcaption-key-val-options))
-                     (setq temp
-                           (assq-delete-all
-                            (car (assoc (caar 
LaTeX-subcaption-key-val-options) temp))
-                            temp)))
-                   (assq-delete-all (car (assoc key temp)) temp))))
-      ;; For `\DeclareCaptionOption', only add the value
-      ;; (remember:      key=^^^^^^, val="defined key")
-      (if (string-equal key "option")
-          (cl-pushnew (list val) opts :test #'equal)
-        ;; For anything but `\DeclareCaptionOption', do the standard
-        ;; procedure.  Again, take care of `subrefformat' for `subcaption.el'.
-        (if val-match
-            (progn
-              (when (and (string-equal key "labelformat")
-                         (boundp 'LaTeX-subcaption-key-val-options))
-                (cl-pushnew (list "subrefformat"
-                                  (TeX-delete-duplicate-strings (apply 
#'append (list val) val-match)))
-                            opts :test #'equal))
-              (cl-pushnew (list key (TeX-delete-duplicate-strings (apply 
#'append (list val) val-match)))
-                          opts :test #'equal))
-          (cl-pushnew (list key (list val)) opts :test #'equal)))
-      (setq LaTeX-caption-key-val-options-local (copy-alist opts))))
-  ;; Support for environments defined with newfloat.sty: These
-  ;; environments are added to "type" and "type*" key:
-  (when (and (member "newfloat" (TeX-style-list))
-             (fboundp 'LaTeX-newfloat-DeclareFloatingEnvironment-list)
-             (LaTeX-newfloat-DeclareFloatingEnvironment-list))
-    (dolist (key '("type" "type*"))
-      (let* ((val (mapcar #'car 
(LaTeX-newfloat-DeclareFloatingEnvironment-list)))
-             (val-match (cdr (assoc key LaTeX-caption-key-val-options-local)))
-             (temp (copy-alist LaTeX-caption-key-val-options-local))
-             (opts (assq-delete-all (car (assoc key temp)) temp)))
-        (cl-pushnew (list key (TeX-delete-duplicate-strings (apply #'append 
val val-match)))
-                    opts :test #'equal)
-        (setq LaTeX-caption-key-val-options-local (copy-alist opts))))))
-
-(defun LaTeX-arg-caption-command (optional &optional prompt)
-  "Insert caption-commands from `caption.sty'. If OPTIONAL,
-indicate `(Optional)' while reading key=val and insert it in
-square brackets.  PROMPT replaces the standard one."
-  (LaTeX-caption-update-key-val-options)
-  (let ((opts (TeX-read-key-val optional
-                                LaTeX-caption-key-val-options-local
-                                prompt)))
-    (TeX-argument-insert opts optional)))
-
 ;; In `LaTeX-caption-DeclareCaption-regexp', we match (0 1 2).  When
 ;; adding a new `Name', we need something unique for `0'-match until
 ;; the next `C-c C-n'.  We mimic that regex-match bei concat'ing the
 ;; elements.  It will vanish upon next `C-c C-n'.
 (defun LaTeX-arg-caption-DeclareCaption (optional format)
-  "Insert various `\\DeclareCaptionFORMAT' commands.  If
-OPTIONAL, insert argument in square brackets.  FORMAT is the
-suffix of the command."
+  "Insert various `\\DeclareCaptionFORMAT' commands.
+If OPTIONAL, insert argument in square brackets.  FORMAT is the
+suffix of the LaTeX macro."
   (let ((name (TeX-read-string "Name: ")))
     (LaTeX-add-caption-DeclareCaptions
      (list (concat "\\DeclareCaption" format "{" name "}")
@@ -251,6 +276,7 @@ suffix of the command."
 
 (defun LaTeX-arg-caption-captionbox (optional &optional star)
   "Query for the arguments of \"\\captionbox\" incl. a label and insert them.
+If OPTIONAL is non-nil, indicate it while reading the caption.
 If STAR is non-nil, then do not query for a \\label and a short
 caption, insert only a caption."
   (let* ((currenv (LaTeX-current-environment))
@@ -339,25 +365,6 @@ STAR is non-nil, do not query for a short-caption and a 
label."
    ;; Add caption to the parser.
    (TeX-auto-add-regexp LaTeX-caption-DeclareCaption-regexp)
 
-   ;; Activate the buffer-local version of key-vals.
-   (setq LaTeX-caption-key-val-options-local
-         (copy-alist LaTeX-caption-key-val-options))
-
-   ;; Append key=vals from bicaption.sty if loaded: "language" key
-   ;; depends on the active languages, it is appended extra where main
-   ;; language is removed from the list:
-   (when (and (member "bicaption" (TeX-style-list))
-              ;; Make sure that one of these packages is loaded:
-              (or (fboundp 'LaTeX-babel-active-languages)
-                  (fboundp 'LaTeX-polyglossia-active-languages)))
-     (setq LaTeX-caption-key-val-options-local
-           (append
-            `(,(list "language"
-                     (or (butlast (LaTeX-babel-active-languages))
-                         (butlast (LaTeX-polyglossia-active-languages)))))
-            LaTeX-bicaption-key-val-options
-            LaTeX-caption-key-val-options-local)))
-
    ;; Caption commands:
    (TeX-add-symbols
     '("caption*" t)
@@ -377,7 +384,7 @@ STAR is non-nil, do not query for a short-caption and a 
label."
                            ([TeX-arg-eval completing-read
                                           (TeX-argument-prompt t nil "Float 
type")
                                           
LaTeX-caption-supported-float-types]))
-      (LaTeX-arg-caption-command))
+      (TeX-arg-key-val (LaTeX-caption-key-val-options)))
 
     '("captionsetup*"
       (TeX-arg-conditional (member "bicaption" (TeX-style-list))
@@ -385,15 +392,19 @@ STAR is non-nil, do not query for a short-caption and a 
label."
                            ([TeX-arg-eval completing-read
                                           (TeX-argument-prompt t nil "Float 
type")
                                           
LaTeX-caption-supported-float-types]))
-      (LaTeX-arg-caption-command))
+      (TeX-arg-key-val (LaTeX-caption-key-val-options)))
 
     '("clearcaptionsetup"
-      [LaTeX-arg-caption-command "Single key"]
+      [TeX-arg-eval completing-read
+                    (TeX-argument-prompt t nil "Single key")
+                    (LaTeX-caption-key-val-options)]
       (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type")
                     LaTeX-caption-supported-float-types))
 
     '("clearcaptionsetup*"
-      [LaTeX-arg-caption-command "Single key"]
+      [TeX-arg-eval completing-read
+                    (TeX-argument-prompt t nil "Single key")
+                    (LaTeX-caption-key-val-options)]
       (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type")
                     LaTeX-caption-supported-float-types))
 
@@ -433,8 +444,8 @@ STAR is non-nil, do not query for a short-caption and a 
label."
 
     '("DeclareCaptionStyle"
       (LaTeX-arg-caption-DeclareCaption "Style")
-      [LaTeX-arg-caption-command "Additional options"]
-      (LaTeX-arg-caption-command "Options"))
+      [TeX-arg-key-val (LaTeX-caption-key-val-options) "Additional options"]
+      (TeX-arg-key-val (LaTeX-caption-key-val-options) "Options"))
 
     '("DeclareCaptionTextFormat"
       (LaTeX-arg-caption-DeclareCaption "TextFormat") t)
diff --git a/style/cuted.el b/style/cuted.el
new file mode 100644
index 0000000..cb769fc
--- /dev/null
+++ b/style/cuted.el
@@ -0,0 +1,73 @@
+;;; cuted.el --- AUCTeX style for `cuted.sty' (v2.0)  -*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `cuted.sty' (v2.0) from 2021/10/04.
+;; `cuted.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "cuted"
+ (lambda ()
+
+   ;; Add the only environment provided by the package:
+   (LaTeX-add-environments "strip")
+
+   ;; This is a glue, in LaTeX set with \setlength:
+   (LaTeX-add-lengths "stripsep")
+
+   ;; New symbols
+   (TeX-add-symbols
+    '("preCutedStrip"  t)
+    '("postCutedStrip" t)
+    '("oldcolsbreak"   t))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("preCutedStrip"  "{")
+                                ("postCutedStrip" "{")
+                                ("oldcolsbreak"   "{"))
+                              'function)))
+ TeX-dialect)
+
+(defvar LaTeX-cuted-package-options
+  '("spread"  "nospread"  "shrink"  "noshrink"
+    "lspread" "nolspread" "lshrink" "nolshrink"
+    "rspread" "norspread" "rshrink" "norshrink"
+    "debug"   "nodebug")
+  "Package options for the cuted package.")
+
+;;; cuted.el ends here
diff --git a/style/empheq.el b/style/empheq.el
index ac88b77..b9f32b1 100644
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -1,6 +1,6 @@
 ;;; empheq.el --- AUCTeX style for `empheq.sty' (v2.14)  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2016-2020 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -91,10 +91,6 @@
     ("marginbox"))
   "Key=value options for environments from empheq.sty.")
 
-(defvar LaTeX-empheq-key-val-options-local nil
-  "Buffer-local key=value options for environments from empheq.sty.")
-(make-local-variable 'LaTeX-empheq-key-val-options-local)
-
 (defvar LaTeX-empheq-supported-amsmath-envs
   '("equation"  "equation*"
     "align"     "align*"
@@ -136,45 +132,40 @@
   "Process parsed delimiters."
   (dolist (delim (mapcar #'car (LaTeX-empheq-declaredelimiter-list)))
     (TeX-add-symbols (concat "empheq" delim)
-                     (concat "empheqbig" delim)))
-  (LaTeX-empheq-update-key-val-options))
+                     (concat "empheqbig" delim))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-empheq-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-empheq-auto-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
-(defun LaTeX-empheq-update-key-val-options ()
-  "Update `LaTeX-empheq-key-val-options-local' if the function
-`LaTeX-empheq-declaredelimiter-list' returns non-nil."
-  (when (LaTeX-empheq-declaredelimiter-list)
-    (let ((lvals (cadr (assoc "left" LaTeX-empheq-key-val-options)))
-          (rvals (cadr (assoc "right" LaTeX-empheq-key-val-options)))
-          (tmp (copy-alist LaTeX-empheq-key-val-options))
-          lval rval)
-      (dolist (delims (LaTeX-empheq-declaredelimiter-list))
-        (let ((delim (car delims))
-              (where (cadr delims)))
-          (if (string= where "Left")
-              (progn
-                (cl-pushnew (concat TeX-esc "empheq" delim) lval :test #'equal)
-                (cl-pushnew (concat TeX-esc "empheqbig" delim) lval :test 
#'equal))
-            (progn
-              (cl-pushnew (concat TeX-esc "empheq" delim) rval :test #'equal)
-              (cl-pushnew (concat TeX-esc "empheqbig" delim) rval :test 
#'equal)))))
-      (when lval
-        (setq tmp (assq-delete-all (car (assoc "left" tmp)) tmp))
-        (setq lvals (append lval lvals))
-        (push (list "left" lvals) tmp))
-      (when rval
-        (setq tmp (assq-delete-all (car (assoc "right" tmp)) tmp))
-        (setq rvals (append rval rvals))
-        (push (list "right" rvals) tmp))
-      (setq LaTeX-empheq-key-val-options-local
-            (copy-alist tmp)))))
+(defun LaTeX-empheq-key-val-options ()
+  "Return an updated list of key=vals from empheq package.
+This function retrieves values of user defined left and right
+delimiters and prepends them to variable
+`LaTeX-empheq-key-val-options'."
+  (append
+   (when (LaTeX-empheq-declaredelimiter-list)
+     (let ((lvals (copy-sequence
+                   (cadr (assoc "left" LaTeX-empheq-key-val-options))))
+           (rvals (copy-sequence
+                   (cadr (assoc "right" LaTeX-empheq-key-val-options)))))
+       (dolist (delims (LaTeX-empheq-declaredelimiter-list))
+         (let ((delim (car delims))
+               (where (cadr delims)))
+           (if (string= where "Left")
+               (progn
+                 (cl-pushnew (concat TeX-esc "empheq" delim)    lvals :test 
#'equal)
+                 (cl-pushnew (concat TeX-esc "empheqbig" delim) lvals :test 
#'equal))
+             (cl-pushnew (concat TeX-esc "empheq" delim)    rvals :test 
#'equal)
+             (cl-pushnew (concat TeX-esc "empheqbig" delim) rvals :test 
#'equal))))
+       `(("left" ,lvals)
+         ("right" ,rvals))))
+   LaTeX-empheq-key-val-options))
 
 (defun LaTeX-empheq-env (env)
-  "Query for a supported amsmath environment and insert it accordingly."
-  (let* ((keyvals (TeX-read-key-val t LaTeX-empheq-key-val-options-local))
+  "Query for a supported amsmath environment and insert it accordingly.
+ENV is the name of environment passed to the function in the style hook."
+  (let* ((keyvals (TeX-read-key-val t (LaTeX-empheq-key-val-options)))
          (amsenv (completing-read
                   (TeX-argument-prompt nil nil "amsmath environment")
                   LaTeX-empheq-supported-amsmath-envs))
@@ -212,16 +203,26 @@ This function combines the capabilities of 
`LaTeX-env-label' and
       (let ((ncols (TeX-read-string
                     (TeX-argument-prompt nil nil "Number of columns")))
             (keyvals (TeX-read-key-val t
-                                       LaTeX-empheq-key-val-options-local
+                                       (LaTeX-empheq-key-val-options)
                                        "empheq options (k=v)")))
-        (LaTeX-insert-environment env (concat TeX-grop ncols TeX-grcl
-                                              (when (and keyvals (not (string= 
keyvals "")))
-                                                (concat LaTeX-optop keyvals 
LaTeX-optcl))))
+        (LaTeX-insert-environment env
+                                  (concat TeX-grop ncols TeX-grcl
+                                          (when (and keyvals
+                                                     (not (string= keyvals 
"")))
+                                            (concat LaTeX-optop
+                                                    keyvals
+                                                    LaTeX-optcl))))
         (LaTeX-item-equation-alignat t))
     (let ((keyvals
-           (TeX-read-key-val t LaTeX-empheq-key-val-options-local "empheq 
options (k=v)")))
-      (LaTeX-insert-environment env (when (and keyvals (not (string= keyvals 
"")))
-                                      (concat LaTeX-optop keyvals 
LaTeX-optcl)))
+           (TeX-read-key-val t
+                             (LaTeX-empheq-key-val-options)
+                             "empheq options (k=v)")))
+      (LaTeX-insert-environment env
+                                (when (and keyvals
+                                           (not (string= keyvals "")))
+                                  (concat LaTeX-optop
+                                          keyvals
+                                          LaTeX-optcl)))
       (when (and (assoc env LaTeX-label-alist)
                  (LaTeX-label env 'environment))
         (LaTeX-newline)
@@ -283,13 +284,6 @@ number of ampersands if possible."
    ;; Load amsmath.el and mathtools.el
    (TeX-run-style-hooks "amsmath" "mathtools")
 
-   ;; Local version of key-val options
-   (setq LaTeX-empheq-key-val-options-local
-         (copy-alist LaTeX-empheq-key-val-options))
-
-   ;; Initial update of key-vals
-   (LaTeX-empheq-update-key-val-options)
-
    (LaTeX-add-environments
     '("empheq" LaTeX-empheq-env))
 
@@ -302,7 +296,7 @@ number of ampersands if possible."
      (reftex-add-label-environments '(("empheq" ?e nil nil t))))
 
    (TeX-add-symbols
-    '("empheqset" (TeX-arg-key-val LaTeX-empheq-key-val-options-local))
+    '("empheqset" (TeX-arg-key-val (LaTeX-empheq-key-val-options)))
 
     ;; 1.4 Special delimiters
     ;; Normal
@@ -377,12 +371,12 @@ number of ampersands if possible."
       '("flalign"    LaTeX-empheq-env-overload)
       '("gather"     LaTeX-empheq-env-overload)
       '("multline"   LaTeX-empheq-env-overload)
-      '("align*"     LaTeX-env-args [TeX-arg-key-val 
LaTeX-empheq-key-val-options-local])
+      '("align*"     LaTeX-env-args [TeX-arg-key-val 
(LaTeX-empheq-key-val-options)])
       '("alignat*"   LaTeX-empheq-env-overload)
-      '("equation*"  LaTeX-env-args [TeX-arg-key-val 
LaTeX-empheq-key-val-options-local])
-      '("flalign*"   LaTeX-env-args [TeX-arg-key-val 
LaTeX-empheq-key-val-options-local])
-      '("gather*"    LaTeX-env-args [TeX-arg-key-val 
LaTeX-empheq-key-val-options-local])
-      '("multline*"  LaTeX-env-args [TeX-arg-key-val 
LaTeX-empheq-key-val-options-local])
+      '("equation*"  LaTeX-env-args [TeX-arg-key-val 
(LaTeX-empheq-key-val-options)])
+      '("flalign*"   LaTeX-env-args [TeX-arg-key-val 
(LaTeX-empheq-key-val-options)])
+      '("gather*"    LaTeX-env-args [TeX-arg-key-val 
(LaTeX-empheq-key-val-options)])
+      '("multline*"  LaTeX-env-args [TeX-arg-key-val 
(LaTeX-empheq-key-val-options)])
 
       ;; Original definitions are stored prefixed with "AmS"
       '("AmSalign"      LaTeX-env-label)
@@ -455,7 +449,6 @@ number of ampersands if possible."
            (TeX-add-symbols (concat "empheq" delim)
                             (concat "empheqbig" delim))
            (LaTeX-add-empheq-declaredelimiters `(,delim "Left"))
-           (LaTeX-empheq-update-key-val-options)
            (concat TeX-esc delim)))))
 
     '("DeclareRightDelimiter"
@@ -466,7 +459,6 @@ number of ampersands if possible."
            (TeX-add-symbols (concat "empheq" delim)
                             (concat "empheqbig" delim))
            (LaTeX-add-empheq-declaredelimiters `(,delim "Right"))
-           (LaTeX-empheq-update-key-val-options)
            (concat TeX-esc delim))))))
 
    ;; 4.2 Fine-tuning of delimiters
diff --git a/style/enumitem.el b/style/enumitem.el
index 1a858b1..d8ad056 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -1,6 +1,6 @@
-;;; enumitem.el --- AUCTeX style for `enumitem.sty' (v3.6)  -*- 
lexical-binding: t; -*-
+;;; enumitem.el --- AUCTeX style for `enumitem.sty' (v3.9)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015, 2016, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `enumitem.sty' (v3.6) from 2018/11/30.
+;; This file adds support for `enumitem.sty' (v3.9) from 2019/06/20.
 ;; `enumitem.sty' is part of TeXLive.
 
 ;; Tassilo Horn's `minted.el' was a major source of inspiration for
@@ -112,18 +112,19 @@
     ("beginpenalty")
     ("midpenalty")
     ("endpenalty")
+    ;; 3.6 Injecting code
     ("before")
     ("before*")
     ("after")
     ("after*")
     ("first")
     ("first*")
-    ;; 3.6 Description styles
+    ;; 3.7 Description styles
     ("style" ("standard" "unboxed" "nextline" "sameline" "multiline"))
-    ;; 3.7 Compact lists
+    ;; 3.8 Compact lists
     ("noitemsep")
     ("nosep")
-    ;; 3.8 Wide lists
+    ;; 3.9 Wide lists
     ("wide")
     ;; 4 Inline lists
     ("itemjoin")
@@ -132,14 +133,48 @@
     ("mode" ("boxed" "unboxed")))
   "Key=value options for enumitem macros and environments.")
 
-(defvar LaTeX-enumitem-key-val-options-local nil
-  "Buffer-local key=value options for enumitem macros and environments.")
-(make-variable-buffer-local 'LaTeX-enumitem-key-val-options-local)
-
-(defvar LaTeX-enumitem-newlist-list-local nil
-  "Local list of all environments definded with `\\newlist' plus
-the ones initially available through `enumitem' package.")
-(make-variable-buffer-local 'LaTeX-enumitem-newlist-list-local)
+(defun LaTeX-enumitem-key-val-options ()
+  "Return an updated list of key=vals from enumitem package."
+  (append
+   ;; New keys are valueless, so take them as is:
+   (when (LaTeX-enumitem-SetEnumitemKey-list)
+     (LaTeX-enumitem-SetEnumitemKey-list))
+   ;; New values defined available keys: We have to collect predefined
+   ;; values (if any) from `LaTeX-enumitem-key-val-options' (stored in
+   ;; `vals-predefined') and user-defined values (stored in
+   ;; `vals-parsed') which were parsed and added to `result' in the
+   ;; previous run of `dolist' and then combine them as value to a
+   ;; key.
+   (when (LaTeX-enumitem-SetEnumitemValue-list)
+     (let (result)
+       (dolist (keyvals (LaTeX-enumitem-SetEnumitemValue-list) result)
+         (let* ((key (nth 1 keyvals))
+                (val (nth 2 keyvals))
+                (vals-predefined
+                 (cadr (assoc key LaTeX-enumitem-key-val-options)))
+                (vals-parsed (cadr (assoc key result))))
+           ;; Remove entry in `result' if there is one for the `key':
+           (when (assoc key result)
+             (setq result (assq-delete-all (car (assoc key result))
+                                           result)))
+           ;; Add the entry to `result'; also remove any duplicates
+           (cl-pushnew (list key (TeX-delete-duplicate-strings
+                                  (append vals-parsed
+                                          vals-predefined
+                                          (list val))))
+                       result :test #'equal)))))
+   ;; New values to `align' key: We collect the predefined ones from
+   ;; `LaTeX-enumitem-key-val-options' in `vals-predefined' and
+   ;; prepend them to newly parsed ones:
+   (when (LaTeX-enumitem-SetLabelAlign-list)
+     (let* ((key "align")
+            (vals (mapcar #'car (LaTeX-enumitem-SetLabelAlign-list)))
+            (vals-predefined (cadr
+                              (assoc key LaTeX-enumitem-key-val-options))))
+       `(("align" ,(TeX-delete-duplicate-strings
+                    (append vals-predefined vals))))))
+   ;; Predefined key=vals:
+   LaTeX-enumitem-key-val-options))
 
 ;; Setup for \newlist:
 
@@ -148,8 +183,7 @@ the ones initially available through `enumitem' package.")
 (defvar LaTeX-enumitem-newlist-regexp
   '("\\\\newlist{\\([^}]+\\)}{\\([^}]+\\)}"
     (1 2) LaTeX-auto-enumitem-newlist)
-  "Matches the arguments of `\\newlist' from `enumitem'
-package.")
+  "Matches the arguments of `\\newlist' from `enumitem' package.")
 
 ;; Setup for \SetLabelAlign:
 
@@ -158,8 +192,7 @@ package.")
 (defvar LaTeX-enumitem-SetLabelAlign-regexp
   '("\\\\SetLabelAlign{\\([^}]+\\)}"
     1 LaTeX-auto-enumitem-SetLabelAlign)
-  "Matches the argument of `\\SetLabelAlign' from `enumitem'
-package.")
+  "Matches the argument of `\\SetLabelAlign' from `enumitem' package.")
 
 ;; Setup for \SetEnumitemKey:
 
@@ -168,8 +201,7 @@ package.")
 (defvar LaTeX-enumitem-SetEnumitemKey-regexp
   '("\\\\SetEnumitemKey{\\([^}]+\\)}"
     1 LaTeX-auto-enumitem-SetEnumitemKey)
-  "Matches the arguments of `\\SetEnumitemKey' from `enumitem'
-package.")
+  "Matches the arguments of `\\SetEnumitemKey' from `enumitem' package.")
 
 ;; Setup for \SetEnumitemValue:
 
@@ -185,8 +217,7 @@ package.")
 (defvar LaTeX-enumitem-SetEnumitemValue-regexp
   '("\\\\SetEnumitemValue{\\([^}]+\\)}{\\([^}]+\\)}"
     (0 1 2) LaTeX-auto-enumitem-SetEnumitemValue)
-  "Matches the arguments of `\\SetEnumitemValue' from `enumitem'
-package.")
+  "Matches the arguments of `\\SetEnumitemValue' from `enumitem' package.")
 
 ;; Plug them into the machinery.
 (defun LaTeX-enumitem-auto-prepare ()
@@ -208,25 +239,18 @@ package.")
       (when (or (string-equal type "description")
                 (string-equal type "description*"))
         (add-to-list 'LaTeX-item-list `(,env . LaTeX-item-argument)))
-      ;; Add new env's to `ispell-tex-skip-alist': skip the optional argument
-      (TeX-ispell-skip-setcdr `((,env ispell-tex-arg-end 0)))))
-  ;; Now add the parsed env's to the local list.
-  (when (LaTeX-enumitem-newlist-list)
-    (setq LaTeX-enumitem-newlist-list-local
-          (append (mapcar #'list (mapcar #'car (LaTeX-enumitem-newlist-list)))
-                  LaTeX-enumitem-newlist-list-local))))
+      ;; Add new env's to `ispell-tex-skip-alist': skip the opt. arg:
+      (TeX-ispell-skip-setcdr `((,env ispell-tex-arg-end 0))))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-enumitem-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-enumitem-auto-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
 (defun LaTeX-enumitem-env-with-opts (env)
-  "Update available key-val options, then insert ENV and optional
-key-val and the first item."
-  (LaTeX-enumitem-update-key-val-options)
+  "Insert ENV provided by `enumitem' package."
   (LaTeX-insert-environment
    env
-   (let ((opts (TeX-read-key-val t LaTeX-enumitem-key-val-options-local)))
+   (let ((opts (TeX-read-key-val t (LaTeX-enumitem-key-val-options))))
      (when (and opts (not (string-equal opts "")))
        (format "[%s]" opts))))
   (if (TeX-active-mark)
@@ -253,21 +277,20 @@ key-val and the first item."
                 (current-fill-column)))
     (LaTeX-fill-paragraph nil)))
 
-(defun LaTeX-arg-SetLabelAlign (optional)
-  "Ask for new type (value) for the \"align\" key and add it to
-`LaTeX-enumitem-key-val-options-local'."
-  (LaTeX-enumitem-update-key-val-options)
+(defun LaTeX-arg-enumitem-SetLabelAlign (optional)
+  "Ask and insert a new type (value) for the \"align\" key.
+Insert value in brackets if OPTIONAL is non-nil."
   (let ((val (TeX-read-string "Alignment: ")))
     (TeX-argument-insert val optional)
     (LaTeX-add-enumitem-SetLabelAligns val)))
 
-(defun LaTeX-arg-SetEnumitemKey (optional)
-  "Ask for a new key to be defined and add it to
-`LaTeX-enumitem-key-val-options-local'."
-  (LaTeX-enumitem-update-key-val-options)
+(defun LaTeX-arg-enumitem-SetEnumitemKey (optional)
+  "Ask and insert a new key and its replacement.
+Insert key and value in brackets if OPTIONAL is non-nil."
   (let ((key     (TeX-read-string "New Key: "))
         (replace (TeX-read-key-val optional
-                                   LaTeX-enumitem-key-val-options-local 
"Replacement")))
+                                   (LaTeX-enumitem-key-val-options)
+                                   "Replacement")))
     (TeX-argument-insert key     optional)
     (TeX-argument-insert replace optional)
     (LaTeX-add-enumitem-SetEnumitemKeys key)))
@@ -278,11 +301,10 @@ key-val and the first item."
 ;; the elements and pass the result to
 ;; `LaTeX-add-enumitem-SetEnumitemValues'.  It will vanish upon next
 ;; invocation of `C-c C-n'.
-(defun LaTeX-arg-SetEnumitemValue (optional)
-  "Ask for a new value added to an existing key incl. the final
-replacement of the value."
-  (LaTeX-enumitem-update-key-val-options)
-  (let ((key (completing-read  "Key: " LaTeX-enumitem-key-val-options-local))
+(defun LaTeX-arg-enumitem-SetEnumitemValue (optional)
+  "Ask and insert for a new value added to an existing key.
+Insert key and value in brackets if OPTIONAL is non-nil."
+  (let ((key (completing-read  "Key: " LaTeX-enumitem-key-val-options))
         (val (TeX-read-string "String value: ")))
     (TeX-argument-insert key optional)
     (TeX-argument-insert val optional)
@@ -290,32 +312,41 @@ replacement of the value."
      (list (concat "\\SetEnumitemValue{" key "}{" val "}")
            key val))))
 
-(defun LaTeX-enumitem-update-key-val-options ()
-  "Update the buffer-local key-val options before offering them
-in `enumitem'-completions."
-  (dolist (key (LaTeX-enumitem-SetEnumitemKey-list))
-    (add-to-list 'LaTeX-enumitem-key-val-options-local key))
-  (dolist (keyvals (LaTeX-enumitem-SetEnumitemValue-list))
-    (let* ((key (nth 1 keyvals))
-           (val (nth 2 keyvals))
-           ;; (key-match (car (assoc key 
LaTeX-enumitem-key-val-options-local)))
-           (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
-           (temp (copy-alist LaTeX-enumitem-key-val-options-local))
-           (opts (assq-delete-all (car (assoc key temp)) temp)))
-      (if val-match
-          (cl-pushnew (list key (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
-                      opts :test #'equal)
-        (cl-pushnew (list key (list val)) opts :test #'equal))
-      (setq LaTeX-enumitem-key-val-options-local (copy-alist opts))))
-  (dolist (newalign (LaTeX-enumitem-SetLabelAlign-list))
-    (let* ((key "align")
-           (val (car newalign))
-           (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
-           (temp (copy-alist LaTeX-enumitem-key-val-options-local))
-           (opts (assq-delete-all (car (assoc key temp)) temp)))
-      (cl-pushnew (list key (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
-                  opts :test #'equal)
-      (setq LaTeX-enumitem-key-val-options-local (copy-alist opts)))))
+(defun LaTeX-arg-enumitem-setlist (_optional)
+  "Insert the arguments of `\\setlist' macro from `enumitem' package.
+This function inserts three arguments.  The first optional
+argument is only available when the package option `sizes' is
+provided.  OPTIONAL is ignored."
+  ;; First opt. argument:
+  (when (LaTeX-provided-package-options-member "enumitem" "sizes")
+    (let* ((TeX-arg-opening-brace "<")
+           (TeX-arg-closing-brace ">")
+           (sizes '("script" "tiny" "footnote" "small" "normal"
+                    "large" "Large" "LARGE" "huge" "Huge"))
+           (size (completing-read
+                  (TeX-argument-prompt t nil "Size")
+                  (append
+                   (mapcar (lambda (x) (concat "-" x)) sizes)
+                   (mapcar (lambda (x) (concat x "-")) sizes)
+                   sizes))))
+      (TeX-argument-insert size t)))
+  ;; Second opt. argument:
+  (TeX-argument-insert
+   (mapconcat #'identity
+              (TeX-completing-read-multiple
+               (TeX-argument-prompt t nil "Environment(s), level(s)")
+               (append
+                (when (LaTeX-provided-package-options-member
+                       "enumitem" "includedisplayed")
+                  '("trivlist"))
+                (mapcar #'car (LaTeX-enumitem-newlist-list))
+                '("1" "2" "3" "4")))
+              ",")
+   t)
+  ;; Mandatory argument:
+  (TeX-argument-insert
+   (TeX-read-key-val nil (LaTeX-enumitem-key-val-options))
+   nil))
 
 (TeX-add-style-hook
  "enumitem"
@@ -327,19 +358,16 @@ in `enumitem'-completions."
    (TeX-auto-add-regexp LaTeX-enumitem-SetEnumitemValue-regexp)
    (TeX-auto-add-regexp LaTeX-enumitem-SetLabelAlign-regexp)
 
-   ;; Activate the buffer-local version of key-vals.
-   (setq LaTeX-enumitem-key-val-options-local
-         (copy-alist LaTeX-enumitem-key-val-options))
-
-   ;; Set the standard env's to the local list.
-   (setq LaTeX-enumitem-newlist-list-local
-         '(("itemize") ("enumerate") ("description")))
+   ;; Add the standard environments:
+   (LaTeX-add-enumitem-newlists '("itemize"     "itemize")
+                                '("enumerate"   "enumerate")
+                                '("description" "description"))
 
-   ;; Add the starred versions to the local list.
+   ;; Add the starred versions with the 'inline' package option:
    (when (LaTeX-provided-package-options-member "enumitem" "inline")
-     (setq LaTeX-enumitem-newlist-list-local
-           (append '(("itemize*") ("enumerate*") ("description*"))
-                   LaTeX-enumitem-newlist-list-local)))
+     (LaTeX-add-enumitem-newlists '("itemize*"     "itemize*")
+                                  '("enumerate*"   "enumerate*")
+                                  '("description*" "description*")))
 
    ;; Standard env's take key-val as optional argument.
    (LaTeX-add-environments
@@ -355,8 +383,11 @@ in `enumitem'-completions."
       '("description*" LaTeX-enumitem-env-with-opts))
      (add-to-list 'LaTeX-item-list '("description*" . LaTeX-item-argument)))
 
-   ;; 7 Cloning the basic lists
    (TeX-add-symbols
+    ;; 6 Size dependent settings
+    '("SetEnumitemSize" 2)
+
+    ;; 7 Cloning the basic lists
     ;; The easy way would be:
     ;; '("newlist"
     ;;   "Name" (TeX-arg-eval
@@ -373,11 +404,8 @@ in `enumitem'-completions."
          (let ((name (TeX-read-string "Name: "))
                (type (completing-read
                       "Type: "
-                      '(("itemize")  ("enumerate")  ("description")
-                        ("itemize*") ("enumerate*") ("description*"))))
+                      (mapcar #'cadr (LaTeX-enumitem-newlist-list))))
                (depth (TeX-read-string "Max-depth: ")))
-           (setq LaTeX-enumitem-newlist-list-local
-                 (append `(,(list name)) LaTeX-enumitem-newlist-list-local))
            (when (or (string-equal type "description")
                      (string-equal type "description*"))
              (add-to-list 'LaTeX-item-list `(,name . LaTeX-item-argument)))
@@ -391,28 +419,13 @@ in `enumitem'-completions."
     ;; \renewlist{<name>}{<type>}{<max-depth>}
     '("renewlist"
       (TeX-arg-eval completing-read "Name: "
-                    LaTeX-enumitem-newlist-list-local)
+                    (mapcar #'car (LaTeX-enumitem-newlist-list)))
       (TeX-arg-eval completing-read "Type: "
-                    '(("itemize")  ("enumerate")  ("description")
-                      ("itemize*") ("enumerate*") ("description*")))
+                    (mapcar #'cadr (LaTeX-enumitem-newlist-list)))
       "Max-depth")
 
-    ;; \setlist[<names,levels>]{<key-vals>}
-    '("setlist"
-      [TeX-arg-eval mapconcat #'identity
-                    (TeX-completing-read-multiple
-                     (TeX-argument-prompt t nil "Environment(s), level(s)")
-                     (append
-                      (when (LaTeX-provided-package-options-member "enumitem"
-                                                                   
"includedisplayed")
-                        '("trivlist"))
-                      LaTeX-enumitem-newlist-list-local
-                      '(("1") ("2") ("3") ("4")))) ","]
-      (TeX-arg-eval
-       (lambda ()
-         (LaTeX-enumitem-update-key-val-options)
-         (let ((opts (TeX-read-key-val nil 
LaTeX-enumitem-key-val-options-local)))
-           (format "%s" opts)))))
+    ;; \setlist<size>[<names,levels>]{<key-vals>}
+    '("setlist" LaTeX-arg-enumitem-setlist)
 
     ;; \setlist*[<names,levels>]{<key-vals>}
     '("setlist*"
@@ -423,13 +436,10 @@ in `enumitem'-completions."
                       (when (LaTeX-provided-package-options-member "enumitem"
                                                                    
"includedisplayed")
                         '("trivlist"))
-                      LaTeX-enumitem-newlist-list-local
-                      '(("1") ("2") ("3") ("4")))) ","]
-      (TeX-arg-eval
-       (lambda ()
-         (LaTeX-enumitem-update-key-val-options)
-         (let ((opts (TeX-read-key-val nil 
LaTeX-enumitem-key-val-options-local)))
-           (format "%s" opts))))) )
+                      (mapcar #'car (LaTeX-enumitem-newlist-list))
+                      '("1" "2" "3" "4")))
+                    ","]
+      (TeX-arg-key-val (LaTeX-enumitem-key-val-options))) )
 
    ;; General commands:
    (TeX-add-symbols
@@ -460,13 +470,13 @@ in `enumitem'-completions."
            (completing-read "List name: " enums)))))
 
     ;; "Align" is added as new value to "align" key in key-val list.
-    '("SetLabelAlign" LaTeX-arg-SetLabelAlign t)
+    '("SetLabelAlign" LaTeX-arg-enumitem-SetLabelAlign t)
 
     ;; "Key" will be parsed and added to key-val list.
-    '("SetEnumitemKey" LaTeX-arg-SetEnumitemKey)
+    '("SetEnumitemKey" LaTeX-arg-enumitem-SetEnumitemKey)
 
     ;; "Key" and "Value" are added to our key-val list.
-    '("SetEnumitemValue" LaTeX-arg-SetEnumitemValue "Replacement")
+    '("SetEnumitemValue" LaTeX-arg-enumitem-SetEnumitemValue "Replacement")
 
     ;; v3.6 has a macro for visual debugging.
     '("DrawEnumitemLabel" 0))
@@ -476,23 +486,31 @@ in `enumitem'-completions."
      (TeX-add-symbols
       '("SetEnumerateShortLabel"
         (TeX-arg-eval completing-read "Key: "
-                      '(("A") ("a") ("I") ("i") ("1")))
+                      '("A" "a" "I" "i" "1"))
         "Replacement")))
 
    ;; Add \labelindent to list of known lengths:
-   (LaTeX-add-lengths "labelitem")
+   (LaTeX-add-lengths "labelindent")
 
    ;; Fontification
    (when (and (featurep 'font-latex)
               (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("newlist"             "{{{")
                                 ("renewlist"           "{{{")
-                                ("setlist"             "*[{")
+                                ("SetEnumitemSize"     "{{")
                                 ("AddEnumerateCounter" "*{{{")
                                 ("SetLabelAlign"       "{{")
                                 ("SetEnumitemKey"      "{{" )
                                 ("SetEnumitemValue"    "{{{"))
                               'function)
+     ;; Cater for additional optionals arg <size> based on package
+     ;; option 'sizes':
+     (font-latex-add-keywords
+      (if (LaTeX-provided-package-options-member "enumitem" "sizes")
+          '(("setlist" "*<[{"))
+        '(("setlist" "*[{")))
+      'function)
+
      (font-latex-add-keywords '(("restartlist"            "{" )
                                 ("setlistdepth"           "{" )
                                 ("SetEnumerateShortLabel" "{{"))
diff --git a/style/fancyvrb.el b/style/fancyvrb.el
index 37dc3c7..22e52c2 100644
--- a/style/fancyvrb.el
+++ b/style/fancyvrb.el
@@ -1,6 +1,6 @@
 ;;; fancyvrb.el --- AUCTeX style for `fancyvrb.sty' version 3.6.  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013, 2014, 2016-2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2016-2021 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano <mose@gnu.org>
@@ -67,6 +67,10 @@
 (declare-function font-latex-set-syntactic-keywords
                   "font-latex")
 
+(declare-function LaTeX-color-definecolor-list "color" ())
+(declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
+(defvar LaTeX-fvextra-key-val-options)
+
 (defvar LaTeX-fancyvrb-key-val-options
   `(("commentchar" ("none"))
     ("gobble")
@@ -120,12 +124,52 @@
     ("aftersave"))
   "Key=value options for fancyvrb macros and environments.")
 
-(defvar LaTeX-fancyvrb-key-val-options-local nil
-  "Buffer-local key=value options for fancyvrb macros and environments.
-This variable is intended for packages like \"fvextra\" which
-provide new key=values for fancyvrb environments.  New key=values
-should be appended to this variable.")
-(make-variable-buffer-local 'LaTeX-fancyvrb-key-val-options-local)
+(defun LaTeX-fancyvrb-key-val-options ()
+  "Return an updated list of key=vals from fancyvrb package.
+This function also checks if the package fvextra is used and
+takes its key=vals into account."
+  (append
+   ;; Check if fvextra is loaded in combination with x?color:
+   (when (and (member "fvextra" (TeX-style-list))
+              (or (member "xcolor" TeX-active-styles)
+                  (member "color" TeX-active-styles)))
+     (let* ((colorcmd (if (member "xcolor" TeX-active-styles)
+                          #'LaTeX-xcolor-definecolor-list
+                        #'LaTeX-color-definecolor-list))
+            (keys '("highlightcolor"
+                    "rulecolor"
+                    "fillcolor"
+                    "tabcolor"
+                    "spacecolor"))
+            (colors (mapcar #'car (funcall colorcmd)))
+            result)
+       (dolist (key keys result)
+         (if (string= key "highlightcolor")
+             (push (list key colors) result)
+           (push (list key (cons "none" colors)) result)))))
+
+   ;; Check if fvextra is loaded:
+   (when (member "fvextra" TeX-active-styles)
+     LaTeX-fvextra-key-val-options)
+
+   ;; Check if fancyvrb is loaded in combination with x?color:
+   (when (and (not (member "fvextra" TeX-active-styles))
+              (or (member "xcolor" TeX-active-styles)
+                  (member "color" TeX-active-styles)))
+     (let* ((colorcmd (if (member "xcolor" TeX-active-styles)
+                          #'LaTeX-xcolor-definecolor-list
+                        #'LaTeX-color-definecolor-list))
+            (colors (mapcar (lambda (x)
+                              (concat TeX-esc "color" TeX-grop x TeX-grcl))
+                            (mapcar #'car (funcall colorcmd))))
+            (keys '("rulecolor" "fillcolor"))
+            val result)
+       (dolist (key keys result)
+         (setq val (cadr (assoc key LaTeX-fancyvrb-key-val-options)))
+         (push (list key (append val colors)) result))))
+
+   ;; Plain fancyvrb:
+   LaTeX-fancyvrb-key-val-options))
 
 (defvar LaTeX-fancyvrb-base-macros
   '("VerbatimInput" "BVerbatimInput" "LVerbatimInput"
@@ -232,7 +276,7 @@ RECUSTOM is non-nil, delete macros from the variable
         (TeX-argument-insert new-mac optional TeX-esc))
       (TeX-argument-insert base-mac optional)
       (TeX-argument-insert
-       (TeX-read-key-val optional LaTeX-fancyvrb-key-val-options-local) 
optional)
+       (TeX-read-key-val optional (LaTeX-fancyvrb-key-val-options)) optional)
       (LaTeX-add-fancyvrb-macros `(,new-mac ,base-mac ,rec-flag))))
   ;;
   ;; Now run the procdure: Do not use the function
@@ -253,7 +297,7 @@ RECUSTOM is non-nil, delete macros from the variable
       (cond ((member base-mac '("VerbatimInput" "BVerbatimInput" 
"LVerbatimInput"))
              (TeX-add-symbols
               `(,mac-name
-                [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+                [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
                 LaTeX-fancyvrb-arg-file-relative))
              (when (and (fboundp 'font-latex-add-keywords)
                         (eq TeX-install-font-lock 'font-latex-setup))
@@ -263,7 +307,7 @@ RECUSTOM is non-nil, delete macros from the variable
             ((string= base-mac "SaveVerb")
              (TeX-add-symbols
               `(,mac-name
-                [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+                [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
                 (TeX-arg-eval
                  (lambda ()
                    (let ((name (TeX-read-string
@@ -291,12 +335,12 @@ RECUSTOM is non-nil, delete macros from the variable
             (t
              (TeX-add-symbols
               `(,mac-name
-                [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+                [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
                 TeX-arg-verb)
               ;; Defined macros have a starred version where the
               ;; `showspaces' key is set to true
               `(,(concat mac-name "*")
-                [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+                [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
                 TeX-arg-verb))
              (add-to-list 'LaTeX-verbatim-macros-with-delims-local
                           mac-name t)
@@ -329,7 +373,7 @@ update only various AUCTeX variables for verbatim 
environments."
       (TeX-argument-insert new-env optional)
       (TeX-argument-insert base-env optional)
       (TeX-argument-insert
-       (TeX-read-key-val optional LaTeX-fancyvrb-key-val-options-local) 
optional)
+       (TeX-read-key-val optional (LaTeX-fancyvrb-key-val-options)) optional)
       (LaTeX-add-fancyvrb-environments `(,new-env ,base-env))
       (when (string= base-env "SaveVerbatim")
         (LaTeX-add-fancyvrb-saveverbatims new-env))))
@@ -342,7 +386,7 @@ update only various AUCTeX variables for verbatim 
environments."
              (LaTeX-add-environments
               `(,env (lambda (env)
                        (let ((options (TeX-read-key-val
-                                       t LaTeX-fancyvrb-key-val-options-local))
+                                       t (LaTeX-fancyvrb-key-val-options)))
                              (file (TeX-read-string "Output file: ")))
                          (LaTeX-insert-environment
                           env
@@ -365,11 +409,11 @@ update only various AUCTeX variables for verbatim 
environments."
              ;; (cond ...):
              (LaTeX-add-environments
               `(,env LaTeX-env-args
-                     [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+                     [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
                      LaTeX-fancyvrb-env-reflabel-key-val))
              (LaTeX-add-environments
               `(,(concat env "*") LaTeX-env-args
-                [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+                [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
                 LaTeX-fancyvrb-env-reflabel-key-val))
              (add-to-list 'LaTeX-verbatim-environments-local (concat env "*"))
              (add-to-list 'LaTeX-indent-environment-list
@@ -523,17 +567,13 @@ ENV is the name of current environment as a string."
    (TeX-run-style-hooks
     "keyval")
 
-   ;; Activate the buffer-local version of key-vals.
-   (setq LaTeX-fancyvrb-key-val-options-local
-         (copy-alist LaTeX-fancyvrb-key-val-options))
-
    (TeX-add-symbols
     ;; Verbatim material in footnotes
     "VerbatimFootnotes"
     ;; Improved verbatim commands
-    '("Verb" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local] 
TeX-arg-verb)
+    '("Verb" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)] TeX-arg-verb)
     ;; \Verb also has a starred version:
-    '("Verb*" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local] 
TeX-arg-verb)
+    '("Verb*" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)] TeX-arg-verb)
     '("DefineShortVerb" (TeX-arg-eval
                          TeX-read-string
                          (TeX-argument-prompt nil nil "Character")
@@ -543,7 +583,7 @@ ENV is the name of current environment as a string."
                            (TeX-argument-prompt nil nil "Character")
                            TeX-esc))
     ;; Verbatim environments
-    '("fvset" (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
+    '("fvset" (TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)))
     ;; Changing individual line formatting
     "FancyVerbFormatLine"
     ;; Line numbering
@@ -562,7 +602,7 @@ ENV is the name of current environment as a string."
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Based on environment")
                     LaTeX-fancyvrb-base-environments)
-      (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)))
 
     '("CustomVerbatimCommand"
       LaTeX-fancyvrb-arg-define-macro)
@@ -571,7 +611,7 @@ ENV is the name of current environment as a string."
 
     ;; Saving and restoring verbatim text and environments
     '("SaveVerb"
-      [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       (TeX-arg-eval
        (lambda ()
          (let ((name (TeX-read-string
@@ -594,35 +634,35 @@ ENV is the name of current environment as a string."
                                    (LaTeX-fancyvrb-saveverbatim-list)))
 
     ;; Writing and reading verbatim files
-    '("VerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+    '("VerbatimInput" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-arg-file-relative)
-    '("BVerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+    '("BVerbatimInput" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-arg-file-relative)
-    '("LVerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+    '("LVerbatimInput" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-arg-file-relative))
 
    (LaTeX-add-environments
     '("Verbatim" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-env-reflabel-key-val)
     '("Verbatim*" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-env-reflabel-key-val)
     '("BVerbatim" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-env-reflabel-key-val)
     '("BVerbatim*" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-env-reflabel-key-val)
     '("LVerbatim" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-env-reflabel-key-val)
     '("LVerbatim*" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-env-reflabel-key-val)
     '("SaveVerbatim"
       (lambda (env)
-        (let ((options (TeX-read-key-val t 
LaTeX-fancyvrb-key-val-options-local))
+        (let ((options (TeX-read-key-val t (LaTeX-fancyvrb-key-val-options)))
               (name (TeX-read-string "Save name: ")))
           (LaTeX-insert-environment
            env
@@ -633,7 +673,7 @@ ENV is the name of current environment as a string."
           (LaTeX-add-fancyvrb-saveverbatims name))))
     '("VerbatimOut"
       (lambda (env)
-        (let ((options (TeX-read-key-val t 
LaTeX-fancyvrb-key-val-options-local))
+        (let ((options (TeX-read-key-val t (LaTeX-fancyvrb-key-val-options)))
               (file (TeX-read-string "Output file: ")))
           (LaTeX-insert-environment
            env
diff --git a/style/floatpag.el b/style/floatpag.el
new file mode 100644
index 0000000..0174174
--- /dev/null
+++ b/style/floatpag.el
@@ -0,0 +1,75 @@
+;;; floatpag.el --- AUCTeX style for `floatpag.sty' (v2.0)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `floatpag.sty' (v2.0) from 2021/10/04.
+;; `floatpag.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "floatpag"
+ (lambda ()
+
+   ;; Macros always available:
+   (TeX-add-symbols
+    '("floatpagestyle" (TeX-arg-pagestyle "Float pagestyle"))
+    '("thisfloatpagestyle" (TeX-arg-pagestyle "Float pagestyle")))
+
+   ;; The next one makes only sense if 'rotating' package is loaded:
+   (when (member "rotating" (TeX-style-list))
+     (TeX-add-symbols
+      '("rotfloatpagestyle" (TeX-arg-pagestyle "Float pagestyle"))))
+
+   ;; Load 'array.el' when the package option is provided:
+   (when (LaTeX-provided-package-options-member "floatpag" "array")
+     (TeX-run-style-hooks "array"))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("floatpagestyle"     "{")
+                                ("thisfloatpagestyle" "{"))
+                              'function)
+     (when (member "rotating" (TeX-style-list))
+       (font-latex-add-keywords '(("rotfloatpagestyle" "{"))
+                                'function))))
+
+ TeX-dialect)
+
+(defvar LaTeX-floatpag-package-options '("array")
+  "Package options for the floatpag package.")
+
+;;; floatpag.el ends here
diff --git a/style/floatrow.el b/style/floatrow.el
index 4f61606..be8878f 100644
--- a/style/floatrow.el
+++ b/style/floatrow.el
@@ -1,6 +1,6 @@
 ;;; floatrow.el --- AUCTeX style for `floatrow.sty' (v0.3b)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2017--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -146,9 +146,74 @@
     ("LTcapwidth" ("table" "contents")))
   "Key=value options for floatrow macros and environments.")
 
-(defvar LaTeX-floatrow-key-val-options-local nil
-  "Buffer-local key=value options for floatrow macros and environments.")
-(make-variable-buffer-local 'LaTeX-floatrow-key-val-options-local)
+(defun LaTeX-floatrow-key-val-options ()
+  "Return an updated list of key=vals from floatrow package."
+  (append
+   (when (LaTeX-floatrow-DeclareNewOption-list)
+     (let ((vcode-keys '("precode" "rowprecode" "midcode" "postcode" 
"rowpostcode"))
+           (sep-keys '("floatrowsep" "capbesidesep"))
+           result)
+       (dolist (keyvals (LaTeX-floatrow-DeclareNewOption-list) result)
+         (let* ((key (cond ((string= (nth 1 keyvals) "FloatStyle")
+                            "style")
+                           ((string= (nth 1 keyvals) "FloatFont")
+                            "font")
+                           ((string= (nth 1 keyvals) "FloatVCode")
+                            "precode")
+                           ((string= (nth 1 keyvals) "ColorBox")
+                            "colorframeset")
+                           ((string= (nth 1 keyvals) "CBoxCorners")
+                            "colorframecorners")
+                           ((string= (nth 1 keyvals) "ObjectSet")
+                            "objectset")
+                           ((string= (nth 1 keyvals) "MarginSet")
+                            "margins")
+                           ((string= (nth 1 keyvals) "FloatSeparators")
+                            "floatrowsep")
+                           ((string= (nth 1 keyvals) "FloatFootnoterule")
+                            "footnoterule")
+                           (t nil)))
+                (val (nth 2 keyvals))
+                (vals-predefined
+                 (cadr (assoc key LaTeX-floatrow-key-val-options)))
+                (vals-parsed (cadr (assoc key result))))
+           ;; Remove entry in `result' if there is one for the `key'.
+           ;; `precode' and `floatrowsep' are special here since they
+           ;; are placeholders for other keys (see above):
+           (cond ((string= key "precode")
+                  (dolist (x vcode-keys)
+                    (when (assoc x result)
+                      (setq result (assq-delete-all (car (assoc x result)) 
result)))))
+                 ((string= key "floatrowsep")
+                  (dolist (x sep-keys)
+                    (when (assoc x result)
+                      (setq result (assq-delete-all (car (assoc x result)) 
result)))))
+                 (t
+                  (when (assoc key result)
+                    (setq result (assq-delete-all (car (assoc key result)) 
result)))))
+           ;; Add the entrie to `result'.  Again, watch for `precode'
+           ;; and `floatrowsep'.  Also delete any dupes:
+           (cond ((string= key "precode")
+                  (dolist (x vcode-keys)
+                    (cl-pushnew (list x (TeX-delete-duplicate-strings
+                                         (append vals-parsed
+                                                 vals-predefined
+                                                 (list val))))
+                                result :test #'equal)))
+                 ((string= key "floatrowsep")
+                  (dolist (x sep-keys)
+                    (cl-pushnew (list x (TeX-delete-duplicate-strings
+                                         (append vals-parsed
+                                                 vals-predefined
+                                                 (list val))))
+                                result :test #'equal)))
+                 (t
+                  (cl-pushnew (list key (TeX-delete-duplicate-strings
+                                         (append vals-parsed
+                                                 vals-predefined
+                                                 (list val))))
+                              result :test #'equal)))))))
+   LaTeX-floatrow-key-val-options))
 
 (defvar LaTeX-floatrow-supported-float-types
   '("figure" "table"                              ; Standard LaTeX
@@ -228,10 +293,6 @@
   ;; Replace initially the way fig & tab env's are inserted:
   (LaTeX-floatrow-env-init)
   ;;
-  ;; Process new key=val options:
-  (when (LaTeX-floatrow-DeclareNewOption-list)
-    (LaTeX-floatrow-update-key-val-options))
-  ;;
   ;; Process new float commands like \ffigbox:
   (when (LaTeX-floatrow-newfloatcommand-list)
     (dolist (cmd (mapcar #'car (LaTeX-floatrow-newfloatcommand-list)))
@@ -291,56 +352,6 @@
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-floatrow-auto-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
-(defun LaTeX-floatrow-update-key-val-options ()
-  "Update buffer-local key-val options before offering for completion."
-  (let ((vcode-keys '("precode" "rowprecode" "midcode" "postcode" 
"rowpostcode"))
-        (sep-keys '("floatrowsep" "capbesidesep")))
-    (dolist (keyvals (LaTeX-floatrow-DeclareNewOption-list))
-      (let* ((key (cond ((string= (nth 1 keyvals) "FloatStyle")
-                         "style")
-                        ((string= (nth 1 keyvals) "FloatFont")
-                         "font")
-                        ((string= (nth 1 keyvals) "FloatVCode")
-                         "precode")
-                        ((string= (nth 1 keyvals) "ColorBox")
-                         "colorframeset")
-                        ((string= (nth 1 keyvals) "CBoxCorners")
-                         "colorframecorners")
-                        ((string= (nth 1 keyvals) "ObjectSet")
-                         "objectset")
-                        ((string= (nth 1 keyvals) "MarginSet")
-                         "margins")
-                        ((string= (nth 1 keyvals) "FloatSeparators")
-                         "floatrowsep")
-                        ((string= (nth 1 keyvals) "FloatFootnoterule")
-                         "footnoterule")
-                        (t nil)))
-             (val (nth 2 keyvals))
-             (val-match (cadr (assoc key 
LaTeX-floatrow-key-val-options-local)))
-             (temp (copy-alist LaTeX-floatrow-key-val-options-local))
-             (opts (cond ((string= key "precode")
-                          (dolist (x vcode-keys)
-                            (setq temp (assq-delete-all (car (assoc x temp)) 
temp)))
-                          temp)
-                         ((string= key "floatrowsep")
-                          (dolist (x sep-keys)
-                            (setq temp (assq-delete-all (car (assoc x temp)) 
temp)))
-                          temp)
-                         (t
-                          (assq-delete-all (car (assoc key temp)) temp)))))
-        (cond ((string= key "precode")
-               (dolist (x vcode-keys)
-                 (cl-pushnew (list x (TeX-delete-duplicate-strings (append 
(list val) val-match)))
-                             opts :test #'equal)))
-              ((string= key "floatrowsep")
-               (dolist (x sep-keys)
-                 (cl-pushnew (list x (TeX-delete-duplicate-strings (append 
(list val) val-match)))
-                             opts :test #'equal)))
-              (t
-               (cl-pushnew (list key (TeX-delete-duplicate-strings (append 
(list val) val-match)))
-                           opts :test #'equal)))
-        (setq LaTeX-floatrow-key-val-options-local (copy-alist opts))))))
-
 (defun LaTeX-floatrow-arg-floatbox (optional)
   "Query and insert arguments of float box commands from floatrow.sty.
 If OPTIONAL is non-nil, indicate optional argument during query."
@@ -477,10 +488,9 @@ a string and corresponds to first parsed element in
     (LaTeX-add-floatrow-DeclareNewOptions
      (list (concat TeX-esc "Declare" key TeX-grop val TeX-grcl)
            key val))
-    (LaTeX-floatrow-update-key-val-options)
     (TeX-argument-insert val optional)
     (TeX-argument-insert
-     (TeX-read-key-val optional LaTeX-floatrow-key-val-options-local) 
optional)))
+     (TeX-read-key-val optional (LaTeX-floatrow-key-val-options)) optional)))
 
 (defun LaTeX-floatrow-arg-newseparatedlabel/ref (optional type)
   "Query and insert user defined label and reference macros from floatrow.sty.
@@ -497,7 +507,7 @@ the string \"label\" or \"ref\"."
     (TeX-argument-insert cmd optional TeX-esc)))
 
 (defun LaTeX-floatrow-arg-declare-new-floattype (optional &optional cleanup)
-  "Query and insert the first argument of \"DeclareNewFloatType\" macro from 
floatrow.sty.
+  "Query and insert the first argument of \"DeclareNewFloatType\" macro.
 If OPTIONAL is non-nil, insert the argument in brackets.  If
 CLEANUP in non-nil, skip the query and insert process as we are
 inside the function `LaTeX-floatrow-auto-cleanup' and process
@@ -543,10 +553,6 @@ only the parsed items."
    (TeX-auto-add-regexp LaTeX-floatrow-newseparatedlabel-ref-regexp)
    (TeX-auto-add-regexp LaTeX-floatrow-DeclareNewFloatType-regexp)
 
-   ;; Activate the buffer-local version of key-vals
-   (setq LaTeX-floatrow-key-val-options-local
-         (copy-alist LaTeX-floatrow-key-val-options))
-
    ;; Add pre-defined float commands:
    (LaTeX-add-floatrow-newfloatcommands
     "ffigbox" "fcapside" "ttabbox")
@@ -556,9 +562,9 @@ only the parsed items."
     ;; 2.1 The \floatbox Macro
     ;; \floatbox[<preamble>]{<captype>}[<width>][<height>][<vert 
pos>]{<caption>}{<object>}
     '("floatbox"
-      [ TeX-arg-eval completing-read
-        (TeX-argument-prompt t nil "Preamble")
-        '("\\capbeside" "\\nocapbeside" "\\captop") ]
+      [TeX-arg-eval completing-read
+                    (TeX-argument-prompt t nil "Preamble")
+                    '("\\capbeside" "\\nocapbeside" "\\captop")]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Float type")
                     LaTeX-floatrow-supported-float-types)
@@ -608,14 +614,14 @@ only the parsed items."
 
     ;; 3 Float Layout Settings
     '("floatsetup"
-      [ TeX-arg-eval completing-read
-        (TeX-argument-prompt t nil "Float type")
-        LaTeX-floatrow-supported-float-types ]
-      (TeX-arg-key-val LaTeX-floatrow-key-val-options-local))
+      [TeX-arg-eval completing-read
+                    (TeX-argument-prompt t nil "Float type")
+                    LaTeX-floatrow-supported-float-types]
+      (TeX-arg-key-val (LaTeX-floatrow-key-val-options)))
 
     ;; 3.2 Settings for Current Float Environment
     '("thisfloatsetup"
-      (TeX-arg-key-val LaTeX-floatrow-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-floatrow-key-val-options)))
 
     ;; 3.3 Clearing of Settings for Current Float Type
     '("clearfloatsetup"
diff --git a/style/flushend.el b/style/flushend.el
new file mode 100644
index 0000000..db00ffc
--- /dev/null
+++ b/style/flushend.el
@@ -0,0 +1,77 @@
+;;; flushend.el --- AUCTeX style for `flushend.sty' (v2.0)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `flushend.sty' (v2.0) from 2021/10/04.
+;; `flushend.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "flushend"
+ (lambda ()
+
+   ;; New symbols
+   (TeX-add-symbols
+    "flushend"
+    "raggedend"
+    "flushcolsend"
+    "raggedcolsend"
+    '("atColsBreak" t)
+    '("atColsEnd" t)
+    "showcolsendrule")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("flushend"        "")
+                                ("raggedend"       "")
+                                ("flushcolsend"    "")
+                                ("raggedcolsend"   "")
+                                ("atColsBreak"     "{")
+                                ("atColsEnd"       "{")
+                                ("showcolsendrule" ""))
+                              'function)))
+ TeX-dialect)
+
+(defvar LaTeX-flushend-package-options
+  '("spread"  "nospread"  "shrink"  "noshrink"
+    "lspread" "nolspread" "lshrink" "nolshrink"
+    "rspread" "norspread" "rshrink" "norshrink"
+    "checkfootnote" "nocheckfootnote"
+    "checkfloat" "nocheckfloat"
+    "debug" "nodebug")
+  "Package options for the flushend package.")
+
+;;; flushend.el ends here
diff --git a/style/fontspec.el b/style/fontspec.el
index a618ca9..6970b75 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -1,6 +1,6 @@
-;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.6a.  -*- 
lexical-binding: t; -*-
+;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.7i.  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013, 2017, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2013--2021 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano <mose@gnu.org>
@@ -25,12 +25,12 @@
 
 ;;; Commentary:
 
-;; This file adds support for `fontspec.sty' version 2.6a.  Starting
+;; This file adds support for `fontspec.sty' version 2.7i.  Starting
 ;; with `fontspec.sty' v2.4, the order of mandatory font names and
 ;; optional font features in related macros has changed, i.e. optional
 ;; argument comes after the mandatory one.  This change is now (April
 ;; 2017) implemented in this file.  Fontification support retains
-;; backward compatibilty.
+;; backward compatibility.
 
 ;;; Code:
 
@@ -44,38 +44,39 @@
 
 (declare-function LaTeX-color-definecolor-list "color" ())
 (declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
-(declare-function TeX-check-engine-add-engines "tex-buf" (&rest engines))
 
 (defvar LaTeX-fontspec-font-features
-  '(;; 5 Font selection
+  '(;; I General font selection
     ("Extension" (".otf" ".ttf" ".ttc" ".dfont"))
     ("Path")
-    ;; 6.1 More control over font shape selection
+    ;; I 4.1 More control over font shape selection
+    ("UprightFont")
     ("BoldFont")
     ("ItalicFont")
     ("BoldItalicFont")
     ("SlantedFont")
     ("BoldSlantedFont")
     ("SmallCapsFont")
-    ;; 6.2 Specifically choosing the NFSS family
+    ;; I 4.2 Specifically choosing the NFSS family
     ("NFSSFamily")
+    ;; I 4.3 Choosing additional NFSS font faces
     ("FontFace")
-    ;; 11 Different features for different font shapes
-    ("UprightFeatures")
+    ;; III 3. Different features for different font shapes
     ("BoldFeatures")
     ("ItalicFeatures")
     ("BoldItalicFeatures")
     ("SlantedFeatures")
     ("BoldSlantedFeatures")
     ("SmallCapsFeatures")
-    ;; 13 Different features for different font sizes
+    ("UprightFeatures")
+    ;; III 4. Different features for different font sizes
     ("SizeFeatures")
-    ;; 14 Font independent options
+    ;; III 6. Font independent options
     ("Color")
     ("Scale" ("MatchLowercase" "MatchUppercase"))
     ("WordSpace")
     ("PunctuationSpace")
-    ("HyphenChar")
+    ("HyphenChar" ("None"))
     ("OpticalSize")
     ("AutoFakeBold")
     ("AutoFakeSlant")
@@ -83,74 +84,97 @@
     ("FakeStretch")
     ("FakeBold")
     ("LetterSpace")
-    ;; 16 OpenType options
-    ("Ligatures" ("Required"      "RequiredOff"
-                  "Common"        "CommonOff"
-                  "Contextual"    "ContextualOff"
-                  "Rare"          "RareOff"
-                  "Discretionary" "DiscretionaryOff"
-                  "Historic"      "HistoricOff"
-                  "TeX"
-                  "ResetAll"))
-    ("Letters" ("Uppercase"           "UppercaseOff"
-                "SmallCaps"           "SmallCapsOff"
-                "PetiteCaps"          "PetiteCapsOff"
-                "UppercaseSmallCaps"  "UppercaseSmallCapsOff"
-                "UppercasePetiteCaps" "UppercasePetiteCapsOff"
-                "Unicase"             "UnicaseOff"
+    ;; IV.3 OpenType options
+    ;; IV.3.1.1 Alternates.  The next 2 are synonyms:
+    ("Alternate" ("Random"))
+    ("StylisticAlternate" ("Random"))
+    ;; IV.3.1.2 Character Variants
+    ("CharacterVariant")
+    ;; IV 3.1.3 Contextuals
+    ("Contextuals" ("Swash"       "SwashOff"       "SwashReset"
+                    "Alternate"   "AlternateOff"   "AlternateReset"
+                    "WordInitial" "WordInitialOff" "WordInitialReset"
+                    "WordFinal"   "WordFinalOff"   "WordFinalReset"
+                    "LineFinal"   "LineFinalOff"   "LineFinal"
+                    "Inner"       "InnerOff"       "InnerReset"
+                    "ResetAll"))
+    ;; IV 3.1.4 Diacritics
+    ("Diacritics" ("MarkToBase" "MarkToBaseOff" "MarkToBaseReset"
+                   "MarkToMark" "MarkToMarkOff" "MarkToMarkReset"
+                   "AboveBase"  "AboveBaseOff"  "AboveBaseReset"
+                   "BelowBase"  "BelowBaseOff"  "BelowBaseReset"
+                   "ResetAll"))
+    ;; IV 3.1.5 Fractions
+    ("Fractions" ("On" "Off" "Reset" "Alternate"
+                  "AlternateOff" "AlternateReset" "ResetAll"))
+    ;; IV 3.1.6 Kerning
+    ("Kerning" ("On" "Off" "Reset" "ResetAll"
+                "Uppercase" "UppercaseOff" "UppercaseReset"))
+    ;; IV 3.1.7 Letters
+    ("Letters" ("SmallCaps"           "SmallCapsOff"           "SmallCapsReset"
+                "PetiteCaps"          "PetiteCapsOff"          
"PetiteCapsReset"
+                "UppercaseSmallCaps"  "UppercaseSmallCapsOff"  
"UppercaseSmallCapsReset"
+                "UppercasePetiteCaps" "UppercasePetiteCapsOff" 
"UppercasePetiteCapsReset"
+                "Unicase"             "UnicaseOff"             "UnicaseReset"
                 "ResetAll"))
-    ("Numbers" ("Uppercase"    "UppercaseOff"
-                "Lowercase"    "LowercaseOff"
-                "Lining"       "LiningOff"
-                "OldStyle"     "OldStyleOff"
-                "Proportional" "ProportionalOff"
-                "Monospaced"   "MonospacedOff"
-                "SlashedZero"  "SlashedZeroOff"
-                "Arabic"       "ArabicOff"
+    ;; IV 3.1.8 Ligatures
+    ("Ligatures" ("Required"      "RequiredOff"      "RequiredReset"
+                  "Common"        "CommonOff"        "CommonReset"
+                  "Contextual"    "ContextualOff"    "ContextualReset"
+                  "Rare"          "RareOff"          "RareReset"
+                  "Discretionary" "DiscretionaryOff" "DiscretionaryReset"
+                  "Historic"      "HistoricOff"      "HistoricReset"
+                  "TeX"           "TeXOff"           "TeXReset"
+                  "ResetAll"))
+    ;; IV 3.1.9 Localised Forms
+    ("LocalForms" ("On" "Off" "Reset"))
+    ;; IV 3.1.10 Numbers
+    ("Numbers" ("Uppercase"    "UppercaseOff"    "UppercaseReset"
+                "Lowercase"    "LowercaseOff"    "LowercaseReset"
+                "Lining"       "LiningOff"       "LiningReset"
+                "OldStyle"     "OldStyleOff"     "OldStyleReset"
+                "Proportional" "ProportionalOff" "ProportionalReset"
+                "Monospaced"   "MonospacedOff"   "MonospacedReset"
+                "SlashedZero"  "SlashedZeroOff"  "SlashedZeroReset"
+                "Arabic"       "ArabicOff"       "ArabicReset"
                 "ResetAll"))
-    ("Contextuals" ("Swash"       "SwashOff"
-                    "Alternate"   "AlternateOff"
-                    "WordInitial" "WordInitialOff"
-                    "WordFinal"   "WordFinalOff"
-                    "LineFinal"   "LineFinalOff"
-                    "Inner"       "InnerOff"
-                    "ResetAll"))
-    ("VerticalPosition" ("Superior"           "SuperiorOff"
-                         "Inferior"           "InferiorOff"
-                         "Numerator"          "NumeratorOff"
-                         "Denominator"        "DenominatorOff"
-                         "ScientificInferior" "ScientificInferiorOff"
-                         "Ordinal"            "OrdinalOff"
-                         "ResetAll"))
-    ("Fraction" ("On" "Off" "Reset" "Alternate" "AlternateOff" "ResetAll"))
-    ("StylisticSet")
-    ("CharacterVariant")
-    ("Alternate" ("Random"))
-    ("Style" ("Alternate"      "AlternateOff"
-              "Italic"         "ItalicOff"
-              "Ruby"           "RubyOff"
-              "Swash"          "SwashOff"
-              "Cursive"        "CursiveOff"
-              "Historic"       "HistoricOff"
-              "TitlingCaps"    "TitlingCapsOff"
-              "HorizontalKana" "HorizontalKanaOff"
-              "VerticalKana"   "VerticalKanaOff"
+    ;; IV 3.1.11 Ornament
+    ("Ornament")
+    ;; IV 3.1.12 Style
+    ("Style" ("Alternate"      "AlternateOff"      "AlternateReset"
+              "Italic"         "ItalicOff"         "ItalicReset"
+              "Ruby"           "RubyOff"           "RubyReset"
+              "Swash"          "SwashOff"          "SwashReset"
+              "Cursive"        "CursiveOff"        "CursiveReset"
+              "Historic"       "HistoricOff"       "HistoricReset"
+              "Titling"        "TitlingOff"        "TitlingReset"
+              "HorizontalKana" "HorizontalKanaOff" "HorizontalKanaReset"
+              "VerticalKana"   "VerticalKanaOff"   "VerticalKanaReset"
+              "Uppercase"      "UppercaseOff"      "UppercaseReset"
               "ResetAll"))
-    ("Diacritics" ("MarkToBase" "MarkToBaseOff"
-                   "MarkToMark" "MarkToMarkOff"
-                   "AboveBase"  "AboveBaseOff"
-                   "BelowBase"  "BelowBaseOff"
-                   "ResetAll"))
-    ("Kerning" ("Uppercase" "UppercaseOff" "On" "Off" "Reset" "ResetAll"))
-    ("CharacterWidth" ("Proportional"          "ProportionalOff"
-                       "Full"                  "FullOff"
-                       "Half"                  "HalfOff"
-                       "Third"                 "ThirdOff"
-                       "Quarter"               "QuarterOff"
-                       "AlternateProportional" "AlternateProportionalOff"
-                       "AlternateHalf"         "AlternateHalfOff"
-                       "ResetAll"))
+    ;; IV 3.1.13 Stylistic Set variations.   The next 2 are synonyms:
+    ("StylisticSet")
+    ("Variant")
+    ;; IV 3.1.14 Vertical Position
+    ("VerticalPosition" ("Superior"           "SuperiorOff"           
"SuperiorReset"
+                         "Inferior"           "InferiorOff"           
"InferiorReset"
+                         "Numerator"          "NumeratorOff"          
"NumeratorReset"
+                         "Denominator"        "DenominatorOff"        
"DenominatorReset"
+                         "ScientificInferior" "ScientificInferiorOff" 
"ScientificInferiorReset"
+                         "Ordinal"            "OrdinalOff"            
"OrdinalReset"
+                         "ResetAll"))
+    ;; IV 3.2.1 Annotation
     ("Annotation")
+    ;; IV 3.2.2 Character width
+    ("CharacterWidth" ("Proportional"          "ProportionalOff"          
"ProportionalReset"
+                       "Full"                  "FullOff"                  
"FullReset"
+                       "Half"                  "HalfOff"                  
"HalfReset"
+                       "Third"                 "ThirdOff"                 
"ThirdReset"
+                       "Quarter"               "QuarterOff"               
"QuarterReset"
+                       "AlternateProportional" "AlternateProportionalOff" 
"AlternateProportionalReset"
+                       "AlternateHalf"         "AlternateHalfOff"         
"AlternateHalfReset"
+                       "ResetAll"))
+    ;; IV 3.2.3 CJK shape
     ("CJKShape" ("Traditional"
                  "Simplified"
                  "JIS1978"
@@ -158,24 +182,21 @@
                  "JIS1990"
                  "Expert"
                  "NLC"))
-    ("Vertical" ("RotatedGlyphs"         "RotatedGlyphsOff"
-                 "AlternatesForRotation" "AlternatesForRotationOff"
-                 "Alternates"            "AlternatesOff"
-                 "KanaAlternates"        "KanaAlternatesOff"
-                 "Kerning"               "KerningOff"
-                 "AlternateMetrics"      "AlternateMetricsOff"
-                 "HalfMetrics"           "HalfMetricsOff"
-                 "ProportionalMetrics"   "ProportionalMetricsOff"
+    ;; IV 3.2.4 Vertical typesetting
+    ("Vertical" ("RotatedGlyphs"         "RotatedGlyphsOff"         
"RotatedGlyphsReset"
+                 "AlternatesForRotation" "AlternatesForRotationOff" 
"AlternatesForRotationReset"
+                 "Alternates"            "AlternatesOff"            
"AlternatesReset"
+                 "KanaAlternates"        "KanaAlternatesOff"        
"KanaAlternatesReset"
+                 "Kerning"               "KerningOff"               
"KerningReset"
+                 "AlternateMetrics"      "AlternateMetricsOff"      
"AlternateMetricsReset"
+                 "HalfMetrics"           "HalfMetricsOff"           
"HalfMetricsReset"
+                 "ProportionalMetrics"   "ProportionalMetricsOff"   
"ProportionalMetricsReset"
                  "ResetAll"))
-    ;; 25 Going behind fontspec's back: Offer only an excerpt of all
-    ;; possible tags:
+    ;; VIII 3. Going behind fontspec's back: Offer only an excerpt of
+    ;; all possible tags:
     ("RawFeature" ("frac" "lnum" "onum" "pnum" "smcp" "tnum" "zero")))
   "Font features options for macros of the fontspec package.")
 
-(defvar LaTeX-fontspec-font-features-local nil
-  "Buffer-local font features options for macros of the fontspec package.")
-(make-variable-buffer-local 'LaTeX-fontspec-font-features-local)
-
 (defvar LaTeX-fontspec-font-list nil
   "List of the fonts accessible to fontspec.")
 
@@ -209,21 +230,41 @@ to retrieve the list of fonts."
     (or LaTeX-fontspec-font-list LaTeX-fontspec-font-list-default))
    optional))
 
-(defun LaTeX-fontspec-update-font-features ()
-  "Update Color key=values in `LaTeX-fontspec-font-features-local'."
-  ;; Check if any color defininig package is loaded and update the
-  ;; key=values for coloring.  Prefer xcolor.sty if both packages are
-  ;; loaded.
-  (when (or (member "xcolor" (TeX-style-list))
-            (member "color" (TeX-style-list)))
-    (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
+(defun LaTeX-fontspec-font-features ()
+  "Return an updated list of font features.
+This function retrieves values from various sources and adds them
+to appropriate keys which are eventually prepended to
+`LaTeX-fontspec-font-features' shadowing the predefined one."
+  (append
+   ;; Check for color packages, prefer xcolor over color.  Note that
+   ;; we run the function `TeX-style-list' only once and after that we
+   ;; use the updated `TeX-active-styles'.
+   (when (or (member "xcolor" (TeX-style-list))
+             (member "color" TeX-active-styles))
+     (let ((colorcmd (if (member "xcolor" TeX-active-styles)
                          #'LaTeX-xcolor-definecolor-list
-                       #'LaTeX-color-definecolor-list))
-           (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
-            (copy-alist tmp)))))
+                       #'LaTeX-color-definecolor-list)))
+       `(("Color" ,(mapcar #'car (funcall colorcmd))))))
+   ;; If `LaTeX-fontspec-font-list' is set, use it for other `*Font'
+   ;; related keys:
+   (when LaTeX-fontspec-font-list
+     `(("UprightFont"     ,LaTeX-fontspec-font-list)
+       ("BoldFont"        ,LaTeX-fontspec-font-list)
+       ("ItalicFont"      ,LaTeX-fontspec-font-list)
+       ("BoldItalicFont"  ,LaTeX-fontspec-font-list)
+       ("SlantedFont"     ,LaTeX-fontspec-font-list)
+       ("BoldSlantedFont" ,LaTeX-fontspec-font-list)
+       ("SmallCapsFont"   ,LaTeX-fontspec-font-list)))
+   ;; This is a LuaTeX only feature.  VI. 1 Different font
+   ;; technologies and shapers
+   (when (eq TeX-engine 'luatex)
+     '(("Renderer" ("Harfbuzz" "OpenType" "AAT" "Graphite"))))
+   ;; This is a XeTeX only feature.  VII. 1 Different font
+   ;; technologies
+   (when (eq TeX-engine 'xetex)
+     '(("Renderer" ("OpenType" "AAT" "Graphite"))))
+   ;; Predefined features:
+   LaTeX-fontspec-font-features))
 
 ;; Setup for \newfontfamily and \newfontface:
 (TeX-auto-add-type "fontspec-newfontcmd" "LaTeX")
@@ -246,9 +287,7 @@ to retrieve the list of fonts."
     (when (and (featurep 'font-latex)
                (eq TeX-install-font-lock 'font-latex-setup))
       (font-latex-add-keywords `((,mac ""))
-                               'type-declaration)))
-  ;; Update values of Color key:
-  (LaTeX-fontspec-update-font-features))
+                               'type-declaration))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-fontspec-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-fontspec-auto-cleanup t)
@@ -257,18 +296,13 @@ to retrieve the list of fonts."
 (TeX-add-style-hook
  "fontspec"
  (lambda ()
-   (unless (featurep 'tex-buf)
-     (require 'tex-buf))
+
    (TeX-check-engine-add-engines 'luatex 'xetex)
    (TeX-run-style-hooks "expl3" "xparse")
 
    ;; Add fontspec to the parser.
    (TeX-auto-add-regexp LaTeX-fontspec-newfontcmd-regexp)
 
-   ;; Activate the buffer local version of font features:
-   (setq LaTeX-fontspec-font-features-local
-         (copy-alist LaTeX-fontspec-font-features))
-
    (TeX-add-symbols
     ;; 4.3 Commands for old-style and lining numbers: \oldstylenums is
     ;; already provided by LaTeX, so just add \liningnums here
@@ -288,18 +322,18 @@ to retrieve the list of fonts."
     ;; 5 Font selection
     '("fontspec"
       LaTeX-fontspec-arg-font
-      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
 
     ;; Default font families
     '("setmainfont"
       (LaTeX-fontspec-arg-font "Main font name")
-      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
     '("setsansfont"
       (LaTeX-fontspec-arg-font "Sans font name")
-      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
     '("setmonofont"
       (LaTeX-fontspec-arg-font "Mono font name")
-      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
 
     ;; 5.3 Querying whether a font exists
     '("IfFontExistsTF" LaTeX-fontspec-arg-font 2)
@@ -307,11 +341,11 @@ to retrieve the list of fonts."
     ;; 6 commands to select font families
     '("newfontfamily" TeX-arg-define-macro
       LaTeX-fontspec-arg-font
-      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
 
     '("newfontface" TeX-arg-define-macro
       LaTeX-fontspec-arg-font
-      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
 
     ;; 6.4 Math(s) fonts
     '("setmathrm" "Font name" [ "Font features" ])
@@ -321,29 +355,29 @@ to retrieve the list of fonts."
 
     ;; 8 Default settings
     '("defaultfontfeatures" [ LaTeX-fontspec-arg-font ]
-      (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+      (TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"))
     '("defaultfontfeatures+" [ LaTeX-fontspec-arg-font ]
-      (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+      (TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"))
 
     ;; 10 Working with the currently selected features
     '("IfFontFeatureActiveTF"
-      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font feature"] 2)
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font feature"] 2)
 
     ;; Changing the currently selected features
     '("addfontfeatures"
-      (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+      (TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"))
 
     ;; 23 Defining new features
     '("newAATfeature"
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Existing feature")
-                    LaTeX-fontspec-font-features-local)
+                    (LaTeX-fontspec-font-features))
       "New option" 2)
 
     '("newopentypefeature"
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Existing feature")
-                    LaTeX-fontspec-font-features-local)
+                    (LaTeX-fontspec-font-features))
       "New option" t)
 
     '("newfontfeature" "New feature" t)
@@ -356,7 +390,7 @@ to retrieve the list of fonts."
     '("aliasfontfeature"
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Existing feature")
-                    LaTeX-fontspec-font-features-local)
+                    (LaTeX-fontspec-font-features))
       "New name")
 
     '("aliasfontfeatureoption"
@@ -364,10 +398,10 @@ to retrieve the list of fonts."
        (lambda ()
          (let* ((key (completing-read
                       (TeX-argument-prompt nil nil "Feature")
-                      LaTeX-fontspec-font-features-local))
+                      (LaTeX-fontspec-font-features)))
                 (val (completing-read
                       (TeX-argument-prompt nil nil "Existing name")
-                      (cadr (assoc key LaTeX-fontspec-font-features-local)))))
+                      (cadr (assoc key (LaTeX-fontspec-font-features))))))
            (TeX-argument-insert key nil)
            (format "%s" val))))
       "New name") )
diff --git a/style/fvextra.el b/style/fvextra.el
index b966f70..3109216 100644
--- a/style/fvextra.el
+++ b/style/fvextra.el
@@ -1,6 +1,6 @@
 ;;; fvextra.el --- AUCTeX style for `fvextra.sty' (v1.4)  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2017--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -45,9 +45,7 @@
 
 (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)
+(declare-function LaTeX-fancyvrb-key-val-options "fancyvrb" ())
 
 (defvar LaTeX-fvextra-key-val-options
   '(;; 3 General options
@@ -69,7 +67,7 @@
     ("linenos" ("true" "false"))
     ("mathescape" ("true" "false"))
     ("numberfirstline" ("true" "false"))
-    ;; ("numbers" ("none" "left" "right" "both"))
+    ("numbers" ("none" "left" "right" "both"))
     ("retokenize" ("true" "false"))
     ("space" ("\\textvisiblespace"))
     ("spacecolor" ("none"))
@@ -110,38 +108,6 @@
     ("breaksymbolseprightnchars"))
   "Key=value options for fvextra macros and environments.")
 
-(defun LaTeX-fvextra-update-key-val ()
-  "Update `LaTeX-fancyvrb-key-val-options-local' with key=vals from 
\"fvextra.sty\"."
-  ;; Delete the key "numbers" from `LaTeX-fancyvrb-key-val-options-local':
-  (setq LaTeX-fancyvrb-key-val-options-local
-        (assq-delete-all (car (assoc "numbers" 
LaTeX-fancyvrb-key-val-options-local))
-                         LaTeX-fancyvrb-key-val-options-local))
-  ;; Add the key with "both" value:
-  (add-to-list 'LaTeX-fancyvrb-key-val-options-local
-               '("numbers" ("none" "left" "right" "both")))
-  ;; Add color values to resp. keys:
-  (when (or (member "xcolor" (TeX-style-list))
-            (member "color" (TeX-style-list)))
-    (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
-                         #'LaTeX-xcolor-definecolor-list
-                       #'LaTeX-color-definecolor-list))
-           (keys '("highlightcolor"
-                   "rulecolor"
-                   "fillcolor"
-                   "tabcolor"
-                   "spacecolor"))
-           (tmp (copy-alist LaTeX-fancyvrb-key-val-options-local)))
-      (dolist (x keys)
-        (setq tmp (assq-delete-all (car (assoc x tmp)) tmp))
-        (if (string= x "highlightcolor")
-            (cl-pushnew (list x (mapcar #'car (funcall colorcmd))) tmp :test 
#'equal)
-          (cl-pushnew (list x (append '("none") (mapcar #'car (funcall 
colorcmd)))) tmp :test #'equal)))
-      (setq LaTeX-fancyvrb-key-val-options-local
-            (copy-alist tmp)))))
-
-(add-hook 'TeX-auto-cleanup-hook #'LaTeX-fvextra-update-key-val t)
-(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
-
 (TeX-add-style-hook
  "fvextra"
  (lambda ()
@@ -149,14 +115,9 @@
    ;; Run the style hook for "fancyvrb"
    (TeX-run-style-hooks "fancyvrb")
 
-   ;; Append `LaTeX-fvextra-key-val' to `LaTeX-fancyvrb-key-val-options-local':
-   (setq LaTeX-fancyvrb-key-val-options-local
-         (append LaTeX-fvextra-key-val-options
-                 LaTeX-fancyvrb-key-val-options-local))
-
    (TeX-add-symbols
     ;; 4.1 Inline formatting with \fvinlineset
-    '("fvinlineset" (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
+    '("fvinlineset" (TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)))
 
     ;; 4.2 Line and text formatting
     "FancyVerbFormatText"
@@ -164,9 +125,9 @@
     ;; 6 New commands and environments
     ;; 6.1 \EscVerb
     '("EscVerb"
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] "Text")
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)] "Text")
     '("EscVerb*"
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] "Text")
+      [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)] "Text")
 
     ;; 7.3.2 Breaks within macro arguments
     "FancyVerbBreakStart"
diff --git a/style/graphicx.el b/style/graphicx.el
index bacd734..0e1e220 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -62,7 +62,8 @@
     ("clip"  ("true" "false"))
     ("draft" ("true" "false"))
     ("quiet")
-    ("interpolate" ("true" "false")))
+    ("interpolate" ("true" "false"))
+    ("alt"))
   "Key=value options for graphicx macros.")
 
 (defvar LaTeX-includegraphics-dvips-extensions
diff --git a/style/hologo.el b/style/hologo.el
index 863b3d4..25f8105 100644
--- a/style/hologo.el
+++ b/style/hologo.el
@@ -1,6 +1,6 @@
 ;;; hologo.el --- AUCTeX style for `hologo.sty' (v1.10)  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2015, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -199,25 +199,15 @@
            (format "%s" keyval)))))
 
     ;; Additional user macros
-    '("hologoVariant"
+    `("hologoVariant"
       LaTeX-hologo--arg-use-region-or-query-logo-name
-      (TeX-arg-eval
-       (lambda ()
-         (let ((setup (TeX-read-key-val
-                       nil
-                       (append LaTeX-hologo-key-val-options-local
-                               LaTeX-hologo-key-val-options-global))))
-           (format "%s" setup)))))
+      (TeX-arg-key-val (append ,LaTeX-hologo-key-val-options-local
+                               ,LaTeX-hologo-key-val-options-global)))
 
-    '("HologoVariant"
+    `("HologoVariant"
       LaTeX-hologo--arg-use-region-or-query-logo-name
-      (TeX-arg-eval
-       (lambda ()
-         (let ((setup (TeX-read-key-val
-                       nil
-                       (append LaTeX-hologo-key-val-options-local
-                               LaTeX-hologo-key-val-options-global))))
-           (format "%s" setup)))))
+      (TeX-arg-key-val (append ,LaTeX-hologo-key-val-options-local
+                               ,LaTeX-hologo-key-val-options-global)))
 
     '("hologoList" 0)
 
diff --git a/style/hyperref.el b/style/hyperref.el
index 21b9d1d..81a0533 100644
--- a/style/hyperref.el
+++ b/style/hyperref.el
@@ -1,6 +1,6 @@
 ;;; hyperref.el --- AUCTeX style for `hyperref.sty' v6.83m  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2008, 2013-2020 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2013-2021 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
@@ -176,7 +176,7 @@
     ("borderwidth")
     ;; "borderstyle" is not mentioned in the original hyperref-doc, it
     ;; can be seen in action in
-    ;; http://mirrors.ctan.org/macros/latex/contrib/hyperref/test/testform.tex
+    ;; https://github.com/latex3/hyperref/blob/main/test/testform.tex
     ;; S=Solid (default), D=Dashed, B=Beveled, I=Inset, U=Underline
     ("borderstyle"    ("S" "D" "B" "I" "U"))
     ("calculate")
@@ -259,7 +259,7 @@
     '("Acrobatmenu" "Menu option" "Text")
     ;; The next 6 macros take Key-vals defined in
     ;; "LaTeX-hyperref-forms-options".  For an example, see
-    ;; http://mirrors.ctan.org/macros/latex/contrib/hyperref/test/testform.tex
+    ;; https://github.com/latex3/hyperref/blob/main/test/testform.tex
     '("TextField"  [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label")
     '("CheckBox"   [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label")
     '("ChoiceMenu" [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label" 
"Choices")
@@ -325,6 +325,17 @@
             (not (eq TeX-engine 'xetex)))
        (setq TeX-PDF-from-DVI "Dvipdfmx"))
 
+   ;; Loop over the possible options and load backref.el:
+   (let ((opts '("backref"
+                 "backref=section"
+                 "backref=slide"
+                 "backref=page"
+                 "pagebackref"
+                 "pagebackref=true")))
+     (dolist (opt opts)
+       (when (LaTeX-provided-package-options-member "hyperref" opt)
+         (TeX-run-style-hooks "backref"))))
+
    ;; Activate RefTeX reference style.
    (and LaTeX-reftex-ref-style-auto-activate
         (fboundp 'reftex-ref-style-activate)
diff --git a/style/kpfonts.el b/style/kpfonts.el
index 8dec44c..d55142f 100644
--- a/style/kpfonts.el
+++ b/style/kpfonts.el
@@ -377,17 +377,19 @@ Each entry should be a list with upto four elements, KEY, 
VALUE,
 MENU and CHARACTER.
 
 KEY is the key (after `LaTeX-kpfonts-abbrev-prefix') to be
-redefined in kpfonts minor mode.  If KEY is nil, the symbol has
-no associated keystroke \(it is available in the menu, though\).
+redefined in kpfonts minor mode.  KEY can be a character (for
+example ?o) for a single stroke or a string (for example \"o a\")
+for a multi-stroke binding.  If KEY is nil, the symbol has no
+associated keystroke (it is available in the menu, though).
 
 VALUE can be a string with the name of the macro to be inserted,
 or a function to be called.  The macro must be given without the
 leading backslash.
 
 The third element MENU is the name of the submenu where the
-command should be added.  MENU can be either a string
-\(e.g. \"greek\"\), a list (e.g. \(\"AMS\" \"Delimiters\"\)\) or
-nil.  If MENU is nil, no menu item will be created.
+command should be added.  MENU can be either a string (for
+example \"greek\"), a list (for example (\"AMS\" \"Delimiters\"))
+or nil.  If MENU is nil, no menu item will be created.
 
 The fourth element CHARACTER is a Unicode character position for
 menu display.  When nil, no character is shown.
diff --git a/style/listings.el b/style/listings.el
index 50f0907..cfd4968 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -1,6 +1,6 @@
 ;;; listings.el --- AUCTeX style for `listings.sty'  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2004, 2005, 2009, 2013-2020 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2009, 2013-2021 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -58,6 +58,9 @@
 (declare-function font-latex-set-syntactic-keywords
                   "font-latex")
 
+(declare-function LaTeX-color-definecolor-list "color" ())
+(declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
+
 ;; The following are options taken from chapter 4 of the listings
 ;; manual (2007/02/22 Version 1.4).
 (defvar LaTeX-listings-key-val-options
@@ -162,7 +165,7 @@
     ("backgroundcolor")
     ("rulecolor")
     ("fillcolor")
-    ("fulesepcolor")
+    ("rulesepcolor")
     ("frameshape")
     ;; Indexing
     ("index")
@@ -246,22 +249,45 @@
     ("multicolumn"))
   "Key=value options for listings macros and environments.")
 
-(defvar LaTeX-listings-key-val-options-local nil
-  "Buffer-local Key=value options for listings macros and environments.")
-(make-variable-buffer-local 'LaTeX-listings-key-val-options-local)
+(defun LaTeX-listings-key-val-options ()
+  "Return an updated list of key=vals from listings package."
+  (append
+   ;; Check for x?color package.  Note that listings requires a \color
+   ;; command, e.g., 'rulecolor=\color{blue}':
+   (when (and (or (member "xcolor" (TeX-style-list))
+                  (member "color" TeX-active-styles)))
+     (let* ((colorcmd (if (member "xcolor" TeX-active-styles)
+                          #'LaTeX-xcolor-definecolor-list
+                        #'LaTeX-color-definecolor-list))
+            (colors (mapcar (lambda (x)
+                              (concat TeX-esc "color" TeX-grop x TeX-grcl))
+                            (mapcar #'car (funcall colorcmd))))
+            (keys '("backgroundcolor"
+                    "fillcolor"
+                    "rulecolor"
+                    "rulesepcolor"))
+            result)
+       (dolist (key keys result)
+         (push (list key colors) result))))
+   ;; Cater for user defined styles:
+   (when (LaTeX-listings-lstdefinestyle-list)
+     `(("style" ,(mapcar #'car (LaTeX-listings-lstdefinestyle-list)))))
+   ;; Standard key=vals:
+   LaTeX-listings-key-val-options))
 
 ;; Setup for \lstnewenvironment:
 (defvar LaTeX-auto-listings-lstnewenvironment nil
-  "Temporary for parsing the arguments of `\\lstnewenvironment'
-from `listings' package.")
+  "Temporary for parsing the arguments of '\\lstnewenvironment'.")
 
 (defvar LaTeX-listings-lstnewenvironment-regexp
   `(,(concat "\\\\lstnewenvironment"
-             "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}%?"
-             "[ \t\n\r]*\\[?\\([0-9]?\\)\\]?%?"
+             "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}"
+             "%?"
+             "[ \t\n\r]*\\(?:\\[\\([0-9]\\)\\]\\)?"
+             "%?"
              "[ \t\n\r]*\\(\\[\\)?")
     (1 2 3) LaTeX-auto-listings-lstnewenvironment)
-  "Matches the argument of `\\lstnewenvironment' from `listings.sty'.")
+  "Matches the argument of '\\lstnewenvironment'.")
 
 ;; Setup for \lstdefinestyle:
 (TeX-auto-add-type "listings-lstdefinestyle" "LaTeX")
@@ -269,8 +295,7 @@ from `listings' package.")
 (defvar LaTeX-listings-lstdefinestyle-regexp
   '("\\\\lstdefinestyle{\\([^}]+\\)}"
     1 LaTeX-auto-listings-lstdefinestyle)
-  "Matches the argument of \"\\lstdefinestyle\" from
-\"listings\" package.")
+  "Matches the argument of '\\lstdefinestyle' from 'listings' package.")
 
 ;; Setup for parsing the labels inside optional arguments:
 
@@ -280,27 +305,13 @@ from `listings' package.")
     1 LaTeX-auto-label)
   "Matches the label inside an optional argument after \\begin{lstlisting}.")
 
-(defun LaTeX-listings-update-style-key ()
-  "Update the \"style\" key from `LaTeX-listings-key-val-options-local'
-with user-defined values via the \"lstdefinestyle\" macro."
-  (let* ((elt (assoc "style" LaTeX-listings-key-val-options-local))
-         (key (car elt))
-         (temp (copy-alist LaTeX-listings-key-val-options-local))
-         (opts (assq-delete-all (car (assoc key temp)) temp)))
-    (cl-pushnew (list key (TeX-delete-duplicate-strings
-                           (mapcar #'car 
(LaTeX-listings-lstdefinestyle-list))))
-                opts :test #'equal)
-    (setq LaTeX-listings-key-val-options-local
-          (copy-alist opts))))
-
 (defun LaTeX-listings-auto-prepare ()
-  "Clear temporary variable from `listings.sty' before parsing."
+  "Clear temporary variable from 'listings' package before parsing."
   (setq LaTeX-auto-listings-lstnewenvironment nil)
   (setq LaTeX-auto-listings-lstdefinestyle    nil))
 
 (defun LaTeX-listings-auto-cleanup ()
-  "Process the parsed results of \"\\lstnewenvironment\" and
-\"\\lstdefinestyle\"."
+  "Process the parsed results of 'listings' package."
   (dolist (env-args LaTeX-auto-listings-lstnewenvironment)
     (let ((env  (car   env-args))
           (args (cadr  env-args))
@@ -311,7 +322,7 @@ with user-defined values via the \"lstdefinestyle\" macro."
              (LaTeX-add-environments
               `(,env
                 LaTeX-env-args
-                [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+                [TeX-arg-key-val (LaTeX-listings-key-val-options)]
                 (LaTeX-env-label-as-keyval "caption")
                 ,(1- (string-to-number args)))))
             (;; mandatory argument(s) only
@@ -340,9 +351,7 @@ with user-defined values via the \"lstdefinestyle\" macro."
         ;; Tell font-lock about the update.
         (font-latex-set-syntactic-keywords))
       ;; Add new env's to `ispell-tex-skip-alist': skip the entire env
-      (TeX-ispell-skip-setcdr `(,(cons env (concat "\\\\end{" env "}"))))))
-  (when (LaTeX-listings-lstdefinestyle-list)
-    (LaTeX-listings-update-style-key)))
+      (TeX-ispell-skip-setcdr `(,(cons env (concat "\\\\end{" env "}")))))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-listings-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-listings-auto-cleanup t)
@@ -390,10 +399,6 @@ caption key is found, an error is issued."
    (TeX-auto-add-regexp LaTeX-listings-lstdefinestyle-regexp)
    (TeX-auto-add-regexp LaTeX-listings-key-val-label-regexp)
 
-   ;; Local version of key-val options:
-   (setq LaTeX-listings-key-val-options-local
-         (copy-alist LaTeX-listings-key-val-options))
-
    ;; New symbols
    (TeX-add-symbols
     '("lstalias" ["Alias dialect"] "Alias" ["Dialect"] "Language")
@@ -402,17 +407,16 @@ caption key is found, an error is issued."
        (lambda ()
          (let ((name (TeX-read-string "Style name: ")))
            (LaTeX-add-listings-lstdefinestyles name)
-           (LaTeX-listings-update-style-key)
            (format "%s" name))))
-      (TeX-arg-key-val LaTeX-listings-key-val-options-local))
-    '("lstinline" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+      (TeX-arg-key-val (LaTeX-listings-key-val-options)))
+    '("lstinline" [TeX-arg-key-val (LaTeX-listings-key-val-options)]
       TeX-arg-verb-delim-or-brace)
-    '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+    '("lstinputlisting" [TeX-arg-key-val (LaTeX-listings-key-val-options)]
       TeX-arg-file)
     "lstlistoflistings"
     '("lstnewenvironment" "Name" ["Number or arguments"] ["Default argument"]
       "Starting code" "Ending code")
-    '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options-local))
+    '("lstset" (TeX-arg-key-val (LaTeX-listings-key-val-options)))
     '("lstloadlanguages" t)
     ;; 4.17 Short Inline Listing Commands
     '("lstMakeShortInline" [ "Options" ] "Character")
@@ -425,7 +429,7 @@ caption key is found, an error is issued."
    ;; New environments
    (LaTeX-add-environments
     '("lstlisting" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-listings-key-val-options)]
       (LaTeX-env-label-as-keyval "caption")))
 
    ;; Append "lstlisting" to `LaTeX-label-alist':
diff --git a/style/mdframed.el b/style/mdframed.el
index edf2892..0e3dd9b 100644
--- a/style/mdframed.el
+++ b/style/mdframed.el
@@ -1,6 +1,6 @@
 ;;; mdframed.el --- AUCTeX style for `mdframed.sty' (v1.9b)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2016--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -161,10 +161,6 @@
     ("theoremspace"))
   "Key=value options for mdframed macros and environments.")
 
-(defvar LaTeX-mdframed-key-val-options-local nil
-  "Buffer-local key=value options for mdframed macros and environments.")
-(make-variable-buffer-local 'LaTeX-mdframed-key-val-options-local)
-
 ;; Setup for \newmdenv
 
 (TeX-auto-add-type "mdframed-newmdenv" "LaTeX")
@@ -173,13 +169,9 @@
   `(,(concat
       "\\\\newmdenv"
       "[ \t\n\r%]*"
-      "\\(?:\\[[^][]*"
-        "\\(?:{[^}{]*"
-          "\\(?:{[^}{]*"
-            "\\(?:{[^}{]*}[^}{]*\\)*"
-          "}[^}{]*\\)*"
-        "}[^][]*\\)*"
-      "\\]\\)?"
+      "\\(?:"
+      (LaTeX-extract-key-value-label 'none)
+      "\\)?"
       "[ \t\n\r%]*"
       "{\\([^}]+\\)}")
     1 LaTeX-auto-mdframed-newmdenv)
@@ -202,57 +194,50 @@
   `(,(concat
       "\\\\\\(new\\)?mdtheorem\\(?:env\\)?"
       "[ \t\n\r%]*"
-      "\\(?:\\[[^][]*"
-        "\\(?:{[^}{]*"
-          "\\(?:{[^}{]*"
-            "\\(?:{[^}{]*}[^}{]*\\)*"
-          "}[^}{]*\\)*"
-        "}[^][]*\\)*"
-      "\\]\\)?"
+      "\\(?:"
+      (LaTeX-extract-key-value-label 'none)
+      "\\)?"
       "[ \t\n\r%]*"
       "{\\([^}]+\\)}")
     (2 1) LaTeX-auto-mdframed-mdtheorem)
   "Matches the argument of \\newmdtheoremenv and \\mdtheorem from mdframed 
package.")
 
-(defun LaTeX-mdframed-update-style-key ()
-  "Update some key=values in `LaTeX-mdframed-key-val-options-local'."
-  ;; Add new "style"s to key=vals:
-  (when (LaTeX-mdframed-mdfdefinestyle-list)
-    (let* ((key (car (assoc "style" LaTeX-mdframed-key-val-options-local)))
-           (val (cadr (assoc "style" LaTeX-mdframed-key-val-options)))
-           (temp (copy-alist LaTeX-mdframed-key-val-options-local))
-           (opts (assq-delete-all (car (assoc key temp)) temp)))
-      (cl-pushnew (list key (TeX-delete-duplicate-strings
-                             (append val (mapcar #'car 
(LaTeX-mdframed-mdfdefinestyle-list)))))
-                  opts :test #'equal)
-      (setq LaTeX-mdframed-key-val-options-local
-            (copy-alist opts))))
-  ;;
-  ;; Check if any color defininig package is loaded and update the
-  ;; key=values for coloring.  Prefer xcolor.sty if both packages are
-  ;; loaded.
-  (when (or (member "xcolor" (TeX-style-list))
-            (member "color" (TeX-style-list)))
-    (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
-                         #'LaTeX-xcolor-definecolor-list
-                       #'LaTeX-color-definecolor-list))
-           (keys '("linecolor"
-                   "innerlinecolor"
-                   "middlelinecolor"
-                   "outerlinecolor"
-                   "backgroundcolor"
-                   "fontcolor"
-                   "shadowcolor"
-                   "frametitlebackgroundcolor"
-                   "subtitlebackgroundcolor"
-                   "subtitleabovelinecolor"
-                   "subtitlebelowlinecolor"))
-           (tmp (copy-alist LaTeX-mdframed-key-val-options-local)))
-      (dolist (x keys)
-        (setq tmp (assq-delete-all (car (assoc x tmp)) tmp))
-        (cl-pushnew (list x (mapcar #'car (funcall colorcmd))) tmp :test 
#'equal))
-      (setq LaTeX-mdframed-key-val-options-local
-            (copy-alist tmp)))))
+(defun LaTeX-mdframed-key-val-options ()
+  "Return an updated list of key=vals from mdframed package.
+This function retrieves values of user defined styles and colors
+and prepends them to variable `LaTeX-mdframed-key-val-options'."
+  (append
+   (when (LaTeX-mdframed-mdfdefinestyle-list)
+     (let ((val (copy-sequence
+                 (cadr (assoc "style" LaTeX-mdframed-key-val-options)))))
+       `(("style" ,(append
+                    (mapcar #'car (LaTeX-mdframed-mdfdefinestyle-list))
+                    val)))))
+   ;; Check if any color defininig package is loaded and update the
+   ;; key=values for coloring.  Prefer xcolor.sty if both packages are
+   ;; loaded.  Run `TeX-style-list' only once and use
+   ;; `TeX-active-styles' afterwards:
+   (when (or (member "xcolor" (TeX-style-list))
+             (member "color" TeX-active-styles))
+     (let* ((colorcmd (if (member "xcolor" TeX-active-styles)
+                          #'LaTeX-xcolor-definecolor-list
+                        #'LaTeX-color-definecolor-list))
+            (colors (mapcar #'car (funcall colorcmd)))
+            (keys '("linecolor"
+                    "innerlinecolor"
+                    "middlelinecolor"
+                    "outerlinecolor"
+                    "backgroundcolor"
+                    "fontcolor"
+                    "shadowcolor"
+                    "frametitlebackgroundcolor"
+                    "subtitlebackgroundcolor"
+                    "subtitleabovelinecolor"
+                    "subtitlebelowlinecolor"))
+            result)
+       (dolist (key keys result)
+         (cl-pushnew (list key colors) result :test #'equal))))
+   LaTeX-mdframed-key-val-options))
 
 (defun LaTeX-mdframed-auto-prepare ()
   "Clear variables before parsing for mdframed package."
@@ -264,15 +249,14 @@
   "Process parsed elements for mdframed package."
   (dolist (env (mapcar #'car (LaTeX-mdframed-newmdenv-list)))
     (LaTeX-add-environments
-     `(,env LaTeX-env-args [ TeX-arg-key-val 
LaTeX-mdframed-key-val-options-local ] ))
+     `(,env LaTeX-env-args [TeX-arg-key-val (LaTeX-mdframed-key-val-options)] 
))
     (TeX-ispell-skip-setcdr `((,env ispell-tex-arg-end 0))))
   (dolist (newenv (LaTeX-mdframed-mdtheorem-list))
     (let ((env (car newenv))
           (new (cadr newenv)))
       (LaTeX-add-environments (list env (vector "Heading")))
       (unless (and new (not (string= new "")))
-        (LaTeX-add-environments (list (concat env "*") (vector "Heading"))))))
-  (LaTeX-mdframed-update-style-key))
+        (LaTeX-add-environments (list (concat env "*") (vector "Heading")))))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-mdframed-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-mdframed-auto-cleanup t)
@@ -287,35 +271,31 @@
    (TeX-auto-add-regexp LaTeX-mdframed-mdfdefinestyle-regexp)
    (TeX-auto-add-regexp LaTeX-mdframed-mdtheorem-regexp)
 
-   ;; Local version of key-val options
-   (setq LaTeX-mdframed-key-val-options-local
-         (copy-alist LaTeX-mdframed-key-val-options))
-
    ;; 4. Commands
    (TeX-add-symbols
     '("mdfsetup"
-      (TeX-arg-key-val LaTeX-mdframed-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-mdframed-key-val-options)))
 
     '("newmdenv"
-      [ TeX-arg-key-val LaTeX-mdframed-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
       (TeX-arg-eval
        (lambda ()
          (let ((env (TeX-read-string
                      (TeX-argument-prompt nil nil "Environment"))))
            (LaTeX-add-environments
-            `(,env LaTeX-env-args [ TeX-arg-key-val 
LaTeX-mdframed-key-val-options-local ]))
+            `(,env LaTeX-env-args [TeX-arg-key-val 
(LaTeX-mdframed-key-val-options)]))
            ;; Add new env's to `ispell-tex-skip-alist': skip the optional 
argument
            (TeX-ispell-skip-setcdr `((,env ispell-tex-arg-end 0)))
            (format "%s" env)))))
 
     '("renewmdenv"
-      [ TeX-arg-key-val LaTeX-mdframed-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Environment")
                     (LaTeX-mdframed-newmdenv-list)))
 
     '("surroundwithmdframed"
-      [ TeX-arg-key-val LaTeX-mdframed-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
       TeX-arg-environment)
 
     '("mdflength"
@@ -341,24 +321,23 @@
          (let ((style (TeX-read-string
                        (TeX-argument-prompt nil nil "Style name"))))
            (LaTeX-add-mdframed-mdfdefinestyles style)
-           (LaTeX-mdframed-update-style-key)
            (format "%s" style))))
-      (TeX-arg-key-val LaTeX-mdframed-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-mdframed-key-val-options)))
 
     '("mdfapptodefinestyle"
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Style name")
                     (LaTeX-mdframed-mdfdefinestyle-list))
-      (TeX-arg-key-val LaTeX-mdframed-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-mdframed-key-val-options)))
 
     ;; 6.11. Title commands inside the environment
     '("mdfsubtitle"
-      [ TeX-arg-key-val LaTeX-mdframed-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
       "Subtitle")
 
     ;; 8. Theorems
     '("newmdtheoremenv"
-      [ TeX-arg-key-val LaTeX-mdframed-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
       (TeX-arg-eval
        (lambda ()
          (let ((nthm (TeX-read-string
@@ -368,13 +347,14 @@
       [ TeX-arg-environment "Numbered like" ]
       t [ (TeX-arg-eval progn (if (eq (save-excursion
                                         (backward-char 2)
-                                        (preceding-char)) ?\])
+                                        (preceding-char))
+                                      ?\])
                                   ()
                                 (TeX-arg-counter t "Within counter"))
                         "") ])
 
     '("mdtheorem"
-      [ TeX-arg-key-val LaTeX-mdframed-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
       (TeX-arg-eval
        (lambda ()
          (let ((nthm (TeX-read-string
@@ -385,7 +365,8 @@
       [ TeX-arg-environment "Numbered like" ]
       t [ (TeX-arg-eval progn (if (eq (save-excursion
                                         (backward-char 2)
-                                        (preceding-char)) ?\])
+                                        (preceding-char))
+                                      ?\])
                                   ()
                                 (TeX-arg-counter t "Within counter"))
                         "") ]))
@@ -393,7 +374,7 @@
    ;; Main environment defined by mdframed.sty
    (LaTeX-add-environments
     '("mdframed" LaTeX-env-args
-      [ TeX-arg-key-val LaTeX-mdframed-key-val-options-local ] ))
+      [TeX-arg-key-val (LaTeX-mdframed-key-val-options)] ))
 
    ;; Fontification
    (when (and (featurep 'font-latex)
diff --git a/style/midfloat.el b/style/midfloat.el
new file mode 100644
index 0000000..66d794c
--- /dev/null
+++ b/style/midfloat.el
@@ -0,0 +1,51 @@
+;;; midfloat.el --- AUCTeX style for `midfloat.sty' (v1.1)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `midfloat.sty' (v1.1) from 2012/05/29.
+;; `midfloat.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+
+(TeX-add-style-hook
+ "midfloat"
+ (lambda ()
+
+   ;; Add the only environment provided by the package:
+   (LaTeX-add-environments
+    '("strip" ["Top/Bottom skip"]))
+
+   ;; This is a glue, in LaTeX set with \setlength:
+   (LaTeX-add-lengths "stripsep"))
+ TeX-dialect)
+
+(defvar LaTeX-midfloat-package-options nil
+  "Package options for the midfloat package.")
+
+;;; midfloat.el ends here
diff --git a/style/minted.el b/style/minted.el
index 41f63e6..93e8052 100644
--- a/style/minted.el
+++ b/style/minted.el
@@ -155,9 +155,23 @@
     ("xrightmargin"))
   "Key=value options for minted macros and environments.")
 
-(defvar LaTeX-minted-key-val-options-local nil
-  "Buffer-local key=value options for minted macros and environments.")
-(make-variable-buffer-local 'LaTeX-minted-key-val-options-local)
+(defun LaTeX-minted-key-val-options ()
+  "Return an updated list of key=vals from minted package.
+This function retrieves values of (user) defined colors and
+prepends them to variable `LaTeX-minted-key-val-options'."
+  (append
+   (when (or (member "xcolor" (TeX-style-list))
+             (member "color" TeX-active-styles))
+     (let* ((colorcmd (if (member "xcolor" TeX-active-styles)
+                          #'LaTeX-xcolor-definecolor-list
+                        #'LaTeX-color-definecolor-list))
+            (colors (mapcar #'car (funcall colorcmd)))
+            (keys '("bgcolor" "highlightcolor"
+                    "rulecolor" "spacecolor" "tabcolor"))
+            result)
+       (dolist (key keys result)
+         (push (list key colors) result))))
+   LaTeX-minted-key-val-options))
 
 (defvar LaTeX-minted-pygmentize-program (executable-find "pygmentize"))
 
@@ -217,27 +231,6 @@ brackets.  PROMPT replaces the standard one."
                     (LaTeX-minted-style-list))
    optional))
 
-(defun LaTeX-minted-update-key-vals ()
-  "Update color related key-vals in `LaTeX-minted-key-val-options-local'.
-This function checks if one of the packages \"xcolor.sty\" or
-\"xcolor.sty\" is loaded and appends defined colors as values to
-color related key.  \"xcolor.sty\" is preferred if both packages
-are loaded."
-  (when (or (member "xcolor" (TeX-style-list))
-            (member "color" (TeX-style-list)))
-    (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
-                         #'LaTeX-xcolor-definecolor-list
-                       #'LaTeX-color-definecolor-list))
-           (colorkeys '("bgcolor" "highlightcolor"
-                        "rulecolor" "spacecolor" "tabcolor"))
-           (opts (copy-alist LaTeX-minted-key-val-options-local)))
-      (dolist (key colorkeys)
-        (setq opts (assq-delete-all (car (assoc key opts)) opts))
-        (push (list key (mapcar #'car (funcall colorcmd)))
-              opts))
-      (setq LaTeX-minted-key-val-options-local
-            (copy-alist opts)))))
-
 (defvar LaTeX-minted-auto-newminted nil)
 (defvar LaTeX-minted-newminted-regexp
   '("\\\\newminted\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
@@ -277,7 +270,7 @@ are loaded."
       (add-to-list 'LaTeX-auto-environment (list env))
       (add-to-list 'LaTeX-auto-environment
                    (list env* #'LaTeX-env-args
-                         '(TeX-arg-key-val 
LaTeX-minted-key-val-options-local)))
+                         '(TeX-arg-key-val (LaTeX-minted-key-val-options))))
       (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation) 
t)
       (add-to-list 'LaTeX-indent-environment-list `(,env* current-indentation) 
t)
       (add-to-list 'LaTeX-verbatim-environments-local env)
@@ -289,7 +282,7 @@ are loaded."
                     (car name-lang)
                   (cadr name-lang))))
       (add-to-list 'TeX-auto-symbol
-                   `(,lang [ TeX-arg-key-val 
LaTeX-minted-key-val-options-local ]
+                   `(,lang [TeX-arg-key-val (LaTeX-minted-key-val-options)]
                            TeX-arg-verb))
       (add-to-list 'LaTeX-verbatim-macros-with-delims-local lang)
       (when (and (fboundp 'font-latex-add-keywords)
@@ -304,7 +297,7 @@ are loaded."
                     (car name-lang)
                   (concat (cadr name-lang) "inline"))))
       (add-to-list 'TeX-auto-symbol
-                   `(,lang [ TeX-arg-key-val 
LaTeX-minted-key-val-options-local ]
+                   `(,lang [TeX-arg-key-val (LaTeX-minted-key-val-options)]
                            TeX-arg-verb-delim-or-brace))
       (add-to-list 'LaTeX-verbatim-macros-with-delims-local lang)
       (add-to-list 'LaTeX-verbatim-macros-with-braces-local lang)
@@ -318,14 +311,12 @@ are loaded."
                     (car name-lang)
                   (concat (cadr name-lang) "file"))))
       (add-to-list 'TeX-auto-symbol
-                   `(,lang [ TeX-arg-key-val 
LaTeX-minted-key-val-options-local ]
+                   `(,lang [TeX-arg-key-val (LaTeX-minted-key-val-options)]
                            TeX-arg-file))))
   (when (and (fboundp 'font-latex-set-syntactic-keywords)
              (eq TeX-install-font-lock 'font-latex-setup))
     ;; Refresh font-locking so that the verbatim envs take effect.
-    (font-latex-set-syntactic-keywords))
-  ;; Also update the key=vals
-  (LaTeX-minted-update-key-vals))
+    (font-latex-set-syntactic-keywords)))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-minted-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-minted-auto-cleanup t)
@@ -375,29 +366,25 @@ a list of strings."
  "minted"
  (lambda ()
 
-   ;; Activate local-version of key=vals
-   (setq LaTeX-minted-key-val-options-local
-         (copy-alist LaTeX-minted-key-val-options))
-
    ;; New symbols
    (TeX-add-symbols
     '("mint"
-      [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-minted-key-val-options)]
       LaTeX-arg-minted-language TeX-arg-verb)
     '("mintinline"
-      [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-minted-key-val-options)]
       LaTeX-arg-minted-language TeX-arg-verb-delim-or-brace)
     '("newminted" ["Environment Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-minted-key-val-options)))
     '("newmint" ["Macro Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-minted-key-val-options)))
     '("newmintinline" ["Macro Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-minted-key-val-options)))
     '("newmintedfile" ["Macro Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-minted-key-val-options)))
     ;; 3.3 Formatting source code
     '("inputminted"
-      [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
+      [TeX-arg-key-val (LaTeX-minted-key-val-options)]
       (LaTeX-arg-minted-language)
       TeX-arg-file)
     ;; 3.4 Using different styles
@@ -406,14 +393,14 @@ a list of strings."
     ;; 5.2 Macro option usage
     '("setminted"
       [ LaTeX-arg-minted-language ]
-      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-minted-key-val-options)))
     '("setmintedinline"
       [ LaTeX-arg-minted-language ]
-      (TeX-arg-key-val LaTeX-minted-key-val-options-local)))
+      (TeX-arg-key-val (LaTeX-minted-key-val-options))))
 
    ;; New environments
    (LaTeX-add-environments
-    '("minted" LaTeX-env-args [TeX-arg-key-val 
LaTeX-minted-key-val-options-local]
+    '("minted" LaTeX-env-args [TeX-arg-key-val (LaTeX-minted-key-val-options)]
       LaTeX-arg-minted-language))
 
    ;; 4 Floating listings: If option "newfloat" is given, run the
diff --git a/style/multicol.el b/style/multicol.el
index d9f7284..6fc65b9 100644
--- a/style/multicol.el
+++ b/style/multicol.el
@@ -26,13 +26,18 @@
 
 ;;; Commentary:
 
-;; This file adds support for `multicol.sty'.
+;; This file adds support for `multicol.sty' v1.9b from 2021/10/28.
 
 ;;; Code:
 
 (require 'tex)
 (require 'latex)
 
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
 (TeX-add-style-hook
  "multicol"
  (lambda ()
@@ -48,18 +53,40 @@
     "columnseprulecolor"
     '("raggedcolumns" 0)
     '("flushcolumns"  0)
-    '("columnbreak"   0))
+    ;; 2.3 Manually breaking columns
+    '("newcolumn"     0)
+    '("columnbreak"   [ "How much [0 - 4]" ])
+
+    ;; Preface to version 1.7
+    "RLmulticolcolumns"
+    "LRmulticolcolumns")
+
+   ;; Preface to version 1.8
+   (when (LaTeX-provided-package-options-member "multicol" "colaction")
+     (TeX-add-symbols '("docolaction" 3)))
 
    (LaTeX-add-lengths "premulticols"
                       "postmulticols"
                       "multicolsep"
                       "multicolbaselineskip"
                       "multicolovershoot"
-                      "multicolundershoot"))
+                      "multicolundershoot")
+
+   (LaTeX-add-counters "collectmore")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("columnbreak"       "")
+                                ("newcolumn"         "")
+                                ("LRmulticolcolumns" "")
+                                ("RLmulticolcolumns" ""))
+                              'warning)))
  TeX-dialect)
 
 (defvar LaTeX-multicol-package-options
-  '("errorshow" "infoshow" "balancingshow" "markshow" "debugshow" "grid")
+  '("errorshow" "infoshow" "balancingshow" "markshow" "debugshow"
+    "grid" "colaction")
   "Package options for the multicol package.")
 
 ;;; multicol.el ends here
diff --git a/style/newfloat.el b/style/newfloat.el
index 3eb865c..74185bd 100644
--- a/style/newfloat.el
+++ b/style/newfloat.el
@@ -1,6 +1,6 @@
 ;;; newfloat.el --- AUCTeX style for `newfloat.sty' (v1.1-109)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -71,9 +71,13 @@
     ("chapterlistsgaps" ("on" "off")))
   "Key=value options for newfloat macros.")
 
-(defvar LaTeX-newfloat-key-val-options-local nil
-  "Buffer-local Key=value options for newfloat macros.")
-(make-variable-buffer-local 'LaTeX-newfloat-key-val-options-local)
+(defun LaTeX-newfloat-key-val-options ()
+  "Return newfloat key=vals based on variable `LaTeX-largest-level'."
+  (append
+   (if (< (LaTeX-largest-level) 2)
+       '(("within" ("chapter" "section" "none")))
+     '(("within" ("section" "none"))))
+   LaTeX-newfloat-key-val-options))
 
 ;; Setup parsing for \DeclareFloatingEnvironment:
 (TeX-auto-add-type "newfloat-DeclareFloatingEnvironment" "LaTeX")
@@ -88,8 +92,7 @@
              "{\\([^}]+\\)}"
              "\\(?:[ %]*{\\([^}]*\\)}\\)?")
     (1 2) LaTeX-auto-newfloat-DeclareFloatingEnvironment)
-  "Matches the argument of `\\DeclareFloatingEnvironment' from
-`newfloat.sty'.")
+  "Matches the argument of `\\DeclareFloatingEnvironment' from 
`newfloat.sty'.")
 
 (defun LaTeX-newfloat-auto-prepare ()
   "Clear `LaTeX-auto-newfloat-DeclareFloatingEnvironment' before parsing."
@@ -151,21 +154,10 @@ If `caption.el' is loaded, add the new floating 
environment to
    ;; Add newfloat to the parser.
    (TeX-auto-add-regexp LaTeX-newfloat-DeclareFloatingEnvironment-regex)
 
-   ;; Depending on class, add "within" key to the local options list
-   ;; and use it.
-   (setq LaTeX-newfloat-key-val-options-local
-         (copy-alist LaTeX-newfloat-key-val-options))
-
-   (if (< (LaTeX-largest-level) 2)
-       (add-to-list 'LaTeX-newfloat-key-val-options-local
-                    '("within" ("chapter" "section" "none")))
-     (add-to-list 'LaTeX-newfloat-key-val-options-local
-                  '("within" ("section" "none"))))
-
    ;; Commands:
    (TeX-add-symbols
     '("DeclareFloatingEnvironment"
-      [TeX-arg-key-val LaTeX-newfloat-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-newfloat-key-val-options)]
       (TeX-arg-eval
        (lambda ()
          (let ((newfloat (TeX-read-string
@@ -177,7 +169,7 @@ If `caption.el' is loaded, add the new floating environment 
to
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Floating environment")
                     (mapcar #'car 
(LaTeX-newfloat-DeclareFloatingEnvironment-list)))
-      (TeX-arg-key-val LaTeX-newfloat-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-newfloat-key-val-options-local)))
 
     '("ForEachFloatingEnvironment" t)
     '("ForEachFloatingEnvironment*" t)
diff --git a/style/ntheorem.el b/style/ntheorem.el
index 35c4e45..cd8eff4 100644
--- a/style/ntheorem.el
+++ b/style/ntheorem.el
@@ -103,7 +103,7 @@ for label.  AUCTeX users should add ENVIRONMENT to
   (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
 
 RefTeX users should customize or add ENVIRONMENT to
-`LaTeX-label-alist' and `reftex-label-alist', e.g.
+`LaTeX-label-alist' and `reftex-label-alist', for example
 
   (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
   (add-to-list \\='reftex-label-alist
diff --git a/style/polyglossia.el b/style/polyglossia.el
index f17eeab..4bfb93e 100644
--- a/style/polyglossia.el
+++ b/style/polyglossia.el
@@ -238,8 +238,6 @@ argument, otherwise as a mandatory one."
 (TeX-add-style-hook
  "polyglossia"
  (lambda ()
-   (unless (featurep 'tex-buf)
-     (require 'tex-buf))
    (TeX-check-engine-add-engines 'luatex 'xetex)
    (TeX-auto-add-regexp
     `(,LaTeX-polyglossia-lang-regexp (3 1 2) LaTeX-auto-polyglossia-lang))
diff --git a/style/pythontex.el b/style/pythontex.el
index 08c0033..01c6ed9 100644
--- a/style/pythontex.el
+++ b/style/pythontex.el
@@ -1,6 +1,6 @@
 ;;; pythontex.el --- AUCTeX style for `pythontex.sty' (v0.16)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2018--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -35,9 +35,10 @@
 (require 'latex)
 
 ;; Silence the compiler:
-;; `LaTeX-fancyvrb-key-val-options-local' will be defined after
+
+;; The function `LaTeX-fancyvrb-key-val-options' will be defined after
 ;; loading `fvextra.el' which loads `fancyvrb.el' in return:
-(defvar LaTeX-fancyvrb-key-val-options-local)
+(declare-function LaTeX-fancyvrb-key-val-options "fancyvrb" ())
 
 ;; These are provided by `font-latex.el':
 (defvar font-latex-syntactic-keywords-extra)
@@ -116,7 +117,7 @@ Update the variable `LaTeX-pythontex-language-list' if 
still nil."
   "Insert ENVIRONMENT provided by pythontex package."
   (let ((session (TeX-read-string
                   (TeX-argument-prompt t nil "Session")))
-        (fvkeyval (TeX-read-key-val t LaTeX-fancyvrb-key-val-options-local)))
+        (fvkeyval (TeX-read-key-val t (LaTeX-fancyvrb-key-val-options))))
     (LaTeX-insert-environment environment
                               (concat
                                (when (and session (not (string= session "")))
@@ -307,7 +308,7 @@ a list of strings."
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Family")
         LaTeX-pythontex-family-list ]
-      (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
+      (TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)))
 
     ;; \setpythontexprettyprinter[<family>]{<printer>}
     '("setpythontexprettyprinter"
@@ -341,14 +342,14 @@ a list of strings."
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Mode")
         '("raw" "verb" "verbatim") ]
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] )
+      [ TeX-arg-key-val (LaTeX-fancyvrb-key-val-options) ] )
 
     ;; \stdoutpythontex[<mode>][<options>]
     '("stdoutpythontex"
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Mode")
         '("raw" "verb" "verbatim") ]
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] )
+      [ TeX-arg-key-val (LaTeX-fancyvrb-key-val-options) ] )
 
     ;;\saveprintpythontex{<name>}
     '("saveprintpythontex"
@@ -372,7 +373,7 @@ a list of strings."
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Mode")
         '("raw" "verb" "verbatim") ]
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+      [ TeX-arg-key-val (LaTeX-fancyvrb-key-val-options) ]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Name")
                     (LaTeX-pythontex-savecontent-list)))
@@ -383,7 +384,7 @@ a list of strings."
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Mode")
         '("raw" "verb" "verbatim") ]
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+      [ TeX-arg-key-val (LaTeX-fancyvrb-key-val-options) ]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Name")
                     (LaTeX-pythontex-savecontent-list)))
@@ -393,7 +394,7 @@ a list of strings."
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Mode")
         '("raw" "verb" "verbatim") ]
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] )
+      [ TeX-arg-key-val (LaTeX-fancyvrb-key-val-options) ] )
 
 
     ;;\savestderrpythontex{<name>}
@@ -409,7 +410,7 @@ a list of strings."
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Mode")
         '("raw" "verb" "verbatim") ]
-      [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
+      [ TeX-arg-key-val (LaTeX-fancyvrb-key-val-options) ]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Name")
                     (LaTeX-pythontex-savecontent-list)))
@@ -436,7 +437,7 @@ a list of strings."
 
     ;; \inputpygments[<fancyvrb settings>]{<lexer>}{<external file>}
     '("inputpygments"
-      [ TeX-arg-eval LaTeX-fancyvrb-key-val-options-local ]
+      [ TeX-arg-eval (LaTeX-fancyvrb-key-val-options) ]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Lexer")
                     (LaTeX-pythontex-language-list))
@@ -447,7 +448,7 @@ a list of strings."
       [ TeX-arg-eval completing-read
         (TeX-argument-prompt t nil "Lexer")
         (LaTeX-pythontex-language-list) ]
-      (TeX-arg-eval LaTeX-fancyvrb-key-val-options-local))
+      (TeX-arg-eval (LaTeX-fancyvrb-key-val-options)))
 
     ;; \setpygmentspygopt[<lexer>]{<pygments options>}
     '("setpygmentspygopt"
@@ -511,7 +512,7 @@ a list of strings."
 
     ;; \begin{pygments}[<fancyvrb settings>]{<lexer>}
     '("pygments" LaTeX-env-args
-      [ TeX-arg-eval LaTeX-fancyvrb-key-val-options-local ]
+      [TeX-arg-eval (LaTeX-fancyvrb-key-val-options)]
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Lexer")
                     (LaTeX-pythontex-language-list))) )
diff --git a/style/rotating.el b/style/rotating.el
new file mode 100644
index 0000000..fddda47
--- /dev/null
+++ b/style/rotating.el
@@ -0,0 +1,87 @@
+;;; rotating.el --- AUCTeX style for `rotating.sty' (v2.16d)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `rotating.sty' (v2.16d) from 2016/08/11.
+;; `rotating.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+(defvar LaTeX-graphicx-package-options)
+
+(TeX-add-style-hook
+ "rotating"
+ (lambda ()
+
+   ;; Environments provided by the package:
+   (LaTeX-add-environments
+    '("sidewaysfigure"  LaTeX-env-figure)
+    '("sidewaysfigure*" LaTeX-env-figure)
+    '("sidewaystable"   LaTeX-env-figure)
+    '("sidewaystable*"  LaTeX-env-figure)
+    "sideways"
+    '("turn"   "Angle")
+    '("rotate" "Angle"))
+
+   ;; Add the float environments to `LaTeX-label-alist':
+   (dolist (env '("sidewaysfigure" "sidewaysfigure*"))
+     (add-to-list 'LaTeX-label-alist `(,env . LaTeX-figure-label) t))
+
+   (dolist (env '("sidewaystable" "sidewaystable*"))
+     (add-to-list 'LaTeX-label-alist `(,env . LaTeX-table-label) t))
+
+   ;; The skips:
+   (LaTeX-add-lengths "rotFPtop" "rotFPbot")
+
+   ;; New symbols
+   (TeX-add-symbols
+    '("turnbox" ["Angle"] "Argument"))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("turnbox"   "[{"))
+                              'textual)))
+ TeX-dialect)
+
+(defvar LaTeX-rotating-package-options
+  (progn
+    (TeX-load-style "graphicx")
+    (append LaTeX-graphicx-package-options
+            '("clockwise"   "counterclockwise" "anticlockwise"
+              "figuresleft" "figuresright"
+              "quiet" "log" "chatter")))
+  "Package options for the rotating package.")
+
+;;; rotating.el ends here
diff --git a/style/sidecap.el b/style/sidecap.el
new file mode 100644
index 0000000..bcd019c
--- /dev/null
+++ b/style/sidecap.el
@@ -0,0 +1,160 @@
+;;; sidecap.el --- AUCTeX style for `sidecap.sty' (v1.6f)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `sidecap.sty' (v1.6f) from 2003/06/06.
+;; `sidecap.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+(defun LaTeX-env-sidecap-float (environment)
+  "Create ENVIRONMENT with \\caption and \\label commands.
+This function is a copy of `LaTeX-env-figure' and adjusted to
+read the first optional argument 'relwidth' provided by
+environments of the package sidecap."
+  (let* ((relwidth (TeX-read-string
+                    (TeX-argument-prompt t nil "Relative caption width")))
+         (float (and LaTeX-float        ; LaTeX-float can be nil, i.e.
+                                        ; do not prompt
+                     (TeX-read-string "(Optional) Float position: " 
LaTeX-float)))
+         (caption (TeX-read-string "Caption: "))
+         (short-caption (when (>= (length caption) 
LaTeX-short-caption-prompt-length)
+                          (TeX-read-string "(Optional) Short caption: ")))
+         (center (y-or-n-p "Center? "))
+         (active-mark (and (TeX-active-mark)
+                           (not (eq (mark) (point)))))
+         start-marker end-marker)
+    (when active-mark
+      (if (< (mark) (point))
+          (exchange-point-and-mark))
+      (setq start-marker (point-marker))
+      (set-marker-insertion-type start-marker t)
+      (setq end-marker (copy-marker (mark))))
+    (setq LaTeX-float float)
+    (LaTeX-insert-environment environment
+                              (concat
+                               ;; First check if 'relwidth' is given:
+                               (when (and relwidth
+                                          (not (string= relwidth "")))
+                                 (concat LaTeX-optop relwidth
+                                         LaTeX-optcl))
+                               ;; We have to insert a pair of brackets
+                               ;; if 'float' is given and 'relwidth'
+                               ;; was empty, otherwise 'float' becomes
+                               ;; 'relwidth':
+                               (unless (zerop (length float))
+                                 (concat
+                                  (when (or (null relwidth)
+                                            (string= relwidth ""))
+                                    (concat LaTeX-optop LaTeX-optcl))
+                                  LaTeX-optop float LaTeX-optcl))))
+    (when active-mark
+      (goto-char start-marker)
+      (set-marker start-marker nil))
+    (when center
+      (insert TeX-esc "centering")
+      (indent-according-to-mode)
+      (LaTeX-newline)
+      (indent-according-to-mode))
+    ;; Insert caption and ask for a label, do nothing if user skips caption
+    (unless (zerop (length caption))
+      (if (member environment LaTeX-top-caption-list)
+          ;; top caption
+          (progn
+            (insert (LaTeX-compose-caption-macro caption short-caption))
+            ;; If `auto-fill-mode' is active, fill the caption.
+            (if auto-fill-function (LaTeX-fill-paragraph))
+            (LaTeX-newline)
+            (indent-according-to-mode)
+            ;; ask for a label and insert a new line only if a label is
+            ;; actually inserted
+            (when (LaTeX-label environment 'environment)
+              (LaTeX-newline)
+              (indent-according-to-mode)))
+        ;; bottom caption (default)
+        (when active-mark (goto-char end-marker))
+        (save-excursion
+          (LaTeX-newline)
+          (indent-according-to-mode)
+          ;; If there is an active region point is before the backslash of
+          ;; "\end" macro, go one line upwards.
+          (when active-mark (forward-line -1) (indent-according-to-mode))
+          (insert (LaTeX-compose-caption-macro caption short-caption))
+          ;; If `auto-fill-mode' is active, fill the caption.
+          (if auto-fill-function (LaTeX-fill-paragraph))
+          ;; ask for a label and if necessary insert a new line between caption
+          ;; and label
+          (when (save-excursion (LaTeX-label environment 'environment))
+            (LaTeX-newline)
+            (indent-according-to-mode)))
+        ;; Insert an empty line between caption and marked region, if any.
+        (when active-mark (LaTeX-newline) (forward-line -1))
+        (indent-according-to-mode)))
+    (when (markerp end-marker)
+      (set-marker end-marker nil))
+    (when (and (member environment '("SCtable" "SCtable*"))
+               ;; Suppose an existing tabular environment should just
+               ;; be wrapped into a table if there is an active region.
+               (not active-mark))
+      (LaTeX-environment-menu LaTeX-default-tabular-environment))))
+
+(TeX-add-style-hook
+ "sidecap"
+ (lambda ()
+
+   ;; Add the environments provided by the package:
+   (LaTeX-add-environments
+    '("SCtable"   LaTeX-env-sidecap-float)
+    '("SCtable*"  LaTeX-env-sidecap-float)
+    '("SCfigure"  LaTeX-env-sidecap-float)
+    '("SCfigure*" LaTeX-env-sidecap-float)
+    '("wide"))
+
+   ;; Add the float environments to `LaTeX-label-alist':
+   (dolist (env '("SCfigure" "SCfigure*"))
+     (add-to-list 'LaTeX-label-alist `(,env . LaTeX-figure-label) t))
+
+   (dolist (env '("SCtable" "SCtable*"))
+     (add-to-list 'LaTeX-label-alist `(,env . LaTeX-table-label) t))
+
+   ;; The next 2 can be set with '\renewcommand':
+   (TeX-add-symbols
+    "sidecaptionsep"
+    "sidecaptionrelwidth"))
+ TeX-dialect)
+
+(defvar LaTeX-sidecap-package-options
+  '("outercaption" "innercaption"
+    "leftcaption" "rightcaption"
+    "wide"
+    "raggedright" "raggedleft" "ragged")
+  "Package options for the sidecap package.")
+
+;;; sidecap.el ends here
diff --git a/style/siunitx.el b/style/siunitx.el
index e67e817..9ad9aba 100644
--- a/style/siunitx.el
+++ b/style/siunitx.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2012-2021  Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
-;; Author: Mosè Giordano <giordano.mose@libero.it>
+;; Author: Mosè Giordano <mose@gnu.org>
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -25,7 +25,8 @@
 
 ;;; Commentary:
 
-;; This file adds support for `siunitx.sty' version 2.5s.
+;; This file adds support for `siunitx.sty' version 3.0.36 from
+;; 2021/22/18.
 
 ;;; Code:
 
@@ -36,39 +37,50 @@
 (declare-function font-latex-add-keywords
                   "font-latex"
                   (keywords class))
+(declare-function LaTeX-color-definecolor-list "color" ())
+(declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
 
 (TeX-auto-add-type "siunitx-unit" "LaTeX")
 
-;; Self Parsing -- see (info "(auctex)Hacking the Parser").  
`\\(?:\\[.*\\]\\)?'
-;; matches possible options (actually used only by `DeclareSIUnit' macro),
-;; wrapped in `[...]'.
+;; Self Parsing -- see (info "(auctex)Hacking the Parser").
+;; `\\(?:\\[[^]]*\\]\\)?' matches possible options (actually used only
+;; by `DeclareSIUnit' macro), wrapped in `[...]'.
 (defvar LaTeX-siunitx-regexp
-  (concat "\\\\Declare"
-          "\\(?:SIUnit\\|SIPrefix\\|BinaryPrefix\\|SIPostPower\\|SIPrepower\\|"
-          "SIQualifier\\)"
-          "[ \t\n\r]*\\(?:\\[.*\\]\\)?[ \t\n\r]*{?\\\\\\([A-Za-z]+\\)}?")
+  `(,(concat "\\\\DeclareSI\\(Unit\\|Prefix\\|Power\\|Qualifier\\)"
+             "[ \t\n\r]*"
+             ;; The optional argument
+             "\\(?:\\[[^]]*\\]\\)?"
+             "[ \t\n\r]*"
+             ;; First mandatory argument
+             "{?\\\\\\([A-Za-z]+\\)}?"
+             "[ \t\n\r]*"
+             ;; Second mandatory argument needed for '\DeclareSIPower':
+             "{?\\\\\\([A-Za-z]+\\)}?")
+    (2 3 1) LaTeX-auto-siunitx-unit)
   "Matches new siunitx unit, prefix, power, and qualifier definitions.")
 
-(defvar LaTeX-auto-siunitx-unit nil
-  "Temporary for parsing siunitx macro definitions.")
-
 (defun LaTeX-siunitx-prepare ()
   "Clear `LaTex-auto-siunitx-unit' before use."
   (setq LaTeX-auto-siunitx-unit nil))
 
-(defun LaTeX-siunitx-cleanup ()
-  "Move symbols from `LaTeX-auto-siunitx-unit' to `LaTeX-siunitx-unit-list'."
-  (mapcar (lambda (symbol)
-            (add-to-list 'LaTeX-siunitx-unit-list (list symbol)))
-          LaTeX-auto-siunitx-unit))
-
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-siunitx-prepare t)
-(add-hook 'TeX-auto-cleanup-hook #'LaTeX-siunitx-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
 (defvar LaTeX-siunitx-unit-history nil
   "History of units in siunitx.")
 
+(defun LaTeX-siunitx-unit-list-parsed ()
+  "Return a list of units incl. the user defined ones.
+This function should be preferred over the function
+`LaTeX-siunitx-unit-list' since it knows about the 2 macros
+defined with '\\DeclareSIPower'."
+  (let (result)
+    (dolist (unit (LaTeX-siunitx-unit-list) result)
+      (push (car unit) result)
+      (when (and (> (safe-length unit) 1)
+                 (string-equal (nth 2 unit) "Power"))
+        (push (cadr unit) result)))))
+
 (defun LaTeX-arg-siunitx-unit (optional &optional prompt initial-input
                                         definition prefix)
   "Prompt for siunitx units, prefixes, powers, and qualifiers.
@@ -91,7 +103,8 @@ PREFIX is non-nil, insert it before the given input."
          (unit (mapconcat #'identity
                           (TeX-completing-read-multiple
                            (TeX-argument-prompt optional prompt "Unit: " t)
-                           (LaTeX-siunitx-unit-list) nil nil initial-input
+                           (LaTeX-siunitx-unit-list-parsed)
+                           nil nil initial-input
                            'LaTeX-siunitx-unit-history)
                           TeX-esc)))
     (if (and definition (not (string-equal "" unit)))
@@ -108,228 +121,232 @@ string."
                           nil t TeX-esc))
 
 (defvar LaTeX-siunitx-package-options
-  '(;; Detecting fonts
-    ("detect-all")
-    ("detect-display-math" ("true" "false"))
-    ("detect-family" ("true" "false"))
-    ("detect-inline-family" ("math" "text"))
-    ("detect-inline-weight" ("math" "text"))
-    ("detect-mode" ("true" "false"))
-    ("detect-none")
-    ("detect-shape" ("true" "false"))
-    ("detect-weight" ("true" "false"))
-    ;; Font settings
+  '(;; Table 10: Print options
     ("color")
-    ("math-rm")
-    ("math-sf")
-    ("math-tt")
-    ("mode" ("math" "text"))
+    ("mode"                       ("match" "math" "text"))
     ("number-color")
-    ("text-rm")
-    ("text-sf")
-    ("text-tt")
+    ("number-mode"                ("match" "math" "text"))
+    ("propagate-math-font"        ("true" "false"))
+    ("reset-math-version"         ("true" "false"))
+    ("reset-text-family"          ("true" "false"))
+    ("reset-text-series"          ("true" "false"))
+    ("reset-text-shape"           ("true" "false"))
+    ("text-family-to-math"        ("true" "false"))
+    ("text-font-command")
+    ("text-series-to-math"        ("true" "false"))
     ("unit-color")
-    ;; Parsing numbers
+    ("unit-mode"                  ("match" "math" "text"))
+    ;; Table 11: Options for number parsing
+    ("evaluate-expression"        ("true" "false"))
+    ("expression")
     ("input-close-uncertainty")
     ("input-comparators")
-    ("input-complex-roots")
     ("input-decimal-markers")
     ("input-digits")
     ("input-exponent-markers")
     ("input-ignore")
     ("input-open-uncertainty")
-    ("input-protect-tokens")
     ("input-signs")
     ("input-uncertainty-signs")
-    ("input-symbols")
-    ("parse-numbers" ("true" "false"))
-    ;; Post-processing numbers
-    ("add-decimal-zero" ("true" "false"))
-    ("add-integer-zero" ("true" "false"))
-    ("explicit-sign")
+    ("parse-numbers"              ("true" "false"))
+    ("retain-explicit-plus"       ("true" "false"))
+    ("retain-zero-uncertainty"    ("true" "false"))
+    ;; Table 12: Number post-processing options
+    ("drop-exponent"              ("true" "false"))
+    ("drop-uncertainty"           ("true" "false"))
+    ("drop-zero-decimal"          ("true" "false"))
+    ("exponent-mode"              ("input" "fixed" "engineering" "scientific"))
     ("fixed-exponent")
     ("minimum-integer-digits")
-    ("omit-uncertainty" ("true" "false"))
-    ("retain-explicit-plus" ("true" "false"))
-    ("retain-unity-mantissa" ("true" "false"))
-    ("retain-zero-exponent" ("true" "false"))
-    ("round-half" ("up" "even"))
-    ("round-integer-to-decimal" ("true" "false"))
+    ("minimum-decimal-digits")
+    ("round-half"                 ("up" "even"))
     ("round-minimum")
-    ("round-mode" ("off" "figures" "places"))
+    ("round-mode"                 ("off" "figures" "places" "uncertainty"))
+    ("round-pad"                  ("true" "false"))
     ("round-precision")
-    ("scientific-notation" ("true" "false" "fixed" "engineering"))
-    ("zero-decimal-to-integer" ("true" "false"))
-    ;; Printing numbers
-    ("bracket-negative-numbers" ("true" "false"))
-    ("bracket-numbers" ("true" "false"))
-    ("close-bracket")
-    ("complex-root-position" ("after-number" "before-number"))
-    ("copy-complex-root")
-    ("copy-decimal-marker")
+    ;; Table 13: Output options for numbers
+    ("bracket-negative-numbers"   ("true" "false"))
     ("exponent-base")
     ("exponent-product")
-    ("group-digits" ("true" "false" "decimal" "integer"))
+    ("group-digits"               ("all" "none" "decimal" "integer"))
     ("group-minimum-digits")
     ("group-separator")
     ("negative-color")
-    ("open-bracket")
     ("output-close-uncertainty")
-    ("output-complex-root")
     ("output-decimal-marker")
     ("output-exponent-marker")
     ("output-open-uncertainty")
-    ("separate-uncertainty" ("true" "false"))
-    ("tight-spacing" ("true" "false"))
+    ("print-implicit-plus"        ("true" "false"))
+    ("print-unity-mantissa"       ("true" "false"))
+    ("print-zero-exponent"        ("true" "false"))
+    ("tight-spacing"              ("true" "false"))
+    ("uncertainty-mode"           ("compact" "full" "compact-marker"))
     ("uncertainty-separator")
-    ;; Multi-part numbers
-    ("fraction-function")
-    ("input-product")
-    ("input-quotient")
-    ("output-product")
-    ("output-quotient")
-    ("quotient-mode" ("symbol" "fraction"))
-    ;; Lists and ranges of numbers
+    ;; Table 14: Output options for lists, products and ranges of
+    ;; numbers and quantities
+    ("list-exponents"             ("individual" "combine-bracket" "combine"))
     ("list-final-separator")
     ("list-pair-separator")
     ("list-separator")
+    ("list-units"                 ("repeat" "bracket" "single"))
+    ("product-exponents"          ("individual" "combine-bracket" "combine"))
+    ("product-mode"               ("symbol" "phrase"))
+    ("product-phrase")
+    ("product-symbol")
+    ("product-units"              ("repeat" "bracket" "single"))
+    ("range-exponents"            ("individual" "combine-bracket" "combine"))
     ("range-phrase")
-    ;; Angles
-    ("add-arc-degree-zero" ("true" "false"))
-    ("add-arc-minute-zero" ("true" "false"))
-    ("add-arc-second-zero" ("true" "false"))
-    ("angle-symbol-over-decimal" ("true" "false"))
-    ("arc-separator")
+    ("range-units"                ("repeat" "bracket" "single"))
+    ;; Table 15: Options for complex numbers
+    ("complex-root-position"      ("after-number" "before-number"))
+    ("output-complex-root")
+    ("input-complex-root")
+    ;; Table 16: Angle options
+    ("angle-mode"                 ("input" "arc" "decimal"))
+    ("angle-symbol-degree")
+    ("angle-symbol-minute")
+    ("angle-symbol-over-decimal"  ("true" "false"))
+    ("angle-symbol-second")
+    ("angle-separator")
+    ("fill-angle-degrees"         ("true" "false"))
+    ("fill-angle-minutes"         ("true" "false"))
+    ("fill-angle-seconds"         ("true" "false"))
     ("number-angle-product")
-    ;; Creating units
-    ("free-standing-units" ("true" "false"))
-    ("overwrite-functions" ("true" "false"))
-    ("space-before-unit" ("true" "false"))
-    ("unit-optional-argument" ("true" "false"))
-    ("use-xspace" ("true" "false"))
-    ;; Loading additional units
-    ("abbreviations" ("true" "false"))
-    ("binary-units" ("true" "false"))
-    ("version-1-compatibility" ("true" "false"))
-    ;; Using units
-    ("bracket-unit-denominator" ("true" "false"))
-    ("forbid-literal-units" ("true" "false"))
-    ("literal-superscript-as-power" ("true" "false"))
+    ;; Table 17: Unit creation options
+    ("free-standing-units"        ("true" "false"))
+    ("overwrite-command"          ("true" "false"))
+    ("space-before-unit"          ("true" "false"))
+    ("unit-optional-argument"     ("true" "false"))
+    ("use-xspace"                 ("true" "false"))
+    ;; Table 18: Unit output options
+    ("bracket-unit-denominator"   ("true" "false"))
+    ("forbid-literal-units"       ("true" "false"))
+    ("fraction-command")
     ("inter-unit-product")
-    ("parse-units" ("true" "false"))
-    ("per-mode" ("reciprocal" "fraction" "reciprocal-positive-first" "symbol"
-                 "repeated-symbol" "symbol-or-fraction"))
+    ("parse-units"                ("true" "false"))
+    ("per-mode"                   ("power" "fraction" "symbol"
+                                   "repeated-symbol"  "symbol-or-fraction"))
     ("per-symbol")
-    ("power-font" ("number" "unit"))
-    ("prefixes-as-symbols" ("true" "false"))
-    ("qualifier-mode" ("subscript" "brackets" "phrase" "space" "text"))
+    ("qualifier-mode"             ("subscript" "brackets"
+                                   "combine"   "phrase"))
     ("qualifier-phrase")
-    ("sticky-per" ("true" "false"))
-    ;; Numbers with units
-    ("allow-number-unit-breaks" ("true" "false"))
-    ("exponent-to-prefix" ("true" "false"))
-    ("list-units" ("brackets" "repeat" "single"))
-    ("multi-part-units" ("brackets" "repeat" "single"))
-    ("number-unit-product")
-    ("product-units" ("repeat" "brackets" "brackets-power" "power" "repeat"
-                      "single"))
-    ("range-units" ("brackets" "repeat" "single"))
-    ;; Tabular material
-    ("table-align-comparator" ("true" "false"))
-    ("table-align-exponent" ("true" "false"))
-    ("table-align-text-pre" ("true" "false"))
-    ("table-align-text-post" ("true" "false"))
-    ("table-align-uncertainty" ("true" "false"))
-    ("table-alignment" ("center" "left" "right"))
-    ("table-auto-round" ("true" "false"))
+    ("sticky-per"                 ("true" "false"))
+    ("unit-font-command")
+    ;; Table 19: Options for quantities
+    ("allow-number-unit-breaks"   ("true" "false"))
+    ("extract-mass-in-kilograms"  ("true" "false"))
+    ("prefix-mode"                ("input" "combine-exponent"
+                                   "extract-exponent"))
+    ("quantity-product")
+    ("separate-uncertainty-units")
+    ;; Table 20: Options for tabular material
+    ("table-align-comparator"     ("true" "false"))
+    ("table-align-exponent"       ("true" "false"))
+    ("table-align-text-after"     ("true" "false"))
+    ("table-align-text-before"    ("true" "false"))
+    ("table-align-uncertainty"    ("true" "false"))
+    ("table-alignment"            ("center" "left" "right" "none"))
+    ("table-alignment-mode"       ("format" "marker" "none"))
+    ("table-auto-round"           ("true" "false"))
     ("table-column-width")
-    ("table-comparator" ("true" "false"))
-    ("table-figures-decimal")
-    ("table-figures-exponent")
-    ("table-figures-integer")
-    ("table-figures-uncertainty")
+    ("table-fixed-width"          ("true" "false"))
     ("table-format")
-    ("table-number-alignment" ("center-decimal-marker" "center" "left" 
"right"))
-    ("table-parse-only" ("true" "false"))
-    ("table-omit-exponent" ("true" "false"))
-    ("table-space-text-pre")
-    ("table-space-text-post")
-    ("table-sign-exponent" ("true" "false"))
-    ("table-sign-mantissa" ("true" "false"))
-    ("table-text-alignment" ("center" "left" "right"))
-    ("table-unit-alignment" ("center" "left" "right"))
-    ;; Symbols
-    ("math-angstrom")
-    ("math-arcminute")
-    ("math-arcsecond")
-    ("math-celsius")
-    ("math-degree")
-    ("math-micro")
-    ("math-ohm")
-    ("redefine-symbols" ("true" "false"))
-    ("text-angstrom")
-    ("text-arcminute")
-    ("text-arcsecond")
-    ("text-celsius")
-    ("text-degree")
-    ("text-micro")
-    ("text-ohm")
-    ;; Other options
-    ("locale" ("FR" "DE" "UK" "US" "ZA"))
-    ("strict"))
+    ("table-number-alignment"     ("center" "left" "right"))
+    ("table-text-alignment"       ("center" "left" "right"))
+    ;; 4.13 Locale options
+    ("locale"                     ("FR" "DE" "UK" "US" "ZA")))
   "Package options for the siunitx package.")
 
+(defun LaTeX-siunitx-key-val-options ()
+  "Return an updated list of key=vals from siunitx package."
+  (append
+   (when (and (or (member "xcolor" (TeX-style-list))
+                  (member "color" TeX-active-styles)))
+     (let* ((colorcmd (if (member "xcolor" TeX-active-styles)
+                          #'LaTeX-xcolor-definecolor-list
+                        #'LaTeX-color-definecolor-list))
+            (colors  (mapcar #'car (funcall colorcmd)))
+            (keys '("color"
+                    "number-color"
+                    "unit-color"
+                    "negative-color"))
+            result)
+       (dolist (key keys result)
+         (push (list key colors) result))))
+   LaTeX-siunitx-package-options))
+
 (TeX-add-style-hook
  "siunitx"
  (lambda ()
-   (TeX-auto-add-regexp `(,LaTeX-siunitx-regexp 1 LaTeX-auto-siunitx-unit))
+
+   (TeX-auto-add-regexp LaTeX-siunitx-regexp)
+
    (TeX-add-symbols
-    ;; Numbers
-    '("ang" [TeX-arg-key-val LaTeX-siunitx-package-options] "Angle")
-    '("num" [TeX-arg-key-val LaTeX-siunitx-package-options] "Number")
-    '("numlist" [TeX-arg-key-val LaTeX-siunitx-package-options] "Numbers")
-    '("numrange" [TeX-arg-key-val LaTeX-siunitx-package-options]
+    '("sisetup" (TeX-arg-key-val (LaTeX-siunitx-key-val-options)))
+
+    ;; 3.1 Numbers
+    '("num"        [TeX-arg-key-val (LaTeX-siunitx-key-val-options)] "Number")
+    '("numlist"    [TeX-arg-key-val (LaTeX-siunitx-key-val-options)] "Numbers")
+    '("numproduct" [TeX-arg-key-val (LaTeX-siunitx-key-val-options)] "Numbers")
+    '("numrange"   [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
       "Number 1" "Number 2")
-    ;; Units
-    '("si" [TeX-arg-key-val LaTeX-siunitx-package-options] 
LaTeX-arg-siunitx-unit)
-    '("SI" [TeX-arg-key-val LaTeX-siunitx-package-options]
-      "Value" [ "Pre-unit"] LaTeX-arg-siunitx-unit)
-    '("SIlist" [TeX-arg-key-val LaTeX-siunitx-package-options]
-      "Values" LaTeX-arg-siunitx-unit)
-    '("SIrange" [TeX-arg-key-val LaTeX-siunitx-package-options]
-      "Value 1" "Value 2" LaTeX-arg-siunitx-unit)
-    ;; Settings
-    '("sisetup" (TeX-arg-key-val LaTeX-siunitx-package-options))
-    ;; Tabular material
-    '("tablenum" [TeX-arg-key-val LaTeX-siunitx-package-options] "Number")
-    ;; Creating new macros (`DeclareSIUnitWithOptions' macro is deprecated)
-    '("DeclareSIUnit" [TeX-arg-key-val LaTeX-siunitx-package-options]
+
+    ;; 3.2 Angles
+    '("ang" [TeX-arg-key-val (LaTeX-siunitx-key-val-options)] "Angle")
+
+    ;; 3.3 Units
+    '("unit"       [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
+      LaTeX-arg-siunitx-unit)
+    '("qty"        [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
+      "Number" LaTeX-arg-siunitx-unit)
+    '("qtylist"    [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
+      "Numbers" LaTeX-arg-siunitx-unit)
+    '("qtyproduct" [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
+      "Numbers" LaTeX-arg-siunitx-unit)
+    '("qtyrange"   [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
+      "Number 1" "Number 2" LaTeX-arg-siunitx-unit)
+
+    ;; 3.4 Complex numbers and quantities
+    '("complexnum" [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
+      "Number")
+    '("complexqty" [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
+      "Number" LaTeX-arg-siunitx-unit)
+
+    ;; These macros are deprecated with package v3: "si", "SI",
+    ;; "SIlist", "SIrange", "SendSettingsToPgf".  Hence they are
+    ;; removed.
+
+    ;; 3.7 Creating new macros
+    '("DeclareSIUnit" [TeX-arg-key-val (LaTeX-siunitx-key-val-options)]
       (LaTeX-arg-define-siunitx-unit) "Symbol")
+
     '("DeclareSIPrefix" (LaTeX-arg-define-siunitx-unit "Prefix")
       "Symbol" "Powers of 10")
-    '("DeclareBinaryPrefix" (LaTeX-arg-define-siunitx-unit "Prefix")
-      "Symbol" "Powers of 2")
-    '("DeclareSIPostPower" (LaTeX-arg-define-siunitx-unit "Name") "Power")
-    '("DeclareSIPrePower" (LaTeX-arg-define-siunitx-unit "Name") "Power")
+
+    '("DeclareSIPower"
+      (LaTeX-arg-define-siunitx-unit "Symbol before")
+      (LaTeX-arg-define-siunitx-unit "Symbol after")
+      "Power")
+
     '("DeclareSIQualifier" (LaTeX-arg-define-siunitx-unit "Qualifier") 
"Symbol")
-    ;; Highlighting
-    '("highlight" "Color")
-    ;; Transferring settings to pgf
-    '("SendSettingsToPgf" 0))
-    ;;; The unit macros
-   ;; SI base units
+
+    ;; 3.8 Tabular material
+    '("tablenum" [TeX-arg-key-val (LaTeX-siunitx-key-val-options)] "Number"))
+
+   ;; The unit macros
    (LaTeX-add-siunitx-units
+    ;; Table 1: SI base units.
     "ampere"
     "candela"
     "kelvin"
     "kilogram"
-    "gram"
     "meter"
     "metre"
     "second"
-    ;; Coherent derived units in the SI with special names and symbols
+    ;; Table 2: Coherent derived units in the SI with special names
+    ;; and symbols
     "becquerel"
-    "celsius"
+    ;; "celsius"
     "degreeCelsius"
     "coulomb"
     "farad"
@@ -337,8 +354,8 @@ string."
     "hertz"
     "henry"
     "joule"
-    "katal"
     "lumen"
+    "katal"
     "lux"
     "newton"
     "ohm"
@@ -351,9 +368,15 @@ string."
     "volt"
     "watt"
     "weber"
-    ;; Non-SI units accepted for use with the International System of Units
+    ;; Table 3: Non-SI units accepted for use with the International
+    ;; System of Units
+    "astronomicalunit"
+    "bel"
+    "dalton"
     "day"
+    "decibel"
     "degree"
+    "electronvolt"
     "hectare"
     "hour"
     "liter"
@@ -361,30 +384,20 @@ string."
     "arcminute"
     "minute"
     "arcsecond"
-    "tonne"
-    ;; Non-SI units whose values in SI units must be obtained experimentally
-    "astronomicalunit"
-    "atomicmassunit"
-    "bohr"
-    "clight"
-    "dalton"
-    "electronmass"
-    "electronvolt"
-    "elementarycharge"
-    "hartree"
-    "planckbar"
-    ;; Other non-SI units.
-    "angstrom"
-    "bar"
-    "barn"
-    "bel"
-    "decibel"
-    "knot"
-    "mmHg"
-    "nauticalmile"
     "neper"
+    "tonne"
+    ;; 3.5 The unit macros
     "percent"
-    ;; SI prefixes
+    "square"
+    "squared"
+    "cubic"
+    "cubed"
+    "tothe"
+    "raiseto"
+    "per"
+    "of"
+    "highlight" ; Defined by siunitx.sty
+    ;; Table 4: SI prefixes
     "yocto"
     "zepto"
     "atto"
@@ -405,201 +418,37 @@ string."
     "peta"
     "exa"
     "zetta"
-    "yotta"
-    ;; Powers
-    "square"
-    "squared"
-    "cubic"
-    "cubed"
-    "tothe"
-    "raiseto"
-    "per"
-    "of")
-   ;; Abbreviated units (available unless `abbreviations' option is set to 
`false')
-   (unless (LaTeX-provided-package-options-member "siunitx" 
"abbreviations=false")
-     (LaTeX-add-siunitx-units
-      "fg"
-      "pg"
-      "ng"
-      "ug"
-      "mg"
-      "g"
-      "kg"
-      "amu"
-      "pm"
-      "nm"
-      "um"
-      "mm"
-      "cm"
-      "dm"
-      "m"
-      "km"
-      "as"
-      "fs"
-      "ps"
-      "ns"
-      "us"
-      "ms"
-      "s"
-      "fmol"
-      "pmol"
-      "nmol"
-      "umol"
-      "mmol"
-      "mol"
-      "kmol"
-      "pA"
-      "nA"
-      "uA"
-      "mA"
-      "A"
-      "kA"
-      "ul"
-      "ml"
-      "l"
-      "hl"
-      "uL"
-      "mL"
-      "L"
-      "hL"
-      "mHz"
-      "Hz"
-      "kHz"
-      "MHz"
-      "GHz"
-      "THz"
-      "N"
-      "mN"
-      "kN"
-      "MN"
-      "Pa"
-      "kPa"
-      "MPa"
-      "GPa"
-      "mohm"
-      "kohm"
-      "Mohm"
-      "pV"
-      "nV"
-      "uV"
-      "mV"
-      "V"
-      "kV"
-      "uW"
-      "mW"
-      "W"
-      "kW"
-      "MW"
-      "GW"
-      "J"
-      "kJ"
-      "meV"
-      "keV"
-      "MeV"
-      "GeV"
-      "TeV"
-      "kWh"
-      "F"
-      "fF"
-      "pF"
-      "K"
-      "dB"))
-   ;; Binary prefixes and units available when `binary-units' option is used
-   (when (or (LaTeX-provided-package-options-member "siunitx" "binary-units")
-             (LaTeX-provided-package-options-member "siunitx" 
"binary-units=true"))
-     (LaTeX-add-siunitx-units
-      "kibi"
-      "mebi"
-      "gibi"
-      "tebi"
-      "pebi"
-      "exbi"
-      "zebi"
-      "yobi"
-      "bit"
-      "byte"))
-   ;; Symbols
+    "yotta")
+
+   ;; 3.6 Unit abbreviations are always defined:
    (LaTeX-add-siunitx-units
-    "SIUnitSymbolAngstrom"
-    "SIUnitSymbolArcminute"
-    "SIUnitSymbolArcsecond"
-    "SIUnitSymbolCelsius"
-    "SIUnitSymbolDegree"
-    "SIUnitSymbolMicro"
-    "SIUnitSymbolOhm")
-   ;; Macros available when `version-1-compatibility' option is used
-   (when (or (LaTeX-provided-package-options-member
-              "siunitx" "version-1-compatibility")
-             (LaTeX-provided-package-options-member
-              "siunitx" "version-1-compatibility=true"))
-     (LaTeX-add-siunitx-units
-      "Square"
-      "ssquare"
-      "BAR"
-      "bbar"
-      "Day"
-      "dday"
-      "Gray"
-      "ggray"
-      "atomicmass"
-      "arcmin"
-      "arcsec"
-      "are"
-      "curie"
-      "gal"
-      "millibar"
-      "rad"
-      "rem"
-      "roentgen"
-      "micA"
-      "micmol"
-      "micl"
-      "micL"
-      "nanog"
-      "micg"
-      "picm"
-      "micm"
-      "Sec"
-      "mics"
-      "cmc"
-      "dmc"
-      "cms"
-      "centimetrecubed"
-      "centimetresquared"
-      "cubiccentimetre"
-      "cubicdecimetre"
-      "squarecentimetre"
-      "squaremetre"
-      "squarekilometre"
-      "parsec"
-      "lightyear"
-      "gmol"
-      "kgmol"
-      "lbmol"
-      "molar"
-      "Molar"
-      "torr"
-      "gon"
-      "micron"
-      "mrad"
-      "gauss"
-      "eVperc"
-      "nanobarn"
-      "picobarn"
-      "femtobarn"
-      "attobarn"
-      "zeptobarn"
-      "yoctobarn"
-      "nb"
-      "pb"
-      "fb"
-      "ab"
-      "zb"
-      "yb"))
-
-   ;; `siunitx.sty' adds new column specification letters
+    "fg"    "pg"    "ng"    "ug"    "mg"    "g"    "kg"
+    "pm"    "nm"    "um"    "mm"    "cm"    "dm"   "m"  "km"
+    "as"    "fs"    "ps"    "ns"    "us"    "ms"   "s"
+    "fmol"  "pmol"  "nmol"  "umol"  "mmol"  "mol"  "kmol"
+    "pA"    "nA"    "uA"    "mA"    "A"     "kA"
+    "ul"    "ml"    "l"     "hl"    "uL"    "mL"   "L"  "hL"
+    "mHz"   "Hz"    "kHz"   "MHz"   "GHz"   "THz"
+    "mN"    "N"     "kN"    "MN"
+    "Pa"    "kPa"   "MPa"   "GPa"
+    "mohm"  "kohm"  "Mohm"
+    "pV"    "nV"    "uV"    "mV"    "V"     "kV"
+    "uW"    "mW"    "W"     "kW"    "MW"    "GW"
+    "J"     "uJ"    "mJ"    "kJ"
+    "eV"    "meV"   "keV"   "MeV"   "GeV"   "TeV"  "kWh"
+    "F"     "fF"    "pF"    "nF"    "uF"
+    "H"     "mH"    "uH"
+    "K"     "dB"
+    "kibi"  "mebi"  "gibi"  "tebi"  "pebi"
+    "exbi"  "zebi"  "yobi"  "bit"   "byte")
+
+   ;; \cancel is only available when cancel.sty is loaded:
+   (when (member "cancel" (TeX-style-list))
+     (LaTeX-add-siunitx-units "cancel"))
+
+   ;; `siunitx.sty' add new column specification letter 'S'
    (set (make-local-variable 'LaTeX-array-column-letters)
-        (concat LaTeX-array-column-letters "s" "S"))
+        (concat LaTeX-array-column-letters "S"))
 
    (TeX-run-style-hooks "l3keys2e"
                         "array"
@@ -610,28 +459,39 @@ string."
    ;; Fontification
    (when (and (featurep 'font-latex)
               (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("ang" "[{")
-                                ("num" "[{")
-                                ("si" "[{")
-                                ("SI" "[{[{")
-                                ("numlist" "[{")
-                                ("numrange" "[{{")
-                                ("SIlist" "[{{")
-                                ("SIrange" "[{{{")
-                                ("sisetup" "{")
-                                ("tablenum" "[{")
-                                ("DeclareSIUnit" "[|{\\{")
-                                ("DeclareSIPrefix" "|{\\{{")
-                                ("DeclareBinaryPrefix" "|{\\{{")
-                                ("DeclareSIPostPower" "|{\\{")
-                                ("DeclareSIPrePower" "|{\\{")
-                                ("DeclareSIQualifier" "|{\\{")
-                                ("highlight" "{"))
+     (font-latex-add-keywords '(("num"                 "[{")
+                                ("numlist"             "[{")
+                                ("numproduct"          "[{")
+                                ("numrange"            "[{{")
+                                ("ang"                 "[{")
+                                ("unit"                "[{")
+                                ("qty"                 "[{{")
+                                ("qtylist"             "[{{")
+                                ("qtyrange"            "[{{{")
+                                ("complexnum"          "[{")
+                                ("complexqty"          "[{")
+                                ("DeclareSIUnit"       "[|{\\{")
+                                ("DeclareSIPrefix"     "|{\\{{")
+                                ("DeclareSIPower"      "|{\\|{\\{")
+                                ("DeclareSIQualifier"  "|{\\{")
+                                ("tablenum"            "[{")
+                                ("highlight"           "{")
+                                ("sisetup"             "{")
+                                ;; These macros are deprecated in v3, we
+                                ;; leave the fontification support
+                                ;; here for older documents:
+                                ("si"       "[{")
+                                ("SI"       "[{[{")
+                                ("SIlist"   "[{{")
+                                ("SIrange"  "[{{{"))
                               'function)))
  TeX-dialect)
 
 (defun LaTeX-siunitx-package-options nil
   "Prompt for package options for the siunitx package."
-  (TeX-read-key-val t LaTeX-siunitx-package-options))
+  (TeX-read-key-val t (append
+                       ;; 'table-column-type' is a preamble only:
+                       '(("table-column-type"))
+                       LaTeX-siunitx-package-options)))
 
 ;; siunitx.el ends here
diff --git a/style/stabular.el b/style/stabular.el
new file mode 100644
index 0000000..5f3ca02
--- /dev/null
+++ b/style/stabular.el
@@ -0,0 +1,63 @@
+;;; stabular.el --- AUCTeX style for `stabular.sty' (v2.1)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `stabular.sty' (v2.1) from 2021/10/04.
+;; `stabular.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+(TeX-add-style-hook
+ "stabular"
+ (lambda ()
+
+   ;; Load array.el if the package option is given:
+   (when (LaTeX-provided-package-options-member "stabular" "array")
+     (TeX-run-style-hooks "array"))
+
+   ;; Add the environments provided by the package:
+   (LaTeX-add-environments
+    '("stabular" LaTeX-env-array)
+    '("stabular*" LaTeX-env-tabular*))
+
+   ;; Append the environments to `LaTeX-item-list':
+   (add-to-list 'LaTeX-item-list
+                '("stabular" . LaTeX-item-array)
+                t)
+   (add-to-list 'LaTeX-item-list
+                '("stabular*" . LaTeX-item-tabular*)
+                t))
+
+ TeX-dialect)
+
+(defvar LaTeX-stabular-package-options '("array")
+  "Package options for the stabular package.")
+
+;;; stabular.el ends here
diff --git a/style/stfloats.el b/style/stfloats.el
new file mode 100644
index 0000000..9e80bbf
--- /dev/null
+++ b/style/stfloats.el
@@ -0,0 +1,65 @@
+;;; stfloats.el --- AUCTeX style for `stfloats.sty' (v3.3d)  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-12-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 `stfloats.sty' (v3.3d) from 2017/03/27.
+;; `stfloats.sty' is part of TeXLive.
+
+;;; Code:
+
+(require 'tex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "stfloats"
+ (lambda ()
+
+   ;; New symbols
+   (TeX-add-symbols
+    "fnbelowfloat"
+    "fnunderfloat"
+    "setbaselinefloat"
+    "setbaselinefixed")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("fnbelowfloat"     "")
+                                ("fnunderfloat"     "")
+                                ("setbaselinefloat" "")
+                                ("setbaselinefixed" ""))
+                              'function)))
+ TeX-dialect)
+
+(defvar LaTeX-stfloats-package-options nil
+  "Package options for the stfloats package.")
+
+;;; stfloats.el ends here
diff --git a/style/subcaption.el b/style/subcaption.el
index 5f3122f..e40dc80 100644
--- a/style/subcaption.el
+++ b/style/subcaption.el
@@ -1,6 +1,6 @@
 ;;; subcaption.el --- AUCTeX style for `subcaption.sty' (v1.3)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -38,17 +38,17 @@
 (declare-function font-latex-add-keywords
                   "font-latex"
                   (keywords class))
-
-(defvar LaTeX-caption-key-val-options-local)
 (defvar LaTeX-caption-key-val-options)
 
 (defvar LaTeX-subcaption-key-val-options
   '(("subrefformat" ("default" "empty" "simple" "brace" "parens")))
-  "Key=value options for subcaption package.  This key takes the
-same values as \"labelformat\" from caption package.")
+  "Key=value options for subcaption package.
+This key takes the same values as \"labelformat\" from caption
+package.")
 
 (defun LaTeX-arg-subcaption-subcaption (optional &optional star)
   "Query for the arguments of \"\\subcaption\" incl. a label and insert them.
+If OPTIONAL is non-nil, indicate it while reading the caption.
 If STAR is non-nil, then do not query for a \\label and a short
 caption, insert only a caption."
   (let* (;; \subcaption needs an environment, "minipage" will be
@@ -79,6 +79,7 @@ caption, insert only a caption."
 
 (defun LaTeX-arg-subcaption-subcaptionbox (optional &optional star)
   "Query for the arguments of \"\\subcaptionbox\" incl. a label and insert 
them.
+If OPTIONAL is non-nil, indicate it while reading the caption.
 If STAR is non-nil, then do not query for a \\label and a short
 caption, insert only a caption."
   (let* ((currenv (LaTeX-current-environment))
@@ -117,17 +118,13 @@ caption, insert only a caption."
    ;; Run style hook for caption.el
    (TeX-run-style-hooks "caption")
 
-   ;; Make "subrefformat" available in key-vals of caption.el:
-   (setq LaTeX-caption-key-val-options-local
-         (append LaTeX-subcaption-key-val-options
-                 LaTeX-caption-key-val-options-local))
 
    (TeX-add-symbols
     ;; Basic commands
     '("subcaption"     (LaTeX-arg-subcaption-subcaption))
-    '("subcaption*"    (LaTeX-arg-subcaption-subcaption t))
+    '("subcaption*"    (LaTeX-arg-subcaption-subcaption     t)  )
     '("subcaptionbox"  (LaTeX-arg-subcaption-subcaptionbox) t)
-    '("subcaptionbox*" (LaTeX-arg-subcaption-subcaptionbox t) t)
+    '("subcaptionbox*" (LaTeX-arg-subcaption-subcaptionbox  t) t)
     '("subref"         TeX-arg-ref)
     ;; \subref* is only available with hyperref.sty loaded, we don't
     ;; check if hyperref.el is loaded and make it available directly.
diff --git a/style/tabulary.el b/style/tabulary.el
index be4b114..6b309e0 100644
--- a/style/tabulary.el
+++ b/style/tabulary.el
@@ -1,6 +1,6 @@
 ;;; tabulary.el --- AUCTeX style for the tabulary package.  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013-2016, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016, 2020, 2021 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <mje@inducks.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -42,10 +42,13 @@
  (lambda ()
    ;; Make tabulary the default tabular environment
    (setq LaTeX-default-tabular-environment "tabulary")
+
    ;; Use the enhanced tabular indentation.  Append to
-   ;; `LaTeX-indent-environment-list' in order not to override custom settings.
+   ;; `LaTeX-indent-environment-list' in order not to override custom
+   ;; settings.
    (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
-                '("tabulary" LaTeX-indent-tabular))
+                '("tabulary" LaTeX-indent-tabular)
+                t)
 
    ;; Append tabulary to `LaTeX-item-list' with `LaTeX-item-tabular*'
    (add-to-list 'LaTeX-item-list '("tabulary" . LaTeX-item-tabular*) t)
diff --git a/style/tcolorbox.el b/style/tcolorbox.el
index c7e7051..5ba44bb 100644
--- a/style/tcolorbox.el
+++ b/style/tcolorbox.el
@@ -1,6 +1,6 @@
 ;;; tcolorbox.el --- AUCTeX style for `tcolorbox.sty' (v4.00)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015, 2016, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 ;; Author: Tassilo Horn <tsdh@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -34,9 +34,10 @@
 ;; file is prefixed with `tcolorboxlib-',
 ;; e.g. `tcolorboxlib-raster.el'.
 
-;; Libraries should also append their key=val option to variable
-;; `LaTeX-tcolorbox-keyval-options-full'.  This variable is called
-;; with macro `\tcbset'.
+;; Libraries should also prepend a symbol containing their key=val
+;; options to the variable `LaTeX-tcolorbox-keyval-options-full'.
+;; This variable is used by the function of the same name called when
+;; inserting `\tcbset' macro.
 
 ;;; Code:
 
@@ -343,14 +344,46 @@
     ("no recording"))
   "Key=value options for tcolorbox macros and environments.")
 
-(defvar LaTeX-tcolorbox-keyval-options-local nil
-   "Buffer-local key=value options for tcolorbox macros and environments.")
-(make-variable-buffer-local 'LaTeX-tcolorbox-keyval-options-local)
-
-(defvar LaTeX-tcolorbox-keyval-options-full nil
-  "Key=value options of tcolorbox core and all loaded libraries.")
+(defun LaTeX-tcolorbox-keyval-options ()
+  "Return an updated list of key=vals from tcolorbox package."
+  (append
+   ;; This style runs `xcolor.el', so we use
+   ;; `LaTeX-xcolor-definecolor-list' right away:
+   (let ((colors (mapcar #'car (LaTeX-xcolor-definecolor-list)))
+         (keys '("colframe"
+                 "colback"
+                 "colbacktitle"
+                 "colupper"
+                 "collower"
+                 "coltext"
+                 "coltitle"))
+         result)
+     (dolist (key keys result)
+       (cl-pushnew (list key colors) result :test #'equal)))
+   LaTeX-tcolorbox-keyval-options))
+
+(defvar LaTeX-tcolorbox-keyval-options-full
+  '(LaTeX-tcolorbox-keyval-options)
+  "Buffer-local list of symbols containing key=val options.
+tcolorbox libraries should add their key=val options to this
+list.  Key=val options might be a variable or a function.  This
+variable is initialized with the function
+`LaTeX-tcolorbox-keyval-options'.  Please add entries on top of
+this list so that this item always comes last.")
 (make-variable-buffer-local 'LaTeX-tcolorbox-keyval-options-full)
 
+(defun LaTeX-tcolorbox-keyval-options-full ()
+  "Return an updated list of full key=vals for tcolorbox and libraries.
+Each symbol is a variable or a function.  If a symbol name
+contains a function and a variable value, the function is
+preferred.  This function processes symbols in the variable
+`LaTeX-tcolorbox-keyval-options-full'."
+  (let (result)
+    (dolist (elt (reverse LaTeX-tcolorbox-keyval-options-full) result)
+      (if (functionp elt)
+          (setq result (append (funcall elt) result))
+        (setq result (append (symbol-value elt) result))))))
+
 (defvar LaTeX-tcolorbox-tcbox-options
   '(;; 4.20 \tcbox Specials
     ("tcbox raise")
@@ -437,7 +470,8 @@
   "Matches the arguments of \\newtcbox from tcolorbox package.")
 
 ;; Setup for \tcbuselibrary:
-(TeX-auto-add-type "tcolorbox-tcbuselibrary" "LaTeX" "tcbuselibraries")
+(TeX-auto-add-type "tcolorbox-tcbuselibrary"
+                   "LaTeX" "tcolorbox-tcbuselibraries")
 
 (defvar LaTeX-tcolorbox-tcbuselibrary-regexp
   '("\\\\tcbuselibrary{\\([^}]+\\)}"
@@ -450,7 +484,7 @@ This functions checks the arguments of \\tcbuselibrary and 
the
 name of libraries given in the optional argument of \\usepackage
 call for tcolorbox and runs the style hook for them.  The file
 for style must have the prefix \"tcolorboxlib-\" in the name,
-e.g. \"tcolorboxlib-raster.el\"."
+for example \"tcolorboxlib-raster.el\"."
   (when (LaTeX-tcolorbox-tcbuselibrary-list)
     (let (libs)
       (dolist (x (LaTeX-tcolorbox-tcbuselibrary-list))
@@ -464,25 +498,6 @@ e.g. \"tcolorboxlib-raster.el\"."
         (when (member x LaTeX-tcolorbox-library-list)
           (TeX-run-style-hooks (concat "tcolorboxlib-" x)))))))
 
-(defun LaTeX-tcolorbox-update-style-key ()
-  "Update some key=values in `LaTeX-tcolorbox-keyval-options-local'."
-  ;; Update the key=values for coloring.
-  (let* ((keys '("colframe"
-                 "colback"
-                 "colbacktitle"
-                 "colupper"
-                 "collower"
-                 "coltext"
-                 "coltitle"))
-         (tmp (copy-alist LaTeX-tcolorbox-keyval-options-local)))
-    (dolist (key keys)
-      (setq tmp (assq-delete-all (car (assoc key tmp)) tmp))
-      (cl-pushnew
-       (list key (mapcar #'car (LaTeX-xcolor-definecolor-list))) tmp :test 
#'equal))
-    (setq LaTeX-tcolorbox-keyval-options-local (copy-alist tmp)))
-  (setq LaTeX-tcolorbox-keyval-options-full
-        (copy-alist LaTeX-tcolorbox-keyval-options-local)))
-
 (defun LaTeX-tcolorbox-auto-prepare ()
   "Clear various LaTeX-tcolorbox-* variables before parsing."
   (setq LaTeX-auto-tcolorbox-newtcolorbox  nil
@@ -511,7 +526,7 @@ e.g. \"tcolorboxlib-raster.el\"."
              (LaTeX-add-environments
               (list box
                     #'LaTeX-env-args
-                    [TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local]
+                    [TeX-arg-key-val (LaTeX-tcolorbox-keyval-options)]
                     (1- (string-to-number arg)))))
             (;; mandatory argument(s) only
              (and arg (not (string= arg ""))
@@ -539,8 +554,8 @@ e.g. \"tcolorboxlib-raster.el\"."
              (and arg (not (string= arg ""))
                   opt (not (string= opt  "")))
              (TeX-add-symbols (list box
-                               [TeX-arg-key-val 
LaTeX-tcolorbox-keyval-options-local]
-                               (1- (string-to-number arg)))))
+                                    [TeX-arg-key-val 
(LaTeX-tcolorbox-keyval-options)]
+                                    (1- (string-to-number arg)))))
             (;; mandatory argument(s) only
              (and arg (not (string= arg ""))
                   (string-equal opt ""))
@@ -548,9 +563,6 @@ e.g. \"tcolorboxlib-raster.el\"."
             (t ; No args -- in pratice, this will probably never happen
              (TeX-add-symbols (list box))))))
   ;;
-  ;; Update key=vals
-  (LaTeX-tcolorbox-update-style-key)
-  ;;
   ;; Load style hooks for libraries, if any.
   (LaTeX-tcolorbox-load-used-libraries))
 
@@ -562,15 +574,6 @@ e.g. \"tcolorboxlib-raster.el\"."
  "tcolorbox"
  (lambda ()
 
-   ;; Activate the buffer-local version of key-vals.
-   (setq LaTeX-tcolorbox-keyval-options-local
-         (copy-alist LaTeX-tcolorbox-keyval-options))
-
-   ;; Collect key=val's from libraries in
-   ;; `LaTeX-tcolorbox-keyval-options-full'; \tcbset needs this:
-   (setq LaTeX-tcolorbox-keyval-options-full
-         (copy-alist LaTeX-tcolorbox-keyval-options-local))
-
    ;; Add tcolorbox to the parser.
    (TeX-auto-add-regexp LaTeX-tcolorbox-newtcolorbox-regexp)
    (TeX-auto-add-regexp LaTeX-tcolorbox-newtcbox-regexp)
@@ -584,32 +587,38 @@ e.g. \"tcolorboxlib-raster.el\"."
 
     ;; 1.3 Libraries
     '("tcbuselibrary"
-      (TeX-arg-eval mapconcat #'identity
-                    (TeX-completing-read-multiple
-                     (TeX-argument-prompt nil nil "Libraries")
-                     LaTeX-tcolorbox-library-list) ","))
+      (TeX-arg-eval
+       (lambda ()
+         (let ((libs (mapconcat #'identity
+                                (TeX-completing-read-multiple
+                                 (TeX-argument-prompt nil nil "Libraries")
+                                 LaTeX-tcolorbox-library-list)
+                                ",")))
+           (LaTeX-add-tcolorbox-tcbuselibraries libs)
+           (LaTeX-tcolorbox-load-used-libraries)
+           (format "%s" libs)))))
 
     ;; 3 Macros for Box Creation
     '("tcblower" 0)
 
     '("tcbset"
-      (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-full))
+      (TeX-arg-key-val (LaTeX-tcolorbox-keyval-options-full)))
 
     '("tcbsetforeverylayer"
-      (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
+      (TeX-arg-key-val (LaTeX-tcolorbox-keyval-options)))
 
     '("tcbox"
-      [ TeX-arg-eval TeX-read-key-val t
-        (append
-         LaTeX-tcolorbox-tcbox-options
-         LaTeX-tcolorbox-keyval-options-local) ]
+      [TeX-arg-eval TeX-read-key-val t
+                    (append
+                     LaTeX-tcolorbox-tcbox-options
+                     (LaTeX-tcolorbox-keyval-options))]
       t)
 
     '("newtcolorbox"
       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
       "Name"
       [ TeX-arg-define-macro-arguments ]
-      (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
+      (TeX-arg-key-val (LaTeX-tcolorbox-keyval-options)))
 
     '("renewtcolorbox"
       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
@@ -617,13 +626,13 @@ e.g. \"tcolorboxlib-raster.el\"."
                     (TeX-argument-prompt nil nil "Color box")
                     (LaTeX-tcolorbox-newtcolorbox-list))
       [ TeX-arg-define-macro-arguments ]
-      (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
+      (TeX-arg-key-val (LaTeX-tcolorbox-keyval-options)))
 
     '("newtcbox"
       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
       TeX-arg-macro
       [ TeX-arg-define-macro-arguments ]
-      (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
+      (TeX-arg-key-val (LaTeX-tcolorbox-keyval-options)))
 
     '("renewtcbox"
       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
@@ -634,11 +643,11 @@ e.g. \"tcolorboxlib-raster.el\"."
                        (LaTeX-tcolorbox-newtcbox-list))))
            (concat TeX-esc macro))))
       [ TeX-arg-define-macro-arguments ]
-      (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
+      (TeX-arg-key-val (LaTeX-tcolorbox-keyval-options)))
 
     '("tcolorboxenvironment"
       TeX-arg-environment
-      (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
+      (TeX-arg-key-val (LaTeX-tcolorbox-keyval-options)))
 
     ;; 4.16 Layered Boxes and Every Box Settings
     '("tcbsetmanagedlayer" "Number")
@@ -670,7 +679,7 @@ e.g. \"tcolorboxlib-raster.el\"."
    (LaTeX-add-environments
     ;; 3 Macros for Box Creation: Main env
     '("tcolorbox" LaTeX-env-args
-      [ TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local ])
+      [ TeX-arg-key-val (LaTeX-tcolorbox-keyval-options) ])
 
     ;; 7 Saving and Loading of Verbatim Texts
     '("tcbverbatimwrite" "File name")
diff --git a/style/tcolorboxlib-raster.el b/style/tcolorboxlib-raster.el
index 912f3c2..db61a03 100644
--- a/style/tcolorboxlib-raster.el
+++ b/style/tcolorboxlib-raster.el
@@ -1,6 +1,6 @@
 ;;; tcolorboxlib-raster.el --- AUCTeX style for `raster' library from 
tcolorbox  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -36,8 +36,7 @@
 (declare-function font-latex-add-keywords
                   "font-latex"
                   (keywords class))
-
-(defvar LaTeX-tcolorbox-keyval-options-local)
+(declare-function LaTeX-tcolorbox-keyval-options "tcolorbox" ())
 (defvar LaTeX-tcolorbox-keyval-options-full)
 
 (defvar LaTeX-tcolorbox-lib-raster-keyval-options
@@ -91,11 +90,11 @@
    environment
    (let ((opts (TeX-read-key-val t (append
                                     LaTeX-tcolorbox-lib-raster-keyval-options
-                                    LaTeX-tcolorbox-keyval-options-local)
+                                    (LaTeX-tcolorbox-keyval-options))
                                  (when (string= environment "tcboxeditemize")
                                    "Raster options (k=v)")))
          (box-opts (when (string= environment "tcboxeditemize")
-                     (TeX-read-key-val nil LaTeX-tcolorbox-keyval-options-local
+                     (TeX-read-key-val nil (LaTeX-tcolorbox-keyval-options)
                                        "Box options (k=v)"))))
      (concat
       (when (and opts (not (string= opts "")))
@@ -134,15 +133,14 @@
  "tcolorboxlib-raster"
  (lambda ()
 
-   ;; Append key-vals from library to `LaTeX-tcolorbox-keyval-options-full':
-   (setq LaTeX-tcolorbox-keyval-options-full
-         (append LaTeX-tcolorbox-lib-raster-keyval-options
-                 LaTeX-tcolorbox-keyval-options-full))
+   ;; Register key-vals from library to `LaTeX-tcolorbox-keyval-options-full':
+   (add-to-list 'LaTeX-tcolorbox-keyval-options-full
+                'LaTeX-tcolorbox-lib-raster-keyval-options)
 
    (TeX-add-symbols
     ;; 14.2 Macros of the Library
     '("tcbitem"
-      [ TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local "Item options 
(k=v)" ]
+      [TeX-arg-key-val (LaTeX-tcolorbox-keyval-options) "Item options (k=v)" ]
       (TeX-arg-literal " ")))
 
    (LaTeX-add-environments
@@ -154,7 +152,7 @@
          (let ((raster-opts
                 (TeX-read-key-val t (append
                                      LaTeX-tcolorbox-lib-raster-keyval-options
-                                     LaTeX-tcolorbox-keyval-options-local))))
+                                     (LaTeX-tcolorbox-keyval-options)))))
            (when (and raster-opts (not (string= raster-opts "")))
              (concat LaTeX-optop raster-opts LaTeX-optcl))))))
 
@@ -167,10 +165,10 @@
          (let ((raster-opts
                 (TeX-read-key-val t (append
                                      LaTeX-tcolorbox-lib-raster-keyval-options
-                                     LaTeX-tcolorbox-keyval-options-local)
+                                     (LaTeX-tcolorbox-keyval-options))
                                   "Raster options (k=v)"))
                (box-opts
-                (TeX-read-key-val nil LaTeX-tcolorbox-keyval-options-local
+                (TeX-read-key-val nil (LaTeX-tcolorbox-keyval-options)
                                   "Box options (k=v)")))
            (concat
             (when (and raster-opts (not (string= raster-opts "")))
diff --git a/style/tex-live.el b/style/tex-live.el
index abddbe8..b74890d 100644
--- a/style/tex-live.el
+++ b/style/tex-live.el
@@ -1,6 +1,6 @@
 ;;; tex-live.el --- AUCTeX style for `tex-live.sty'  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2020--2021 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -42,6 +42,7 @@
 (declare-function LaTeX-add-fancyvrb-environments
                   "fancyvrb"
                   (&rest fancyvrb-environments))
+(declare-function LaTeX-fancyvrb-key-val-options "fancyvrb" ())
 
 (declare-function font-latex-add-keywords
                   "font-latex"
@@ -84,7 +85,7 @@
     '("listinginput"
       (TeX-arg-eval completing-read
                     (TeX-argument-prompt nil nil "Value of firstnumber key")
-                    (cadr (assoc "firstnumber" 
LaTeX-fancyvrb-key-val-options-local)))
+                    (cadr (assoc "firstnumber" 
(LaTeX-fancyvrb-key-val-options))))
       LaTeX-fancyvrb-arg-file-relative)
 
     ;; Various sorts of names:
diff --git a/style/theorem.el b/style/theorem.el
index d844129..219e864 100644
--- a/style/theorem.el
+++ b/style/theorem.el
@@ -63,10 +63,10 @@
     "Large" "LARGE" "huge" "Huge"
     ;; reset macro
     "normalfont")
-  "List of font declaration commands for \"\\theorem(body\|header)font\".")
+  "List of font declaration commands for \"\\theorem(body|header)font\".")
 
 (defun LaTeX-arg-theorem-fontdecl (optional &optional prompt)
-  "Prompt for font declaration commands in \"\\theorem(body\|header)font\".
+  "Prompt for font declaration commands in \"\\theorem(body|header)font\".
 If OPTIONAL is non-nil, insert the resulting value as an optional
 argument.  Use PROMPT as the prompt string."
   ;; `INITIAL-INPUT' (5th argument to `TeX-completing-read-multiple')
@@ -87,7 +87,7 @@ for label.  AUCTeX users should add ENVIRONMENT to
   (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
 
 RefTeX users should customize or add ENVIRONMENT to
-`LaTeX-label-alist' and `reftex-label-alist', e.g.
+`LaTeX-label-alist' and `reftex-label-alist', for example
 
   (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
   (add-to-list \\='reftex-label-alist
diff --git a/style/thmtools.el b/style/thmtools.el
index d9ccf19..d17b30e 100644
--- a/style/thmtools.el
+++ b/style/thmtools.el
@@ -225,7 +225,7 @@ customize or in init-file with:
   (add-to-list \\='LaTeX-label-alist \\='(\"theorem\" . \"thm:\"))
 
 RefTeX users should customize or add ENVIRONMENT to
-`LaTeX-label-alist' and `reftex-label-alist', e.g.
+`LaTeX-label-alist' and `reftex-label-alist', for example
 
   (add-to-list \\='LaTeX-label-alist \\='(\"theorem\" . \"thm:\"))
   (add-to-list \\='reftex-label-alist
diff --git a/style/unicodefonttable.el b/style/unicodefonttable.el
new file mode 100644
index 0000000..3253df1
--- /dev/null
+++ b/style/unicodefonttable.el
@@ -0,0 +1,134 @@
+;;; unicodefonttable.el --- AUCTeX style for `unicodefonttable.sty'  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-10-23
+;; 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 Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
+
+;;; Commentary:
+
+;; This file adds support for `unicodefonttable.sty' v1.0f form
+;; 2021-10-29.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+(declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
+
+(defvar LaTeX-unicodefonttable-key-val-options
+  '(("header"          ("true" "false"))
+    ("noheader"        ("true" "false"))
+    ("title-format")
+    ("title-format-cont")
+    ("display-block"   ("titles" "rules" "none"))
+    ("hex-digits"      ("block" "foot" "head" "head+foot" "none"))
+    ("hex-digits-font" ("\\rmfamily" "\\sffamily"   "\\ttfamily"
+                        "\\mdseries" "\\bfseries"   "\\upshape"
+                        "\\itshape"  "\\slshape"    "\\scshape"
+                        "\\tiny"     "\\scriptsize" "\\footnotesize"
+                        "\\small"    "\\normalsize" "\\large"
+                        "\\Large"    "\\LARGE"  "\\huge" "\\Huge"
+                        "\\normalfont"))
+    ("color")
+    ("statistics"      ("true" "false"))
+    ("nostatistics"    ("true" "false"))
+    ("statistics-font" ("\\rmfamily" "\\sffamily"   "\\ttfamily"
+                        "\\mdseries" "\\bfseries"   "\\upshape"
+                        "\\itshape"  "\\slshape"    "\\scshape"
+                        "\\tiny"     "\\scriptsize" "\\footnotesize"
+                        "\\small"    "\\normalsize" "\\large"
+                        "\\Large"    "\\LARGE"  "\\huge" "\\Huge"
+                        "\\normalfont"))
+    ("statistics-format")
+    ("glyph-width")
+    ("missing-glyph")
+    ("missing-glyph-font" ("\\rmfamily" "\\sffamily"   "\\ttfamily"
+                           "\\mdseries" "\\bfseries"   "\\upshape"
+                           "\\itshape"  "\\slshape"    "\\scshape"
+                           "\\tiny"     "\\scriptsize" "\\footnotesize"
+                           "\\small"    "\\normalsize" "\\large"
+                           "\\Large"    "\\LARGE"  "\\huge" "\\Huge"
+                           "\\normalfont"))
+    ("missing-glyph-color")
+    ("compare-with")
+    ("compare-color")
+    ("compare-bgcolor")
+    ("statistics-compare-format")
+    ("range-start")
+    ("range-end"))
+  "Key=value options for unicodefonttable macros.")
+
+(defun LaTeX-unicodefonttable-key-val-options ()
+  "Return an updated list of key=vals from unicodefonttable package."
+  (append
+   (let ((colors (mapcar #'car (LaTeX-xcolor-definecolor-list)))
+         (keys '("color"
+                 "missing-glyph-color"
+                 "compare-color"
+                 "compare-bgcolor"))
+         result)
+     (dolist (key keys result)
+       (push (list key colors) result)))
+   LaTeX-unicodefonttable-key-val-options))
+
+(TeX-add-style-hook
+ "unicodefonttable"
+ (lambda ()
+
+   (TeX-run-style-hooks "fontspec" "xcolor" "caption"
+                        "longtable" "booktabs")
+
+   (TeX-add-symbols
+    '("displayfonttable"
+      [TeX-arg-key-val (LaTeX-unicodefonttable-key-val-options)]
+      LaTeX-fontspec-arg-font
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
+
+    '("displayfonttable*"
+      [TeX-arg-key-val (LaTeX-unicodefonttable-key-val-options)]
+      LaTeX-fontspec-arg-font
+      [TeX-arg-key-val (LaTeX-fontspec-font-features) "Font features"])
+
+    '("fonttablesetup"
+      (TeX-arg-key-val (LaTeX-unicodefonttable-key-val-options)))
+
+    "fonttableglyphcount")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("displayfonttable"     "[{[")
+                                ("displayfonttable*"    "[{[")
+                                ("fonttableglyphcount"   ""))
+                              'function)))
+ TeX-dialect)
+
+(defvar LaTeX-unicodefonttable-package-options nil
+  "Package options for the unicodefonttable package.")
+
+;;; unicodefonttable.el ends here
diff --git a/style/url.el b/style/url.el
index eafbd90..af524bf 100644
--- a/style/url.el
+++ b/style/url.el
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `url.sty'.
+;; This file adds support for `url.sty' v3.4 dated 2013-09-16.
 
 ;;; Code:
 
@@ -41,11 +41,131 @@
 (declare-function font-latex-set-syntactic-keywords
                   "font-latex")
 
+;; Setup for \DeclareUrlCommand:
+(TeX-auto-add-type "url-DeclareUrlCommand" "LaTeX")
+
+(defvar LaTeX-url-DeclareUrlCommand-regexp
+  `(,(concat
+      "\\\\DeclareUrlCommand"
+      "[ \n\r\t]*"
+      "{?"
+      "\\\\\\([a-zA-Z]+\\)"
+      "}?")
+    1 LaTeX-auto-url-DeclareUrlCommand)
+  "Matches the argument of `\\DeclareUrlCommand' from `url' package.")
+
+(defun LaTeX-url-DeclareUrlCommand-prepare ()
+  "Process macros parsed from `\\DeclareUrlCommand'."
+  ;; \DeclareUrlCommand\abc{settings}: makes \abc{ } like \url{ } with
+  ;; settings.
+  (when (LaTeX-url-DeclareUrlCommand-list)
+    (dolist (cmd (mapcar #'car (LaTeX-url-DeclareUrlCommand-list)))
+      (TeX-add-symbols `(,cmd TeX-arg-verb-delim-or-brace))
+      (add-to-list 'LaTeX-verbatim-macros-with-delims-local cmd)
+      (add-to-list 'LaTeX-verbatim-macros-with-braces-local cmd))
+    ;; Fontification
+    (when (and (fboundp 'font-latex-add-keywords)
+               (fboundp 'font-latex-set-syntactic-keywords)
+               (eq TeX-install-font-lock 'font-latex-setup))
+      (font-latex-add-keywords
+       (mapcar (lambda (cmd)
+                 (list cmd  ""))
+               (mapcar #'car (LaTeX-url-DeclareUrlCommand-list)))
+       'reference)
+      ;; Tell font-lock about the update.
+      (font-latex-set-syntactic-keywords))))
+
+;; Setup for \urldef:
+(TeX-auto-add-type "url-urldef" "LaTeX")
+
+(defvar LaTeX-url-urldef-regexp
+  `(,(concat
+      "\\\\urldef"
+      "[ \n\r\t]*"
+      "{?"
+      "\\\\\\([a-zA-Z]+\\)"
+      "}?")
+    1 LaTeX-auto-url-urldef)
+  "Matches the argument of `\\urldef' from `url' package.")
+
+(defun LaTeX-url-urldef-prepare ()
+  "Process macros parsed from `\\urldef'."
+  (when (LaTeX-url-urldef-list)
+    (mapc #'TeX-add-symbols (mapcar #'car (LaTeX-url-urldef-list)))
+    ;; Fontification
+    (when (and (fboundp 'font-latex-add-keywords)
+               (eq TeX-install-font-lock 'font-latex-setup))
+      (font-latex-add-keywords
+       (mapcar (lambda (cmd)
+                 (list cmd ""))
+               (mapcar #'car (LaTeX-url-urldef-list)))
+       'reference))))
+
+(defun LaTeX-url-auto-prepare ()
+  "Clear `LaTeX-auto-url-*' before parsing."
+  (setq LaTeX-auto-url-DeclareUrlCommand nil
+        LaTeX-auto-url-urldef            nil))
+
+(defun LaTeX-url-auto-cleanup ()
+  "Process parsed elements from url.sty."
+  (LaTeX-url-DeclareUrlCommand-prepare)
+  (LaTeX-url-urldef-prepare))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-url-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-url-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun TeX-arg-url-urlstyle (optional &optional prompt)
+  "Prompt for style used in \\urlstyle with completion.
+If OPTIONAL is non-nil, indicate it in the minibuffer during the
+query and insert the result in brackets.  PROMPT replaces the
+standard one."
+  (TeX-argument-insert
+   (completing-read (TeX-argument-prompt optional prompt "Style")
+                    '("rm" "same" "sf" "tt"))
+   optional))
+
+(defun TeX-arg-url-DeclareUrlCommand (optional &optional prompt)
+  "Prompt for arguments of \\DeclareUrlCommand with completion.
+If OPTIONAL is non-nil, indicate it in the minibuffer during the
+query and insert the result in brackets.  PROMPT replaces the
+standard one."
+  (let ((cmd (TeX-read-string
+              (TeX-argument-prompt optional prompt "Command: \\" t)))
+        (style (completing-read
+                (TeX-argument-prompt optional prompt "Style")
+                '("rm" "same" "sf" "tt"))))
+    (insert TeX-esc cmd TeX-grop)
+    (when (and style (not (string= style "")))
+      (insert TeX-esc "urlstyle" TeX-grop style TeX-grcl))
+    (insert TeX-grcl)
+    (LaTeX-add-url-DeclareUrlCommands cmd)
+    (LaTeX-url-DeclareUrlCommand-prepare)))
+
+(defun TeX-arg-url-urldef (optional &optional prompt)
+  "Prompt for arguments of \\urldef with completion."
+  (let ((cmd (TeX-read-string
+              (TeX-argument-prompt optional prompt "Command: \\" t))))
+    (TeX-argument-insert cmd optional TeX-esc)
+    (LaTeX-add-url-urldefs cmd)
+    (LaTeX-url-urldef-prepare))
+  (TeX-insert-macro
+   (completing-read
+    (TeX-argument-prompt optional prompt "Macro: \\" t)
+    (append (mapcar #'car (LaTeX-url-DeclareUrlCommand-list))
+            '("url")))))
+
 (TeX-add-style-hook
  "url"
  (lambda ()
+
+   ;; Add url to the parser
+   (TeX-auto-add-regexp LaTeX-url-DeclareUrlCommand-regexp)
+   (TeX-auto-add-regexp LaTeX-url-urldef-regexp)
+
    ;; New symbols
    (TeX-add-symbols
+    ;; Macros for defining new styles, changing font, linebreaks etc.
     "Url"
     "UrlBigBreakPenalty"
     "UrlBigBreaks"
@@ -57,56 +177,49 @@
     "UrlOrds"
     "UrlRight"
     "UrlSpecials"
-    '("path" (TeX-arg-verb-delim-or-brace "Path"))
+
     ;; "hyperref" redefines \url so that the argument is only in
     ;; braces.  We check here if hyperref is loaded:
     '("url" (TeX-arg-conditional (member "hyperref" (TeX-style-list))
                                  ("Url")
                                  ((TeX-arg-verb-delim-or-brace "Url"))))
-    "urldef"
-    '("urlstyle" TeX-arg-urlstyle))
 
-   (add-to-list 'LaTeX-verbatim-macros-with-delims-local "path")
-   ;; hyperref.el has some code to remove "url" from
-   ;; `LaTeX-verbatim-macros-with-delims-local', but we check here as
-   ;; well if "hyperref" is already loaded:
+    '("urldef" TeX-arg-url-urldef)
+
+    '("urlstyle" TeX-arg-url-urlstyle))
+
+   ;; For '\path', use the facilities provided by this style.  Also
+   ;; don't add "path" for fontification below since
+   ;; `LaTeX-url-DeclareUrlCommand-prepare' takes care of it.
+   (LaTeX-add-url-DeclareUrlCommands "path")
+   (LaTeX-url-DeclareUrlCommand-prepare)
+
+   ;; Don't do the same for '\url' because hyperref.el has some code
+   ;; to remove "url" from `LaTeX-verbatim-macros-with-delims-local',
+   ;; but we check here as well if "hyperref" is already loaded:
    (unless (member "hyperref" (TeX-style-list))
      (add-to-list 'LaTeX-verbatim-macros-with-delims-local "url"))
-   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "path")
    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "url")
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
               (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("path" "") ("url" "")) 'reference)
-     (font-latex-add-keywords '(("Url" "")
-                                ("UrlBigBreakPenalty" "")
-                                ("UrlBigBreaks" "")
-                                ("UrlBreakPenalty" "")
-                                ("UrlBreaks" "")
-                                ("UrlFont" "")
-                                ("UrlLeft" "")
-                                ("UrlNoBreaks" "")
-                                ("UrlOrds" "")
-                                ("UrlRight" "")
-                                ("UrlSpecials" "")
-                                ("urldef" "")
-                                ("urlstyle" "{"))
-                              'variable)
+     (font-latex-add-keywords '(("url" ""))
+                              'reference)
+     ;; Don't fontify the second argument of 'DeclareUrlCommand' since
+     ;; it gets the `font-latex-verbatim-face' from the first
+     ;; argument.  Same applies also to '\urldef' where we don't
+     ;; fontify any arguments:
+     (font-latex-add-keywords '(("DeclareUrlCommand" "\\")
+                                ("urldef"            "")
+                                ("urlstyle"          "{"))
+                              'function)
      ;; Tell font-lock about the update.
      (font-latex-set-syntactic-keywords)))
  TeX-dialect)
 
-(defun TeX-arg-urlstyle (optional &optional prompt)
-  "Prompt for style used in \\urlstyle with completion."
-  (TeX-argument-insert
-   (completing-read (TeX-argument-prompt optional prompt "Style")
-                    '("rm" "same" "sf" "tt")
-                    nil t)
-   optional))
-
-(defvar LaTeX-url-package-options '("hyphens" "obeyspaces" "spaces" "LY1"
-                                    "T1" "allowmove")
+(defvar LaTeX-url-package-options '("hyphens" "obeyspaces" "spaces"
+                                    "allowmove" "lowtilde")
   "Package options for the url package.")
 
 ;;; url.el ends here
diff --git a/style/xparse.el b/style/xparse.el
index 2a9dff4..fd9bb32 100644
--- a/style/xparse.el
+++ b/style/xparse.el
@@ -1,6 +1,6 @@
 ;;; xparse.el --- AUCTeX style for `xparse.sty' version 2020-03-06  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2020, 2021 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano <mose@gnu.org>
@@ -28,10 +28,8 @@
 ;; This file adds basic support for `xparse.sty' version 2020-03-06.
 ;; It parses argument specification of macros and environments.
 
-;; Currently, this style doesn't parse the embellishments specifiers
-;; `e' and `E'.  The "yet not more supported" specifiers `l', `u', `g'
-;; and `G' are ignored completely and may lead to wrong parsing
-;; results.
+;; The "yet not more supported" specifiers `l', `u', `g' and `G' are
+;; ignored completely and may lead to wrong parsing results.
 
 ;;; Code:
 
@@ -48,7 +46,7 @@
 (defvar LaTeX-xparse-macro-regexp
   `(,(concat
       (regexp-quote TeX-esc)
-      "\\(?:New\\|Renew\\|Provide\\|Declare\\)"
+      "\\(New\\|Renew\\|Provide\\|Declare\\)"
       "\\(?:Expandable\\)?"
       "DocumentCommand"
       "[ \t\n\r]*"
@@ -60,7 +58,7 @@
       "}?"
       "[ \t\n\r]*"
       
"{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*}[^}{]*\\)*}[^}{]*\\)*\\)}")
-    (1 2) LaTeX-auto-xparse-macro)
+    (0 2 3 1) LaTeX-auto-xparse-macro)
   "Matches macros by xparse package.")
 
 (TeX-auto-add-type "xparse-environment" "LaTeX")
@@ -68,7 +66,7 @@
 (defvar LaTeX-xparse-environment-regexp
   `(,(concat
       (regexp-quote TeX-esc)
-      "\\(?:New\\|Renew\\|Provide\\|Declare\\)"
+      "\\(New\\|Renew\\|Provide\\|Declare\\)"
       "DocumentEnvironment"
       "[ \t\n\r]*"
       "{"
@@ -78,7 +76,7 @@
       "}"
       "[ \t\n\r]*"
       
"{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*}[^}{]*\\)*}[^}{]*\\)*\\)}")
-    (1 2) LaTeX-auto-xparse-environment)
+    (0 2 3 1) LaTeX-auto-xparse-environment)
   "Matches environments by xparse package.")
 
 (defun LaTeX-arg-xparse-query (optional op-brace cl-brace &optional prompt)
@@ -92,14 +90,27 @@ replaces the standard one."
      (TeX-read-string (TeX-argument-prompt optional prompt "Text"))
      optional)))
 
+(defun LaTeX-arg-xparse-embellishment-query (_optional embellish)
+  "Special insert function for embellishments from xparse package.
+Compatibility argument OPTIONAL is ignored.  EMBELLISH is a
+string with parsed elements inserted in the buffer.  This
+function also sets the value of `TeX-exit-mark' where the point
+will be once the insertion is completed."
+  (let (p)
+    (just-one-space)
+    (setq p (point))
+    (insert embellish)
+    (set-marker TeX-exit-mark (1+ p))))
+
 (defun LaTeX-xparse-macro-parse (type)
   "Process parsed macro and environment definitions.
-TYPE is one of the symobols mac or env."
+TYPE is one of the symbols mac or env."
   (dolist (xcmd (if (eq type 'mac)
                     (LaTeX-xparse-macro-list)
                   (LaTeX-xparse-environment-list)))
-    (let ((name (car xcmd))
-          (spec (cadr xcmd))
+    (let ((name (nth 1 xcmd))
+          (spec (nth 2 xcmd))
+          (what (nth 3 xcmd))
           args opt-star opt-token)
       (with-temp-buffer
         (set-syntax-table LaTeX-mode-syntax-table)
@@ -175,37 +186,68 @@ TYPE is one of the symobols mac or env."
                 ((looking-at-p "t")
                  (re-search-forward "t\\(.\\)" (+ (point) 2) t)
                  (setq opt-token (match-string-no-properties 1)))
-                ;; e & E are currently ignored.  e: If looking at a
-                ;; {, move one balanced expression, otherwise only
-                ;; one character.
+                ;; e{tokes} a set of optional embellishments
                 ((looking-at-p "e")
                  (forward-char)
                  (if (looking-at-p TeX-grop)
-                     (forward-sexp)
-                   (forward-char)))
-                ;; E
+                     (re-search-forward "{\\([^}]+\\)}" nil t)
+                   (re-search-forward "\\(.\\)" (1+ (point)) t))
+                 (push `(LaTeX-arg-xparse-embellishment-query
+                         ,(match-string-no-properties 1))
+                       args))
+                ;; E{tokes}{defaults}
                 ((looking-at-p "E")
                  (forward-char)
                  (if (looking-at-p TeX-grop)
-                     (forward-sexp)
-                   (forward-char))
-                 (if (looking-at-p TeX-grop)
-                     (forward-sexp)
-                   (forward-char)))
+                     (re-search-forward "{\\([^}]+\\)}" nil t)
+                   (re-search-forward "\\(.\\)" (1+ (point)) t))
+                 (push `(LaTeX-arg-xparse-embellishment-query
+                         ,(match-string-no-properties 1))
+                       args)
+                 (when (looking-at-p TeX-grop)
+                   (forward-sexp)))
                 ;; Finished:
                 (t nil))))
       (if (eq type 'env)
-          (LaTeX-add-environments `(,name
-                                    LaTeX-env-args
-                                    ,@(reverse (copy-sequence args))))
+          ;; Parsed enviroments: If we are Renew'ing or Delare'ing, we
+          ;; delete the enviroment first from `LaTeX-environment-list'
+          ;; before adding the new one.  We have to sort the value of
+          ;; `LaTeX-environment-list' by running the function of the
+          ;; same name:
+          (progn
+            (when (member what '("Renew" "Declare"))
+              (LaTeX-environment-list)
+              (setq LaTeX-environment-list
+                    (assq-delete-all (car (assoc name LaTeX-environment-list))
+                                     LaTeX-environment-list)))
+            (LaTeX-add-environments `(,name
+                                      LaTeX-env-args
+                                      ,@(reverse args))))
+        ;; Parsed macros: If we are Renew'ing or Delare'ing, we delete
+        ;; the macros first from `TeX-symbol-list' before adding the
+        ;; new ones.  We have to sort the value of `TeX-symbol-list'
+        ;; by running the function of the same name:
+        (when (member what '("Renew" "Declare"))
+          (TeX-symbol-list)
+          (setq TeX-symbol-list
+                (assq-delete-all (car (assoc name TeX-symbol-list))
+                                 TeX-symbol-list))
+          (when opt-star
+            (setq TeX-symbol-list
+                  (assq-delete-all (car (assoc (concat name "*") 
TeX-symbol-list))
+                                   TeX-symbol-list)))
+          (when opt-token
+            (setq TeX-symbol-list
+                  (assq-delete-all (car (assoc (concat name opt-token) 
TeX-symbol-list))
+                                   TeX-symbol-list))))
         (TeX-add-symbols (cons name
-                               (reverse (copy-sequence args))))
+                               (reverse args)))
         (when opt-star
           (TeX-add-symbols (cons (concat name "*")
-                                 (reverse (copy-sequence args)))))
+                                 (reverse args))))
         (when opt-token
           (TeX-add-symbols (cons (concat name opt-token)
-                                 (reverse (copy-sequence args)))))))))
+                                 (reverse args))))))))
 
 (defun LaTeX-xparse-auto-prepare ()
   "Clear various `LaTeX-auto-xparse-*' variables before parsing."
@@ -275,9 +317,9 @@ TYPE is one of the symobols mac or env."
     "ProcessedArgument"
     "ReverseBoolean"
     '("SplitArgument" "Number" "Token")
-    "SplitList"
+    '("SplitList" "Token")
     "TrimSpaces"
-    '("ProcessList" "List" "Functiom")
+    '("ProcessList" "List" "Function")
     ;; Access to the argument specification
     '("GetDocumentCommandArgSpec" TeX-arg-macro)
     '("GetDocumentEnvironmmentArgSpec" TeX-arg-environment)
diff --git a/style/xr-hyper.el b/style/xr-hyper.el
new file mode 100644
index 0000000..472d028
--- /dev/null
+++ b/style/xr-hyper.el
@@ -0,0 +1,73 @@
+;;; xr-hyper.el --- AUCTeX style for `xr-hyper.sty'  -*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-10-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 Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
+
+;;; Commentary:
+
+;; This file adds support for `xr-hyper.sty' v7.00m form 2021-06-07.
+;; RefTeX has good support for referencing external \label's, so it
+;; should be used.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "xr-hyper"
+ (lambda ()
+   (TeX-add-symbols
+    '("externaldocument"
+      ["Prefix"]
+      [TeX-arg-eval completing-read
+                    (TeX-argument-prompt t nil "Cite option")
+                    '("nocite")]
+      ;; Act like \include and not like \input:
+      (TeX-arg-input-file "File" t)
+      ["Final file"])
+
+    '("externalcitedocument"
+      ["Prefix"]
+      ;; Act like \include and not like \input:
+      (TeX-arg-input-file "File" t)
+      ["Final file"]))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("externaldocument"     "[[{[")
+                                ("externalcitedocument" "[[{["))
+                              'reference)))
+ TeX-dialect)
+
+(defvar LaTeX-xr-hyper-package-options nil
+  "Package options for the xr-hyper package.")
+
+;;; xr-hyper.el ends here
diff --git a/style/xr.el b/style/xr.el
new file mode 100644
index 0000000..c388ead
--- /dev/null
+++ b/style/xr.el
@@ -0,0 +1,68 @@
+;;; xr.el --- AUCTeX style for `xr.sty'  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash@gnu.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2021-10-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 Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
+
+;;; Commentary:
+
+;; This file adds support for `xr.sty' v5.06 form 2020-05-10.  RefTeX
+;; has good support for referencing external \label's, so it should be
+;; used.
+
+;;; Code:
+
+(require 'tex)
+(require 'latex)
+
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+                  "font-latex"
+                  (keywords class))
+
+(TeX-add-style-hook
+ "xr"
+ (lambda ()
+   (TeX-add-symbols
+    '("externaldocument"
+      ["Prefix"]
+      ;; Act like \include and not like \input:
+      (TeX-arg-input-file "File" t))
+
+    '("externalcitedocument"
+      ["Prefix"]
+      ;; Act like \include and not like \input:
+      (TeX-arg-input-file "File" t)))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("externaldocument"     "[{")
+                                ("externalcitedocument" "[{"))
+                              'reference)))
+ TeX-dialect)
+
+(defvar LaTeX-xr-package-options nil
+  "Package options for the xr package.")
+
+;;; xr.el ends here
diff --git a/tests/latex/latex-filling-in.tex b/tests/latex/latex-filling-in.tex
index 274d03c..0d97fcf 100644
--- a/tests/latex/latex-filling-in.tex
+++ b/tests/latex/latex-filling-in.tex
@@ -26,3 +26,45 @@ Lorem ipsum dolor sit amet, consectetur adipisci,
 lorem ipsum dolor
 \par
 sit amet, consectetur adipisci
+
+% bug#48937-1 "\% %" should be considered as comment
+Donec vehicula augue eu neque.  Pellentesque habitant morbi tristique senectus
+et netus et malesuada fames ac turpis egestas. 35\% % FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus vestibulum
+urna fringilla ultrices.
+
+% bug#48937-2 "\%%" should be considered as comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Ut purus
+elit, vestibulum ut, placerat ac, adipiscing vitae, felis.  Curabitur
+dictum gravida mauris.  Nam arcu libero, nonummy eget, consectetuer
+id, vulputate a, magna.  Donec vehicula augue eu neque.  Pellentesque
+habitant morbi tristique senectus et netus et malesuada fames ac
+turpis egestas. 35\%% FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus
+vestibulum urna fringilla ultrices.
+
+% bug#51762-1 "\ %" should be considered as comment
+$$ \fundefline p{A \times B}{A}{(x,y)}{x}\ %%
+\et\ \fundefline q{A \times B}{B}{(x,y)}{y}\ %%
+\text{les projections canoniques}\ .$$
+
+% bug#51762-2 another form of code comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
+tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
+ \\% This is a code comment.
+mattis eget, convallis nec, purus.
+
+% bug#51762-3 "%" in \verb should not introduce code comment
+Cum sociis natoque penatibus et magnis \verb|a%b|
+dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
+dolor. Nullam tristique diam non turpis. 
+Cras placerat accumsan nulla. Nullam rutrum. Nam vestibulum accumsan nisl.
+
+% bug#51762-4 "\par" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet.  Vestibulum convallis, lorem a 
tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae 
lacus.\par 
+ Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at 
vulputate neque nulla lacinia eros.  Aliquam posuere.  Cum sociis natoque 
penatibus et magnis dis parturient montes, nascetur ridiculus mus.%  
+
+% bug#51762-5 "\\" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet.  Vestibulum convallis, lorem a 
+tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus.\\
+  Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at 
vulputate neque nulla lacinia eros.  Aliquam posuere.  Cum sociis natoque 
penatibus et magnis dis parturient montes, nascetur ridiculus mus.%  
diff --git a/tests/latex/latex-filling-out.tex 
b/tests/latex/latex-filling-out.tex
index 764628c..bf326d1 100644
--- a/tests/latex/latex-filling-out.tex
+++ b/tests/latex/latex-filling-out.tex
@@ -24,3 +24,55 @@ Lorem ipsum dolor sit amet, consectetur adipisci, lorem 
ipsum dolor
 Lorem ipsum dolor sit amet, consectetur adipisci, lorem ipsum dolor
 \par
 sit amet, consectetur adipisci
+
+% bug#48937-1 "\% %" should be considered as comment
+Donec vehicula augue eu neque.  Pellentesque habitant morbi tristique
+senectus et netus et malesuada fames ac turpis egestas.
+35\% % FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus
+vestibulum urna fringilla ultrices.
+
+% bug#48937-2 "\%%" should be considered as comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Ut purus
+elit, vestibulum ut, placerat ac, adipiscing vitae, felis.  Curabitur
+dictum gravida mauris.  Nam arcu libero, nonummy eget, consectetuer
+id, vulputate a, magna.  Donec vehicula augue eu neque.  Pellentesque
+habitant morbi tristique senectus et netus et malesuada fames ac
+turpis egestas. 35\%% FIXME check this number
+Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus
+vestibulum urna fringilla ultrices.
+
+% bug#51762-1 "\ %" should be considered as comment
+$$ \fundefline p{A \times B}{A}{(x,y)}{x}\ %%
+\et\ \fundefline q{A \times B}{B}{(x,y)}{y}\ %%
+\text{les projections canoniques}\ .$$
+
+% bug#51762-2 another form of code comment
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
+hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
+nisl, tincidunt et, \\% This is a code comment.
+mattis eget, convallis nec, purus.
+
+% bug#51762-3 "%" in \verb should not introduce code comment
+Cum sociis natoque penatibus et magnis \verb|a%b| dis parturient
+montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
+dolor. Nullam tristique diam non turpis.  Cras placerat accumsan
+nulla. Nullam rutrum. Nam vestibulum accumsan nisl.
+
+% bug#51762-4 "\par" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet.  Vestibulum convallis,
+lorem a tempus semper, dui dui euismod elit, vitae placerat urna
+tortor vitae lacus.\par
+Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor,
+at vulputate neque nulla lacinia eros.  Aliquam posuere.  Cum sociis
+natoque penatibus et magnis dis parturient montes, nascetur ridiculus
+mus.%
+
+% bug#51762-5 "\\" before code comment shouldn't be skipped.
+Mauris ac felis vel velit tristique imperdiet.  Vestibulum convallis,
+lorem a
+tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus.\\
+Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor,
+at vulputate neque nulla lacinia eros.  Aliquam posuere.  Cum sociis
+natoque penatibus et magnis dis parturient montes, nascetur ridiculus
+mus.%
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index af6e34f..9c1198d 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -75,6 +75,58 @@
              (insert-file-contents LaTeX-math-indent/out)
              (buffer-string)))))
 
+;; Test for flush-left type indentation.  The begin/end line of
+;; verbatim-like environments and comment-like environments (provided
+;; by comment.sty) must be flush left.
+;; We also test the indent inside these environments and after them.
+(ert-deftest LaTeX-flush-left-indent ()
+  (with-temp-buffer
+    (LaTeX-mode)
+    (let ((LaTeX-verbatim-environments
+           '("verbatim" "verbatim*" "filecontents" "filecontents*"))
+          (LaTeX-comment-env-list '("comment")))
+
+      ;; Test 1: verbatim environment
+      (insert "\
+\\begin{itemize}
+\\item abc")
+      (LaTeX-insert-environment "verbatim")
+      ;; Check indent inside verbatim env.
+      (should (= (current-column) 0))
+      ;; Check indent of verbatim env itself.
+      (should (string= "\
+\\begin{itemize}
+\\item abc
+\\begin{verbatim}
+
+\\end{verbatim}"
+                       (buffer-string)))
+      ;; Check indent after verbatim env.
+      (goto-char (point-max))
+      (newline-and-indent)
+      (should (= (current-column) 2))
+
+      ;; Test 2: comment environment
+      (erase-buffer)
+      (insert "\
+\\begin{itemize}
+\\item abc")
+      (LaTeX-insert-environment "comment")
+      ;; Check indent inside comment env.
+      (should (= (current-column) 2))
+      ;; Check indent of comment env itself.
+      (should (string= "\
+\\begin{itemize}
+\\item abc
+\\begin{comment}
+\s\s
+\\end{comment}"
+                       (buffer-string)))
+      ;; Check indent after comment env.
+      (goto-char (point-max))
+      (newline-and-indent)
+      (should (= (current-column) 2)))))
+
 ;; Test LaTeX code with math modes is indented as expected.  This has mostly to
 ;; do with the value of `LaTeX-fill-break-at-separators' and how
 ;; `LaTeX-fill-move-to-break-point' handles it.  If the test fails, try to look
@@ -88,13 +140,18 @@
              (LaTeX-mode)
              (let ((fill-column 70))
                (fill-paragraph)
+
                (let ((cmds '("captionsetup" "caption"
                              "parencite"    "par")))
                  (dolist (cmd cmds)
                    (search-forward (concat "\\" cmd))
                    (save-excursion
                      (end-of-line 0)
-                     (fill-paragraph)))))
+                     (fill-paragraph))))
+
+               (while (search-forward "% bug#" nil t)
+                 (forward-line 1)
+                 (fill-paragraph)))
              (buffer-string))
            (with-temp-buffer
              (insert-file-contents LaTeX-filling/out)
diff --git a/tex-bar.el b/tex-bar.el
index 49e1b3c..0bfd431 100644
--- a/tex-bar.el
+++ b/tex-bar.el
@@ -211,7 +211,6 @@ format of the argument MEANING-ALIST in the mentioned 
function."
 (defun TeX-install-toolbar ()
   "Install toolbar buttons for TeX mode."
   (interactive)
-  (require 'toolbar-x)
   (add-to-list 'toolbarx-image-path
                (expand-file-name "images" TeX-data-directory))
   (add-hook 'TeX-PDF-mode-hook #'toolbarx-refresh nil t)
@@ -261,10 +260,6 @@ alists, see variable `TeX-bar-LaTeX-all-button-alists'."
                                (sexp :tag "General element"))))
   :group 'TeX-tool-bar)
 
-(defgroup TeX-tool-bar-button-definitions nil
-  "Collections of button definitions."
-  :group 'TeX-tool-bar)
-
 (defcustom TeX-bar-LaTeX-all-button-alists
   '(TeX-bar-LaTeX-button-alist
     toolbarx-default-toolbar-meaning-alist)
@@ -356,7 +351,6 @@ format of the argument MEANING-ALIST in the mentioned 
function."
 (defun LaTeX-install-toolbar ()
   "Install toolbar buttons for LaTeX mode."
   (interactive)
-  (require 'toolbar-x)
   (add-to-list 'toolbarx-image-path
                (expand-file-name "images" TeX-data-directory))
   (add-hook 'TeX-PDF-mode-hook #'toolbarx-refresh nil t)
diff --git a/tex-buf.el b/tex-buf.el
index ce54251..cdc4b06 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -193,7 +193,7 @@ if present.
 
 If a prefix argument OVERRIDE-CONFIRM is given, prompting will
 ignore the prompting flag from `TeX-command-list' and instead
-will prompt iff the prefix is positive.
+will prompt only if the prefix is positive.
 
 If the master file for the document has a header, it is written to the
 temporary file before the region itself.  The document's header is all
@@ -1513,7 +1513,7 @@ errors or warnings to show."
 
 (defun TeX-TeX-sentinel-check (process name)
   "Cleanup TeX output buffer after running TeX.
-Return nil ifs no errors were found."
+Return nil only if no errors were found."
   (save-excursion
     (goto-char (point-max))
     (cond
@@ -1874,7 +1874,7 @@ defined."
 
 (defun TeX-process-set-variable (name symbol value)
   "Set the variable SYMBOL in the process buffer to VALUE.
-Return nil iff no process buffer exist."
+Return nil only if no process buffer exists."
   (let ((buffer (TeX-process-buffer name)))
     (if buffer
         (with-current-buffer buffer
@@ -2019,7 +2019,7 @@ command."
 ;;; Active Process
 
 (defvar TeX-current-process-region-p nil
-  "This variable is set to t iff the last TeX command is on a region.")
+  "Non-nil means that the last TeX command is on a region.")
 
 (defun TeX-active-process ()
   "Return the active process for the current buffer."
@@ -2354,10 +2354,10 @@ depend on it being positive instead of the entry in
 (defun TeX-command-run-all (arg)
   "Compile the current document until an error occurs or it is finished.
 With a prefix ARG (`\\[universal-argument] \\[TeX-command-run-all]'),
-compile the current region instead, e.g, call
+compile the current region instead, that is, call
 `TeX-command-run-all-region'.  With multiple prefix
 arguments (`\\[universal-argument] \\[universal-argument] 
\\[TeX-command-run-all]'),
-compile the current section instead, e.g. call
+compile the current section instead, that is, call
 `LaTeX-command-run-all-section'."
   (interactive "P")
   (cond
@@ -2434,8 +2434,6 @@ If REPARSE is non-nil, reparse the output log.
 If the file occurs in an included file, the file is loaded (if not
 already in an Emacs buffer) and the cursor is placed at the error."
   (let ((old-buffer (current-buffer))
-        ;; FIXME: default-major-mode has been removed in Emacs 26.
-        (default-major-mode major-mode)
         max-index item)
 
     ;; Switch to the output buffer.
@@ -2520,7 +2518,7 @@ error or warning.  This is the structure of each element:
  *  5: context, to be displayed in the help window
  *  6: string to search in the buffer, in order to find location
        of the error or warning
- *  7: for warnings referring to multiple lines (e.g. bad boxes),
+ *  7: for warnings referring to multiple lines (for exapmle, bad boxes),
        the last line mentioned in the warning message
  *  8: t if it is a bad-box, nil otherwise
  *  9: value of `TeX-error-point'
@@ -2693,11 +2691,14 @@ value is not used here."
                 (find-file
                  (expand-file-name TeX-translate-location-file
                                    (file-name-directory master))))
+          ;; Use the major mode of `TeX-command-buffer' when visiting
+          ;; the error point.
+          (if (eq major-mode (default-value 'major-mode))
+              (funcall (buffer-local-value 'major-mode command-buffer)))
           ;; Set the value of `TeX-command-buffer' in the next file
           ;; with an error to be displayed to the value it has in the
           ;; current buffer.
-          (with-current-buffer error-file-buffer
-            (setq-local TeX-command-buffer command-buffer))
+          (setq-local TeX-command-buffer command-buffer)
 
           ;; Find the location of the error or warning.
           (when TeX-translate-location-line
@@ -2722,16 +2723,16 @@ value is not used here."
                 (search-forward TeX-translate-location-string nil t))))))
       ;; When the file cannot be determined stay here but issue a
       ;; warning.
-      (message (concat "Could not determine file for "
-                       (cond ((equal type 'error) "error")
-                             (t "warning"))))
+      (message "Could not determine file for %s"
+               (if (eq type 'error) "error" "warning"))
       (beep))
 
     ;; Display the help.
     (cond ((eq TeX-display-help 'expert)
            (TeX-pop-to-buffer runbuf nil t)
            (goto-char error-point)
-           (TeX-pop-to-buffer error-file-buffer nil t))
+           (if error-file-buffer
+               (TeX-pop-to-buffer error-file-buffer nil t)))
           (TeX-display-help
            (TeX-help-error
             TeX-translate-location-error
@@ -2740,7 +2741,7 @@ value is not used here."
               TeX-translate-location-context)
             runbuf type))
           (t
-           (message (concat "! " TeX-translate-location-error))))))
+           (message "! %s" TeX-translate-location-error)))))
 
 (defun TeX-error (&optional store)
   "Display an error.
@@ -2815,7 +2816,10 @@ warning."
   (let* ( ;; line-string: match 1 is beginning line, match 2 is end line
          (line-string (if bad-box
                           "at lines? \\([0-9]*\\)\\(?:--\\([0-9]*\\)\\)?"
-                        "on input line \\([0-9]*\\)\\."))
+                        ;; Traditional messages say "on input line X",
+                        ;; the LaTeX3 \msg_line_context:. just reads
+                        ;; "on line X".
+                        "on \\(?:input \\)?line \\([0-9]*\\)\\."))
          ;; word-string: match 1 is the word
          (word-string (if bad-box "[][\\W() ---]\\(\\w+\\)[][\\W() ---]*$"
                         ;; Match "ref" in both "Reference `ref' on page NN
@@ -2965,7 +2969,7 @@ Major modes of AUCTeX can set its own catalogue as buffer 
local
 value of this variable, as LaTeX mode does.
 Style files of AUCTeX can also add their own entries to buffer local
 value of this variable to provide their own help messages.
-It must end with a fallback entry that matches any error, e.g.
+It must end with a fallback entry that matches any error, for example
 \(\".*\" . \"No help available\")")
 
 ;;; - Help
@@ -3138,12 +3142,8 @@ please restart TeX error overview")))
                   TeX-error-last-visited index))
           ;; Find the error and display the help.
           (with-current-buffer TeX-command-buffer
-            ;; For consistency with `TeX-parse-TeX', use the major mode of
-            ;; `TeX-command-buffer' when visiting the error point.
-            ;; FIXME: default-major-mode has been removed in Emacs 26.
-            (let ((default-major-mode major-mode))
-              ;; Find the error and display the help.
-              (apply #'TeX-find-display-help item)))
+            ;; Find the error and display the help.
+            (apply #'TeX-find-display-help item))
           ;; Return to the error overview.
           (if (TeX-error-overview-setup)
               (select-frame TeX-error-overview-frame)
diff --git a/tex-fold.el b/tex-fold.el
index d5b98d1..ec348b9 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -123,7 +123,7 @@ Customize or reset the mode."
   "Internal list of display strings and macros to fold.
 Is updated when the TeX Fold mode is being activated and then
 contains all constructs to fold for the given buffer or mode
-respectively, i.e. contents of both `TeX-fold-macro-spec-list'
+respectively, that is, contents of both `TeX-fold-macro-spec-list'
 and <mode-prefix>-fold-macro-spec-list.")
 (make-variable-buffer-local 'TeX-fold-macro-spec-list-internal)
 
@@ -138,7 +138,7 @@ and <mode-prefix>-fold-macro-spec-list.")
   "Internal list of display strings and environments to fold.
 Is updated when the TeX Fold mode is being activated and then
 contains all constructs to fold for the given buffer or mode
-respectively, i.e. contents of both `TeX-fold-env-spec-list'
+respectively, that is, contents of both `TeX-fold-env-spec-list'
 and <mode-prefix>-fold-env-spec-list.")
 (make-variable-buffer-local 'TeX-fold-env-spec-list-internal)
 
@@ -152,7 +152,7 @@ and <mode-prefix>-fold-env-spec-list.")
   "Internal list of display strings and math macros to fold.
 Is updated when the TeX Fold mode is being activated and then
 contains all constructs to fold for the given buffer or mode
-respectively, i.e. contents of both `TeX-fold-math-spec-list'
+respectively, that is, contents of both `TeX-fold-math-spec-list'
 and <mode-prefix>-fold-math-spec-list.")
 (make-variable-buffer-local 'TeX-fold-math-spec-list-internal)
 
diff --git a/tex-info.el b/tex-info.el
index ef1e439..6a77fc5 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -197,7 +197,7 @@ structuring commands matched by regexp in variable
 of variable `texinfo-section-list'.
 
 If optional argument NO-SUBSECTION is set to any integer or is a
-non nil empty argument (i.e. `C-u \\[Texinfo-mark-section]'),
+non nil empty argument (that is, `\\[universal-argument] 
\\[Texinfo-mark-section]'),
 then mark the current section with exclusion of any subsections.
 
 Otherwise, any included subsections are also marked along with
@@ -273,7 +273,7 @@ the section."
       (TeX-activate-region) )))
 
 (defun Texinfo-mark-node ()
-  "Mark the current node.  \
+  "Mark the current node.
 This is the node in which the pointer is.  It is starting at
 previous beginning of keyword `@node' and ending at next
 beginning of keyword `@node' or `@bye'."
@@ -297,7 +297,8 @@ beginning of keyword `@node' or `@bye'."
 character. Return the resulting string."
   (let ((pos 0) (map '(("comma" . ","))))
     (while (and (< pos (length
-                        node-name)) (string-match "@\\(comma\\)[[:blank:]]*{}" 
node-name pos))
+                        node-name))
+                (string-match "@\\(comma\\)[[:blank:]]*{}" node-name pos))
       (setq node-name (concat  (substring node-name 0 (match-beginning 0))
                                (cdr (assoc-string (match-string 1 node-name) 
map))
                                (substring node-name (match-end 0)))
@@ -416,7 +417,8 @@ each invocation."
     (insert " " l " @| " c " @| " r)))
 
 (defun Texinfo-arg-next-line (_optional &rest _args)
-  "Go to the beginning of next line if we are at the end of line. Otherwise 
insert an end-of-line."
+  "Go to the beginning of next line if we are at the end of line.
+Otherwise insert an end-of-line."
   (if (eolp)  (forward-line) (insert "\n")))
 
 (defun Texinfo-arg-on|off (optional &optional prompt style)
@@ -641,7 +643,7 @@ is assumed by default."
 Special commands:
 \\{Texinfo-mode-map}
 
-Entering Texinfo mode calls the value of `text-mode-hook'  and then the
+Entering Texinfo mode calls the value of `text-mode-hook' and then the
 value of `Texinfo-mode-hook'."
   (interactive)
   (kill-all-local-variables)
@@ -669,6 +671,7 @@ value of `Texinfo-mode-hook'."
   (set (make-local-variable 'comment-start) "@c ")
   (set (make-local-variable 'comment-start-skip) "@c +\\|@comment +")
   (set (make-local-variable 'comment-use-syntax) nil)
+  (setq TeX-comment-start-regexp "@c\\(?:omment\\)?\\>")
   (set (make-local-variable 'words-include-escapes) t)
   (set (make-local-variable 'imenu-generic-expression)
        texinfo-imenu-generic-expression)
@@ -871,7 +874,7 @@ value of `Texinfo-mode-hook'."
   '("\\.cps?" "\\.vrs?" "\\.fns?" "\\.tps?" "\\.pgs?" "\\.kys?")
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
@@ -881,7 +884,7 @@ i.e. you do _not_ have to cater for this yourself by adding 
\\\\' or $."
     "_toc\\.html" "_fot\\.html" "_abt\\.html" "_[0-9]+\\.html" "_l2h_img.+")
   "List of regexps matching suffixes of files to be deleted.
 The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+that is, you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
diff --git a/tex-jp.el b/tex-jp.el
index 562f2c9..714aa7a 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -224,7 +224,7 @@ systems are determined by their values regardless of the 
kanji option."
           '("/usr/share/texmf/jtex/" "/usr/share/texmf/jbibtex/bst/")))
 
 (defcustom japanese-TeX-error-messages t
-  "If non-nil, explain TeX error messages in Japanese."
+  "If non-nil, explain LaTeX error messages in Japanese."
   :type 'boolean)
 
 (defcustom TeX-japanese-process-input-coding-system nil
diff --git a/tex.el b/tex.el
index 46d6bbc..ab6d3d9 100644
--- a/tex.el
+++ b/tex.el
@@ -702,6 +702,7 @@ sure \"%p\" is the first entry."
 (autoload 'LaTeX-command-run-all-section "tex-buf" nil t)
 (autoload 'LaTeX-command-section "tex-buf" nil t)
 (autoload 'TeX-active-master "tex-buf")
+(autoload 'TeX-check-engine-add-engines "tex-buf")
 (autoload 'TeX-command "tex-buf")
 (autoload 'TeX-command-buffer "tex-buf" nil t)
 (autoload 'TeX-command-expand "tex-buf")
@@ -1265,12 +1266,18 @@ viewer."
   (if (TeX-evince-dbus-p de app :forward)
       (intern (format "TeX-%s-sync-view" app))
     `(,app (mode-io-correlate
-            ;; With evince 3, -p N opens the page *labeled* N,
-            ;; and -i,--page-index the physical page N.
-            ,(if (string-match "--page-index"
-                               (shell-command-to-string (concat app " 
--help")))
-                 " -i %(outpage)"
-               " -p %(outpage)")) " %o")))
+            ;; When tex.el is loaded as response to opening a tex file
+            ;; in a non-existent directory, we need to make sure
+            ;; `default-directory' exists, otherwise the shell-command
+            ;; below will error (bug#50225).
+            ,(let ((default-directory (file-name-as-directory
+                                       (expand-file-name "~"))))
+               ;; With evince 3, -p N opens the page *labeled* N,
+               ;; and -i,--page-index the physical page N.
+               (if (string-match "--page-index"
+                                 (shell-command-to-string (concat app " 
--help")))
+                   " -i %(outpage)"
+                 " -p %(outpage)"))) " %o")))
 
 (defvar TeX-view-program-list-builtin
   (cond
@@ -1689,7 +1696,7 @@ as a string.")
 
 (defvar TeX-source-correlate-start-server-flag nil
   "If non-nil, `TeX-source-correlate-start-server-maybe' will start a server.
-Code related to features requiring a server, e.g. for inverse
+Code related to features requiring a server, for example, for inverse
 search, can set the variable.")
 
 (defun TeX-source-correlate-gnuserv-p ()
@@ -1887,7 +1894,7 @@ SyncTeX are recognized."
        :session nil (format "/org/%s/%s/Window/0" (car de-app) (cadr de-app))
        (format "org.%s.%s.Window" (car de-app) (cadr de-app))
        "SyncSource"
-       'TeX-source-correlate-sync-source))))
+       #'TeX-source-correlate-sync-source))))
 
 (defalias 'TeX-source-specials-mode #'TeX-source-correlate-mode)
 (make-obsolete 'TeX-source-specials-mode 'TeX-source-correlate-mode "11.86")
@@ -2816,7 +2823,7 @@ Supported values are described below:
 
 Purpose is notably to prevent non-Texinfo hooks to be run in
 Texinfo files, due to ambiguous style name, as this may cause bad
-side effect e.g. on variable `TeX-font-list'.")
+side effect for example on variable `TeX-font-list'.")
 
 (defcustom TeX-byte-compile nil
   "Not nil means try to byte compile auto files before loading."
@@ -3146,7 +3153,7 @@ Expert %s are completed depending on 
`TeX-complete-expert-commands'."
              (puthash x style TeX-expert-macro-table))))
 
        (defun ,(intern (format "%s-filtered" list-var)) ()
-         ,(format "Return (%s) filtered depending on 
`TeX-complete-expert-commands'."
+         ,(format "Filter (%s) depending on `TeX-complete-expert-commands'."
                   list-var)
          (delq nil
                (mapcar
@@ -3295,7 +3302,7 @@ optional arguments.  If set to `mandatory-args-only',
 When `TeX-insert-macro' is called with \\[universal-argument], it's the other
 way round.
 
-Note that for some macros, there are special mechanisms, see e.g.
+Note that for some macros, there are special mechanisms, see for example
 `LaTeX-includegraphics-options-alist' and `TeX-arg-cite-note-p'."
   :group 'TeX-macro
   :type '(choice (const mandatory-args-only)
@@ -4748,7 +4755,7 @@ to look backward for."
    (TeX-master-directory)))
 
 (defun TeX-near-bobp ()
-  "Return t iff there's nothing but whitespace between (bob) and (point)."
+  "Return t if there's nothing but whitespace between (bob) and (point)."
   (save-excursion
     (skip-chars-backward " \t\n")
     (bobp)))
@@ -5183,16 +5190,17 @@ Brace insertion is only done if point is in a math 
construct and
 ;;; Verbatim constructs
 
 (defvar TeX-verbatim-p-function nil
-  "Mode-specific function to be called by `TeX-verbatim-p'.")
+  "Mode-specific function to be called by `TeX-verbatim-p'.
+It must accept optional argument POS for position.")
 (make-variable-buffer-local 'TeX-verbatim-p-function)
 
 ;; XXX: We only have an implementation for LaTeX mode at the moment (Oct 2009).
-(defun TeX-verbatim-p (&optional _pos)
+(defun TeX-verbatim-p (&optional pos)
   "Return non-nil if position POS is in a verbatim-like construct.
 A mode-specific implementation is required.  If it is not
 available, the function always returns nil."
   (when TeX-verbatim-p-function
-    (funcall TeX-verbatim-p-function)))
+    (funcall TeX-verbatim-p-function pos)))
 
 
 ;;; Comments
@@ -5267,7 +5275,7 @@ whitespace as well."
 
 (defun TeX-in-line-comment ()
   "Return non-nil if point is in a line comment.
-A line comment is a comment starting in column one, i.e. there is
+A line comment is a comment starting in column one, that is, there is
 no whitespace before the comment sign."
   (save-excursion
     (forward-line 0)
@@ -5351,7 +5359,7 @@ and can use regexps instead of syntax."
   (comment-forward n))
 
 (defun TeX-comment-padding-string ()
-  "Return  comment padding as a string.
+  "Return comment padding as a string.
 The variable `comment-padding' can hold an integer or a string.
 This function will return the appropriate string representation
 regardless of its data type."
@@ -5468,7 +5476,7 @@ do not search further than this position in the buffer."
 
 (defun TeX-find-closing-brace (&optional depth limit)
   "Return the position of the closing brace in a TeX group.
-The function assumes that point is inside the group, i.e. after
+The function assumes that point is inside the group, that is, after
 an opening brace.  With optional DEPTH>=1, find that outer level.
 If LIMIT is non-nil, do not search further down than this
 position in the buffer."
@@ -5476,7 +5484,7 @@ position in the buffer."
 
 (defun TeX-find-opening-brace (&optional depth limit)
   "Return the position of the opening brace in a TeX group.
-The function assumes that point is inside the group, i.e. before
+The function assumes that point is inside the group, that is, before
 a closing brace.  With optional DEPTH>=1, find that outer level.
 If LIMIT is non-nil, do not search further up than this position
 in the buffer."
@@ -5669,8 +5677,8 @@ If LIMIT is omitted, search till the end of the buffer.
 The search relies on `TeX-comment-start-regexp' being set
 correctly for the current mode.
 
-Set `TeX-search-forward-comment-start-defun' in order to override
-the default implementation."
+Set `TeX-search-forward-comment-start-function' in order to
+override the default implementation."
   (if TeX-search-forward-comment-start-function
       (funcall TeX-search-forward-comment-start-function limit)
     (setq limit (or limit (point-max)))
@@ -6383,7 +6391,7 @@ The second is a list of modes the backend should be 
activated in.
 
 The third is a function returning a list of documents available
 to the backend.  It should return nil if the backend is not
-available, e.g. if a required executable is not present on the
+available, for example if a required executable is not present on the
 system in question.
 
 The fourth is a function for displaying the documentation.  The
@@ -6566,7 +6574,7 @@ skipped."
      (sit-for 2))))
 
 (defun TeX-ispell-tex-arg-verb-end (&optional arg)
-  "Skip across an optional argument, ARG number of mandatory ones and verbatim 
content.
+  "Skip an optional argument, ARG number of mandatory ones and verbatim 
content.
 This function always checks if one optional argument in brackets
 is given and skips over it.  If ARG is a number, it skips over
 that many mandatory arguments in braces.  Then it checks for
@@ -6629,7 +6637,7 @@ error."
      (lambda () (null TeX-electric-math)))
 
 (defun TeX--list-of-string-p (lst)
-  "Return non-nil iff `LST' is a list of strings.
+  "Return non-nil if LST is a list of strings.
 Used as function for validating a variable's `safe-local-variable' property."
   (and (listp lst)
        (let ((all-strings t))
diff --git a/texmathp.el b/texmathp.el
index b0fd02d..7ede010 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -247,8 +247,8 @@ 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.g.
-\"equation\" or \"\\ensuremath\" or \"\\=\\[\" or \"$\".
+MATCH is a string like a car of an entry in `texmathp-tex-commands', for
+example \"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]