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

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

[elpa] externals/auctex 92aa02b 29/30: Merge remote-tracking branch 'ori


From: Tassilo Horn
Subject: [elpa] externals/auctex 92aa02b 29/30: Merge remote-tracking branch 'origin/master' into externals/auctex
Date: Fri, 25 Sep 2020 11:00:17 -0400 (EDT)

branch: externals/auctex
commit 92aa02b2d674f34a9ba5fed2da0cbdb96cd012f9
Merge: b6366ef 087b030
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Merge remote-tracking branch 'origin/master' into externals/auctex
---
 Makefile.in                    |   2 +-
 bib-cite.el                    |  19 +-
 configure.ac                   |   3 -
 context.el                     |  21 +-
 doc/auctex.texi                |   7 +-
 doc/changes.texi               |  18 +-
 doc/preview-dtxdoc.pl          |   6 +-
 doc/preview-latex.texi         |   4 +-
 font-latex.el                  |  82 ++++--
 latex.el                       |  40 ++-
 preview.el                     | 515 +++++++++++++++++++++++++++++++++++-
 prv-emacs.el                   | 587 -----------------------------------------
 style/amsmath.el               |  19 --
 style/arabxetex.el             |   2 +
 style/bidi.el                  |   4 +-
 style/breqn.el                 |  16 --
 style/csquotes.el              | 470 +++++++++++++++++++++------------
 style/dinbrief.el              | 142 +++++-----
 style/empheq.el                |  20 --
 style/exam.el                  |   6 +-
 style/fontspec.el              |   4 +-
 style/ifluatex.el              |   2 +-
 style/kpfonts.el               |   7 +-
 style/letter.el                |  23 +-
 style/mathtools.el             |   8 -
 style/polyglossia.el           |   2 +
 style/pstricks.el              |   9 +-
 style/shortvrb.el              |   9 +
 style/tikz.el                  |  86 +++---
 tests/latex/font-latex-test.el |  40 +++
 tex-bar.el                     | 100 +++----
 tex-buf.el                     |   8 +-
 tex-font.el                    |   3 +-
 tex-info.el                    |   1 +
 tex.el                         |  74 +++++-
 texmathp.el                    |  40 ++-
 36 files changed, 1315 insertions(+), 1084 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 1037fe0..63234c1 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -177,7 +177,7 @@ STYLESRC = style/prosper.el \
 STYLEELC = $(STYLESRC:.el=.elc)
 
 ifeq (@preview_enabled@,yes)
-   PREVIEWSRC = @PLAT_LISP@ preview.el
+   PREVIEWSRC = preview.el
    PREVIEWELC = $(PREVIEWSRC:.el=.elc)
    PREVIEWLATEX = $(MAKE) preview-latex.el
    TEXMF = (cd latex ; $(MAKE) all)
diff --git a/bib-cite.el b/bib-cite.el
index d871cb0..8d346c3 100644
--- a/bib-cite.el
+++ b/bib-cite.el
@@ -592,6 +592,14 @@
 (eval-when-compile
   (require 'cl-lib))
 
+;; Silence the compiler:
+(declare-function dired-replace-in-string "ext:dired"
+                 (regexp newtext string))
+(declare-function dired-split "ext:dired-aux"
+                 (pat str &optional limit))
+(declare-function reftex-view-crossref "ext:reftex-dcr"
+                 (&optional arg auto-how fail-quietly))
+
 (defgroup bib-cite nil
   "bib-cite, LaTeX minor-mode to display \\cite, \\ref and \\label commands."
   :group 'tex)
@@ -973,9 +981,14 @@ documents, and the Emacs command `find-tag' doesn't allow 
to interactively
 find the next occurrence of a regexp."
   (interactive "P")
   (if (bib-master-file)                 ;Multi-file document
-      (if prev-p
-         (find-tag t '- t)
-       (find-tag t t t))
+      ;; FIXME: This check for `xref-find-definitions' should be
+      ;; removed once AUCTeX requires Emacs >= 25.1
+      (let ((func (if (fboundp 'xref-find-definitions)
+                     'xref-find-definitions
+                   'find-tag)))
+       (if prev-p
+           (funcall func t '- t)
+         (funcall func t t t)))
     (if bib-cite-search-ring
        ;;FIXME: Should first make sure I move off initial \ref{}.
        (let ((regexp (concat bib-ref-regexpc bib-cite-search-ring "}")))
diff --git a/configure.ac b/configure.ac
index 566378d..a31b049 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,8 +55,6 @@ AC_ARG_ENABLE(preview,
   [preview_enabled="yes"])
 AC_SUBST(preview_enabled)
 
-PLAT_LISP=prv-emacs.el
-
 EMACS_PATH_LISPDIR
 AC_MSG_CHECKING(what file to use for auctex startup)
 AC_ARG_WITH(auctexstartfile,
@@ -92,7 +90,6 @@ texsitedir="${lispdir}"
 
 AC_SUBST(auctexstartfile)
 AC_SUBST(previewstartfile)
-AC_SUBST(PLAT_LISP)
 
 AC_MSG_CHECKING([where the package lisp files go])
 AC_ARG_WITH(packagelispdir,
diff --git a/context.el b/context.el
index 87bcd38..626da22 100644
--- a/context.el
+++ b/context.el
@@ -1,6 +1,6 @@
 ;;; context.el --- Support for ConTeXt documents.
 
-;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014-2018
+;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014-2020
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: Berend de Boer <berend@pobox.com>
@@ -55,6 +55,9 @@
 (require 'latex) ; for functions like `TeX-look-at' and `LaTeX-split-long-menu'
 (require 'plain-tex) ; for `plain-TeX-common-initialization'
 
+;; Silence the compiler:
+(defvar ConTeXt-extra-paragraph-commands)
+
 (defgroup ConTeXt-macro nil
   "Special support for ConTeXt macros in AUCTeX."
   :prefix "TeX-"
@@ -70,13 +73,14 @@
 ;; lexically scoped.
 ;; So don't give them a global value, which makes sure the effect of `defvar'
 ;; localized to this file!
-(defvar done-mark)     ;Position of point afterwards, default nil (meaning end)
-
-(defvar reference);Used by `ConTeXt-section-ref' and `ConTeXt-section-section'.
-
-(defvar title); Used by `ConTeXt-section-title' and `ConTeXt-section-section'.
-(defvar name)
-(defvar level)
+;; N.B.: These forms are commented out since they produce a "lack of
+;; prefix" warning during byte-compilation.  This way they produce
+;; only a "reference to free variable" one.
+;; (defvar done-mark) ; Position of point afterwards, default nil (meaning end)
+;; (defvar reference) ; Used by `ConTeXt-section-ref' and 
`ConTeXt-section-section'.
+;; (defvar title) ; Used by `ConTeXt-section-title' and 
`ConTeXt-section-section'.
+;; (defvar name)
+;; (defvar level)
 
 ;; others
 
@@ -559,7 +563,6 @@ assumes the section already is inserted."
   "Hook to insert a reference after the sectioning command.
 Insert this hook into `ConTeXt-section-hook' to prompt for a label to be
 inserted after the sectioning command."
-
   (setq reference (completing-read
                   (TeX-argument-prompt t nil
                                        "Comma separated list of references")
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 079179c..b19b60d 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2270,9 +2270,7 @@ like @samp{\(...\)} or @samp{\[...\]} is built-in and not 
customizable.
 Support for other math macros and environments can be adapted by
 customizing the variables @code{font-latex-match-math-command-keywords}
 and @code{texmathp-tex-commands} respectively. It is no longer
-recommended to customize @code{font-latex-math-environments}, which
-is initialized according to @code{texmathp-tex-commands} and
-@code{texmathp-tex-commands-default} by default.
+recommended to customize @code{font-latex-math-environments}.
 
 To convert your customization in @code{font-latex-math-environments}
 into @code{texmathp-tex-commands}, please register your own math
@@ -2385,9 +2383,6 @@ As a remedy you can make the verbatim construct known to 
@fontlatex{},
 commented dollar sign (@samp{%$}) at the next suitable end of line as a
 quick workaround.  In docTeX documents, @samp{^^A$} is also available
 for similar purpose.
-@c As a last resort one can set `font-lock-keywords-only', but we should
-@c probably not advise users to do this.
-
 
 @node Folding
 @section Folding Macros and Environments
diff --git a/doc/changes.texi b/doc/changes.texi
index bc2bfb6..942daa4 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -12,6 +12,15 @@
 
 @itemize @bullet
 @item
+Support for @samp{PSTricks} is now @acronym{PDF}-oriented. @AUCTeX{} no
+longer turns off PDF mode for @samp{PSTricks} documents even without
+@samp{pst-pdf}. It now sets up @code{TeX-PDF-from-DVI} option so that
+@acronym{PDF} output is generated when @code{TeX-PDF-mode} is enabled
+(default). Users who want @acronym{DVI} output should disable PDF mode
+explicitly by file local variable, or customize @code{TeX-PDF-mode} to
+@code{nil}.
+
+@item
 The function @code{font-latex-update-font-lock} has been obsoleted in
 order to fix @samp{bug#37945}.  That function was used by several style
 files in order to refresh fontification after adding new symbols or
@@ -40,16 +49,7 @@ instead.
 @ifclear rawfile
 @xref{Fontification of math}.
 @end ifclear
-@item
-Support for highlighting and in-math state detection for AMS-LaTeX
-specific environments, such as @samp{align}, @samp{gather} and
-@samp{multline}, are refactored and put into style file
-@file{amsmath.el}. So these support are available only when
-@code{TeX-parse-self} option is enabled.
 
-Support for in-math state detection for packages mathtools, empheq and
-breqn is also moved into the respective style files, so available only
-when @code{TeX-parse-self} option is enabled.
 @item
 @AUCTeX{} tracks changes in @LaTeX{}2e 2020-02-02 release.  @AUCTeX{}
 supports the improvements to @LaTeX{} font selection mechanism (NFSS).
diff --git a/doc/preview-dtxdoc.pl b/doc/preview-dtxdoc.pl
index 62d215d..52d28cb 100755
--- a/doc/preview-dtxdoc.pl
+++ b/doc/preview-dtxdoc.pl
@@ -1,11 +1,12 @@
 #!/usr/bin/perl
+# -*- coding: iso-latin-1-unix; -*-
 
 # Autoconverter from preview.dtx to preview-dtxdoc.texi
 
 # Author: Jan-�ke Larsson <jalar@mai.liu.se>
 # Maintainer: auctex-devel@gnu.org
 
-# Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2005, 2020 Free Software Foundation, Inc.
 
 # This file is part of AUCTeX.
 
@@ -53,6 +54,9 @@ MAIN: while (<STDIN>) {
     s/^%//;
     s/\\%/%/g;
 
+    # Comment
+    s/\^\^A.*\n//;
+
     # Text-substitution macros
     s/\@/\@\@/g;
     s/\\#/#/g;
diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index 67e6de7..b0c682a 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -154,8 +154,8 @@ it will run the surroundings through preview. The 
surroundings include
 all areas up to the next valid preview, unless invalid previews occur
 before, in which case the area will include the last such preview in
 either direction.  And overriding any other
-action, if a region is active (@code{transient-mark-mode} or
-@code{zmacs-regions}), it is run through @code{preview-region}.
+action, if a region is active (@code{transient-mark-mode}), it is run
+through @code{preview-region}.
 @kindex @kbd{C-c C-p C-p}
 @findex preview-at-point
 
diff --git a/font-latex.el b/font-latex.el
index d7d26fa..f8edf91 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1297,7 +1297,7 @@ triggers Font Lock to recognize the change."
   ;; influencing fontification in her file-local variables section.
   (add-hook 'hack-local-variables-hook 
#'font-latex-after-hacking-local-variables t t))
 
-(defun font-latex-update-font-lock (&optional syntactic-kws)
+(defun font-latex-update-font-lock (&optional _syntactic-kws)
   "Tell font-lock about updates of fontification rules.
 If SYNTACTIC-KWS is non-nil, also update
 `font-latex-syntactic-keywords'."
@@ -1320,11 +1320,11 @@ then call `font-latex-set-syntactic-keywords'.")))
 (make-obsolete 'font-latex-update-font-lock nil "12.2.4")
 
 (defvar font-latex--updated-region-end nil
-;; During hilighting of math expression, matched range sometimes exceeds
-;; the given end limit. So record the actual end in this variable to
+;; During font lock operation, matched range sometimes exceeds the
+;; given end limit. So record the actual end in this variable to
 ;; notify the font lock machinery.
-;; Match function of math expression should do the following two if
-;; the end of the actual match goes beyond the limit:
+;; Match functions should do the following two if the end of the
+;; actual match goes beyond the limit:
 ;; 1. If the value of this variable is smaller than limit, set this
 ;;    variable to that limit.
 ;; 2. When the end of the actual match exceeds this variable,
@@ -2018,12 +2018,9 @@ set to french, and >>german<< (and 8-bit) are used if 
set to german."
                                            (match-beginning 0))
          (let* ((beg (match-beginning 0))
                 (after-beg (match-end 0))
-                (opening-quote (match-string 0))
+                (opening-quote (match-string-no-properties 0))
                 (closing-quote
-                 (nth 1 (assoc (if (fboundp 'string-make-multibyte)
-                                   (string-make-multibyte (match-string 0))
-                                 (match-string 0))
-                               font-latex-quote-list)))
+                 (nth 1 (assoc opening-quote font-latex-quote-list)))
                 (nest-count 0)
                 (point-of-surrender (+ beg font-latex-multiline-boundary)))
            ;; Find closing quote taking nested quotes into account.
@@ -2032,7 +2029,8 @@ set to french, and >>german<< (and 8-bit) are used if set 
to german."
                      (concat opening-quote "\\|" closing-quote)
                      point-of-surrender 'move)
                     (when (and (< (point) point-of-surrender) (not (eobp)))
-                      (if (string= (match-string 0) opening-quote)
+                      (if (string= (match-string-no-properties 0)
+                                   opening-quote)
                           (setq nest-count (1+ nest-count))
                         (when (/= nest-count 0)
                           (setq nest-count (1- nest-count)))))))
@@ -2043,19 +2041,27 @@ set to french, and >>german<< (and 8-bit) are used if 
set to german."
                (progn
                  (goto-char after-beg)
                  (store-match-data (list after-beg after-beg beg after-beg)))
-             (store-match-data (list beg (point) (point) (point))))
+             (let ((p (point)))
+               (if (< font-latex--updated-region-end limit)
+                   (setq font-latex--updated-region-end limit))
+               (when (< font-latex--updated-region-end p)
+                 (font-lock-unfontify-region
+                  font-latex--updated-region-end p)
+                 (setq font-latex--updated-region-end p))
+               (store-match-data (list beg p p p))))
            (throw 'match t)))))))
 
 (defun font-latex-extend-region-backwards-quotation ()
   "Extend region backwards for quotations."
   (when font-latex-quotes
     (font-latex-update-quote-list)
-    (let ((regexp-end (regexp-opt (mapcar 'cadr font-latex-quote-list) t)))
+    (let ((regexp-end (regexp-opt (mapcar #'cadr font-latex-quote-list) t)))
       (save-excursion
        (goto-char font-lock-end)
        (catch 'extend
          (while (re-search-backward regexp-end font-lock-beg t)
-           (let ((closing-quote (match-string 0))
+           (let ((found-end (match-beginning 0))
+                 (closing-quote (match-string-no-properties 0))
                  (nest-count 0)
                  (point-of-surrender (- font-lock-beg
                                          font-latex-multiline-boundary))
@@ -2066,19 +2072,41 @@ set to french, and >>german<< (and 8-bit) are used if 
set to german."
                    (setq opening-quote (car elt))
                    (throw 'found nil))))
              ;; Find opening quote taking nested quotes into account.
-             (while (progn
-                      (re-search-backward (concat opening-quote "\\|"
-                                                  closing-quote)
-                                          point-of-surrender 'move)
-                      (when (and (> (point) point-of-surrender)
-                                 (not (bobp)))
-                        (if (string= (match-string 0) closing-quote)
-                            (setq nest-count (1+ nest-count))
-                          (when (/= nest-count 0)
-                            (setq nest-count (1- nest-count)))))))
-             (when (< (point) font-lock-beg)
-                (setq font-lock-beg (point))
-               (throw 'extend t)))))))))
+             (while (if (re-search-backward (concat opening-quote "\\|"
+                                                    closing-quote)
+                                            point-of-surrender 'move)
+                        ;; Found quotes before point-of-surrender.
+                        (cond ((string= (match-string-no-properties 0)
+                                        closing-quote)
+                               ;; Encountered another closing quote.
+                               ;; Increase nest-count and continue
+                               ;; the inner loop.
+                               (setq nest-count (1+ nest-count)))
+                              ;; Found an opening quote.
+                              ((/= nest-count 0)
+                               ;; If in nest, decrease nest-count
+                               ;; and continue the inner loop.
+                               (setq nest-count (1- nest-count)))
+                              ;; Else we arrived at the opening quote
+                              ;; matching with the closing quote found
+                              ;; in the outer loop.
+                              ((< (point) font-lock-beg)
+                               ;; If that opening quote locates
+                               ;; before `font-lock-beg', break the
+                               ;; outer loop and extend the region.
+                               (setq font-lock-beg (point))
+                               (throw 'extend t))
+                              (t
+                               ;; Else terminate the inner loop and
+                               ;; continue the outer loop.
+                               nil))
+                      ;; Didn't find quotes before
+                      ;; point-of-surrender.
+                      ;; Go back just before the closing quote,
+                      ;; terminate the inner loop and
+                      ;; continue the outer loop.
+                      (goto-char found-end)
+                      nil)))))))))
 
 (defun font-latex-match-script (limit)
   "Match subscript and superscript patterns up to LIMIT."
diff --git a/latex.el b/latex.el
index db0af47..923d27a 100644
--- a/latex.el
+++ b/latex.el
@@ -37,6 +37,19 @@
 (eval-when-compile
   (require 'cl-lib))
 
+;; Silence the compiler for functions:
+(declare-function outline-level "ext:outline"
+                 nil)
+(declare-function outline-mark-subtree "ext:outline"
+                 nil)
+(declare-function turn-off-filladapt-mode "ext:filladapt"
+                 nil)
+
+;; Silence the compiler for variables:
+(defvar outline-heading-alist)
+(defvar TeX-auto-file)
+(defvar LaTeX-section-list-changed)
+
 ;;; Syntax
 
 (defvar LaTeX-optop "["
@@ -114,11 +127,14 @@ This depends on `LaTeX-insert-into-comments'."
 ;;; Sections
 
 ;; Declare dynamically scoped vars.
-(defvar title)
-(defvar name)
-(defvar level)
-(defvar done-mark)
-(defvar toc)
+;; N.B.: These forms are commented out since they produce a "lack of
+;; prefix" warning during byte-compilation.  This way they produce
+;; only a "reference to free variable" one.
+;; (defvar title)
+;; (defvar name)
+;; (defvar level)
+;; (defvar done-mark)
+;; (defvar toc)
 
 (defun LaTeX-section (arg)
   "Insert a template for a LaTeX section.
@@ -4534,8 +4550,9 @@ value of NO-SUBSECTIONS."
 (defvar LaTeX-paragraph-commands-internal
   '("[" "]" ; display math
     "appendix" "begin" "caption" "chapter" "end" "include" "includeonly"
-    "label" "maketitle" "noindent" "par" "paragraph" "part" "section"
-    "subsection" "subsubsection" "tableofcontents" "newpage" "clearpage")
+    "label" "maketitle" "newblock" "noindent" "par" "paragraph" "part"
+    "section" "subsection" "subsubsection" "tableofcontents"
+    "newpage" "clearpage")
   "Internal list of LaTeX macros that should have their own line.")
 
 (defun LaTeX-paragraph-commands-regexp-make ()
@@ -6275,10 +6292,10 @@ function would return non-nil and `(match-string 1)' 
would return
                      "enumiv" "footnote" "mpfootnote")
 
   (LaTeX-add-lengths "arraycolsep" "arrayrulewidth" "baselineskip" 
"baselinestretch"
-                    "columnsep" "columnwidth" "doublerulesep" "evensidemargin"
-                    "linewidth" "oddsidemargin" "paperwidth" "paperheight"
-                    "parindent" "parskip" "tabcolsep" "textheight" "textwidth"
-                    "topmargin" "unitlength")
+                    "bibindent" "columnsep" "columnwidth" "doublerulesep"
+                    "evensidemargin" "linewidth" "oddsidemargin" "paperwidth"
+                    "paperheight" "parindent" "parskip" "tabcolsep"
+                    "textheight" "textwidth" "topmargin" "unitlength")
 
   (TeX-add-symbols
    '("addtocounter" TeX-arg-counter "Value")
@@ -6367,6 +6384,7 @@ function would return non-nil and `(match-string 1)' 
would return
    '("nocite" TeX-arg-cite)
    '("bibliographystyle" TeX-arg-bibstyle)
    '("bibliography" TeX-arg-bibliography)
+   '("newblock" (TeX-arg-literal " "))
    '("footnote"
      (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
      t)
diff --git a/preview.el b/preview.el
index 30e10f7..81c9997 100644
--- a/preview.el
+++ b/preview.el
@@ -55,8 +55,6 @@ preview-latex buffers will not survive across sessions.")))
 preview-latex's bug reporting commands will probably not work.")))
   (require 'info))
 
-(require 'prv-emacs)
-
 (defgroup preview nil "Embed Preview images into LaTeX buffers."
   :group 'AUCTeX
   :prefix "preview-"
@@ -887,6 +885,10 @@ Pure borderless black-on-white will return an empty 
string."
      (and border
          (format "--bd %d" (max 1 (round (/ (* res border) 72.0))))))))
 
+(defsubst preview-supports-image-type (imagetype)
+  "Check if IMAGETYPE is supported."
+  (image-type-available-p imagetype))
+
 (defun preview-gs-dvips-process-setup ()
   "Set up Dvips process for conversions via gs."
   (unless (preview-supports-image-type preview-gs-image-type)
@@ -1198,6 +1200,26 @@ is located."
       (push ov preview-gs-queue)))
   t)
 
+(defsubst preview-icon-copy (icon)
+  "Prepare a later call of `preview-replace-active-icon'."
+
+  ;; This is just a GNU Emacs specific efficiency hack because it
+  ;; is easy to do.  When porting, don't do anything complicated
+  ;; here, rather deliver just the unchanged icon and make
+  ;; `preview-replace-active-icon' do the necessary work of replacing
+  ;; the icon where it actually has been stored, probably
+  ;; in the car of the strings property of the overlay.  This string
+  ;; might probably serve as a begin-glyph as well, in which case
+  ;; modifying the string in the strings property would change that
+  ;; glyph automatically.
+
+  (cons 'image (cdr icon)))
+
+(defsubst preview-replace-active-icon (ov replacement)
+  "Replace the active Icon in OV by REPLACEMENT, another icon."
+  (let ((img (overlay-get ov 'preview-image)))
+    (setcdr (car img) (cdar replacement))
+    (setcdr img (cdr replacement))))
 
 (defun preview-gs-place (ov snippet box run-buffer tempdir ps-file _imagetype)
   "Generate an image placeholder rendered over by Ghostscript.
@@ -1226,6 +1248,35 @@ for the file extension."
 
 (defvar view-exit-action)
 
+(eval-and-compile
+  (defvar preview-button-1 [mouse-2])
+  (defvar preview-button-2 [mouse-3]))
+
+(defmacro preview-make-clickable (&optional map glyph helpstring click1 click2)
+  "Generate a clickable string or keymap.
+If MAP is non-nil, it specifies a keymap to add to, otherwise
+a new one is created.  If GLYPH is given, the result is made
+to display it wrapped in a string.  In that case,
+HELPSTRING is a format string with one or two %s specifiers
+for preview's clicks, displayed as a help-echo.  CLICK1 and CLICK2
+are functions to call on preview's clicks."
+  `(let ((resmap ,(or map '(make-sparse-keymap))))
+     ,@(if click1
+           `((define-key resmap preview-button-1 ,click1)))
+     ,@(if click2
+           `((define-key resmap preview-button-2 ,click2)))
+     ,(if glyph
+         `(propertize
+           "x"
+           'display ,glyph
+           'mouse-face 'highlight
+           'help-echo
+           ,(if (stringp helpstring)
+                (format helpstring preview-button-1 preview-button-2)
+              `(format ,helpstring preview-button-1 preview-button-2))
+           'keymap resmap)
+       'resmap)))
+
 (defun preview-mouse-open-error (string)
   "Display STRING in a new view buffer on click."
   (let ((buff (get-buffer-create
@@ -1423,6 +1474,13 @@ recursively."
         (symbol-value hook))
        (t hook)))
 
+(defun preview-inherited-face-attribute (face attribute &optional inherit)
+  "Fetch face attribute while adhering to inheritance.
+This searches FACE for an ATTRIBUTE, using INHERIT
+for resolving unspecified or relative specs.  See the fourth
+argument of function `face-attribute' for details."
+  (face-attribute face attribute nil inherit))
+
 (defcustom preview-scale-function #'preview-scale-from-face
   "*Scale factor for included previews.
 This can be either a function to calculate the scale, or
@@ -1623,6 +1681,409 @@ considered unchanged."
   :group 'preview-appearance
   :type '(repeat function))
 
+(defcustom preview-transparent-color '(highlight :background)
+  "Color to appear transparent in previews.
+Set this to something unusual when using `preview-transparent-border',
+to the default background in most other cases."
+  :type '(radio (const :tag "None" nil)
+                (const :tag "Autodetect" t)
+                (color :tag "By name" :value "white")
+                (list :tag "Take from face"
+                      :value (default :background)
+                      (face)
+                      (choice :tag "What to take"
+                       (const :tag "Background" :value :background)
+                       (const :tag "Foreground" :value :foreground))))
+  :group 'preview-appearance)
+
+;;; Note that the following default introduces a border only when
+;;; Emacs blinks politely when point is on an image (the tested
+;;; unrelated function was introduced at about the time image blinking
+;;; became tolerable).
+(defcustom preview-transparent-border (unless (fboundp 'posn-object-x-y) 1.5)
+  "Width of transparent border for previews in pt.
+Setting this to a numeric value will add a border of
+`preview-transparent-color' around images, and will turn
+the heuristic-mask setting of images to default to 't since
+then the borders are correctly detected even in case of
+palette operations.  If the transparent color is something
+not present otherwise in the image, the cursor display
+will affect just this border.  A width of 0 is interpreted
+by PostScript as meaning a single pixel, other widths are
+interpreted as PostScript points (1/72 of 1in)"
+  :group 'preview-appearance
+  :type '(choice (const :value nil :tag "No border")
+                (number :value 1.5 :tag "Border width in pt")))
+
+(defun preview-get-heuristic-mask ()
+  "Get heuristic-mask to use for previews.
+Consults `preview-transparent-color'."
+  (cond ((stringp preview-transparent-color)
+        (color-values preview-transparent-color))
+       ((or (not (consp preview-transparent-color))
+            (integerp (car preview-transparent-color)))
+        preview-transparent-color)
+       (t (color-values (preview-inherited-face-attribute
+                         (nth 0 preview-transparent-color)
+                         (nth 1 preview-transparent-color)
+                         'default)))))
+
+(defsubst preview-create-icon-1 (file type ascent border)
+  `(image
+    :file ,file
+    :type ,type
+    :ascent ,ascent
+    ,@(and border
+          '(:mask (heuristic t)))))
+
+(defun preview-create-icon (file type ascent border)
+  "Create an icon from FILE, image TYPE, ASCENT and BORDER."
+  (list
+   (preview-create-icon-1 file type ascent border)
+   file type ascent border))
+
+(put 'preview-filter-specs :type
+     (lambda (keyword value &rest args)
+       (if (image-type-available-p value)
+          `(image :type ,value
+                  ,@(preview-filter-specs-1 args))
+        (throw 'preview-filter-specs nil))))
+
+(defun preview-import-image (image)
+  "Convert the printable IMAGE rendition back to an image."
+  (cond ((stringp image)
+        (propertize image 'face 'preview-face))
+       ((eq (car image) 'image)
+        image)
+       (t
+        (preview-create-icon-1 (nth 0 image)
+                               (nth 1 image)
+                               (nth 2 image)
+                               (if (< (length image) 4)
+                                   (preview-get-heuristic-mask)
+                                 (nth 3 image))))))
+
+;; No defcustom here: does not seem to make sense.
+
+(defvar preview-tb-icon-specs
+  '((:type xpm :file "prvtex24.xpm")
+    (:type xbm :file "prvtex24.xbm")))
+
+(defvar preview-tb-icon nil)
+
+(defun preview-add-urgentization (fun ov &rest rest)
+  "Cause FUN (function call form) to be called when redisplayed.
+FUN must be a form with OV as first argument,
+REST as the remainder, returning T."
+  (let ((dispro (overlay-get ov 'display)))
+    (unless (eq (car dispro) 'when)
+      (overlay-put ov 'display `(when (,fun ,ov ,@rest)  . ,dispro)))))
+
+(defun preview-remove-urgentization (ov)
+  "Undo urgentization of OV by `preview-add-urgentization'.
+Returns the old arguments to `preview-add-urgentization'
+if there was any urgentization."
+  (let ((dispro (overlay-get ov 'display)))
+    (when (eq (car-safe dispro) 'when)
+      (prog1
+         (car (cdr dispro))
+       (overlay-put ov 'display (cdr (cdr dispro)))))))
+
+(defvar preview-overlay nil)
+
+(put 'preview-overlay
+     'modification-hooks
+     '(preview-handle-modification))
+
+(put 'preview-overlay
+     'insert-in-front-hooks
+     '(preview-handle-insert-in-front))
+
+(put 'preview-overlay
+     'insert-behind-hooks
+     '(preview-handle-insert-behind))
+
+;; We have to fake our way around atomicity.
+
+;; Here is the beef: for best intuitiveness, we want to have
+;; insertions be carried out as expected before iconized text
+;; passages, but we want to insert *into* the overlay when not
+;; iconized.  A preview that has become empty can not get content
+;; again: we remove it.  A disabled preview needs no insert-in-front
+;; handler.
+
+(defvar preview-change-list nil
+  "List of tentatively changed overlays.")
+
+(defcustom preview-dump-threshold
+  "^ *\\\\begin *{document}[ %]*$"
+  "*Regexp denoting end of preamble.
+This is the location up to which preamble changes are considered
+to require redumping of a format."
+  :group 'preview-latex
+  :type 'string)
+
+(defun preview-preamble-changed-function
+  (ov after-change beg end &optional length)
+  "Hook function for change hooks on preamble.
+See info node `(elisp) Overlay Properties' for
+definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
+  (let ((format-cons (overlay-get ov 'format-cons)))
+    (preview-unwatch-preamble format-cons)
+    (preview-format-kill format-cons)
+    (setcdr format-cons t)))
+
+(defun preview-watch-preamble (file command format-cons)
+  "Set up a watch on master file FILE.
+FILE can be an associated buffer instead of a filename.
+COMMAND is the command that generated the format.
+FORMAT-CONS contains the format info for the main
+format dump handler."
+  (let ((buffer (if (bufferp file)
+                   file
+                 (find-buffer-visiting file))) ov)
+    (setcdr
+     format-cons
+     (cons command
+          (when buffer
+            (with-current-buffer buffer
+              (save-excursion
+                (save-restriction
+                  (widen)
+                  (goto-char (point-min))
+                  (unless (re-search-forward preview-dump-threshold nil t)
+                    (error "Can't find preamble of `%s'" file))
+                  (setq ov (make-overlay (point-min) (point)))
+                  (overlay-put ov 'format-cons format-cons)
+                  (overlay-put ov 'insert-in-front-hooks
+                               '(preview-preamble-changed-function))
+                  (overlay-put ov 'modification-hooks
+                               '(preview-preamble-changed-function))
+                  ov))))))))
+
+(defun preview-unwatch-preamble (format-cons)
+  "Stop watching a format on FORMAT-CONS.
+The watch has been set up by `preview-watch-preamble'."
+  (when (consp (cdr format-cons))
+    (when (cddr format-cons)
+      (delete-overlay (cddr format-cons)))
+    (setcdr (cdr format-cons) nil)))
+
+(defun preview-register-change (ov)
+  "Register not yet changed OV for verification.
+This stores the old contents of the overlay in the
+`preview-prechange' property and puts the overlay into
+`preview-change-list' where `preview-check-changes' will
+find it at some later point of time."
+  (unless (overlay-get ov 'preview-prechange)
+    (if (eq (overlay-get ov 'preview-state) 'disabled)
+       (overlay-put ov 'preview-prechange t)
+      (overlay-put ov 'preview-prechange
+                  (save-restriction
+                    (widen)
+                    (buffer-substring-no-properties
+                     (overlay-start ov) (overlay-end ov)))))
+    (push ov preview-change-list)))
+
+(defun preview-check-changes ()
+  "Check whether the contents under the overlay have changed.
+Disable it if that is the case.  Ignores text properties."
+  (dolist (ov preview-change-list)
+    (condition-case nil
+       (with-current-buffer (overlay-buffer ov)
+         (let ((text (save-restriction
+                       (widen)
+                       (buffer-substring-no-properties
+                        (overlay-start ov) (overlay-end ov)))))
+           (if (zerop (length text))
+               (preview-delete ov)
+             (unless
+                 (or (eq (overlay-get ov 'preview-state) 'disabled)
+                     (preview-relaxed-string=
+                      text (overlay-get ov 'preview-prechange)))
+               (overlay-put ov 'insert-in-front-hooks nil)
+               (overlay-put ov 'insert-behind-hooks nil)
+               (preview-disable ov)))))
+      (error nil))
+    (overlay-put ov 'preview-prechange nil))
+  (setq preview-change-list nil))
+
+(defun preview-handle-insert-in-front
+  (ov after-change beg end &optional length)
+  "Hook function for `insert-in-front-hooks' property.
+See info node `(elisp) Overlay Properties' for
+definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
+  (if after-change
+      (unless undo-in-progress
+       (if (eq (overlay-get ov 'preview-state) 'active)
+           (move-overlay ov end (overlay-end ov))))
+    (preview-register-change ov)))
+
+(defun preview-handle-insert-behind
+  (ov after-change beg end &optional length)
+  "Hook function for `insert-behind-hooks' property.
+This is needed in case `insert-before-markers' is used at the
+end of the overlay.  See info node `(elisp) Overlay Properties'
+for definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
+  (if after-change
+      (unless undo-in-progress
+       (if (eq (overlay-get ov 'preview-state) 'active)
+           (move-overlay ov (overlay-start ov) beg)))
+    (preview-register-change ov)))
+
+(defun preview-handle-modification
+  (ov after-change beg end &optional length)
+  "Hook function for `modification-hooks' property.
+See info node `(elisp) Overlay Properties' for
+definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
+  (unless after-change
+    (preview-register-change ov)))
+
+(defun preview-toggle (ov &optional arg event)
+  "Toggle visibility of preview overlay OV.
+ARG can be one of the following: t displays the overlay,
+nil displays the underlying text, and 'toggle toggles.
+If EVENT is given, it indicates the window where the event
+occured, either by being a mouse event or by directly being
+the window in question.  This may be used for cursor restoration
+purposes."
+  (let ((old-urgent (preview-remove-urgentization ov))
+       (preview-state
+        (if (if (eq arg 'toggle)
+                (null (eq (overlay-get ov 'preview-state) 'active))
+              arg)
+            'active
+          'inactive))
+       (strings (overlay-get ov 'strings)))
+    (unless (eq (overlay-get ov 'preview-state) 'disabled)
+      (overlay-put ov 'preview-state preview-state)
+      (if (eq preview-state 'active)
+         (progn
+           (overlay-put ov 'category 'preview-overlay)
+           (if (eq (overlay-start ov) (overlay-end ov))
+               (overlay-put ov 'before-string (car strings))
+             (dolist (prop '(display keymap mouse-face help-echo))
+               (overlay-put ov prop
+                            (get-text-property 0 prop (car strings))))
+             (overlay-put ov 'before-string nil))
+           (overlay-put ov 'face nil))
+       (dolist (prop '(display keymap mouse-face help-echo))
+         (overlay-put ov prop nil))
+       (overlay-put ov 'face 'preview-face)
+       (unless (cdr strings)
+         (setcdr strings (preview-inactive-string ov)))
+       (overlay-put ov 'before-string (cdr strings)))
+      (if old-urgent
+         (apply 'preview-add-urgentization old-urgent))))
+  (if event
+      (preview-restore-position
+       ov
+       (if (windowp event)
+          event
+        (posn-window (event-start event))))))
+
+(defvar preview-marker (make-marker)
+  "Marker for fake intangibility.")
+
+(defvar preview-temporary-opened nil)
+
+(defvar preview-last-location nil
+  "Restored cursor position marker for reopened previews.")
+(make-variable-buffer-local 'preview-last-location)
+
+(defun preview-mark-point ()
+  "Mark position for fake intangibility."
+  (when (eq (get-char-property (point) 'preview-state) 'active)
+    (unless preview-last-location
+      (setq preview-last-location (make-marker)))
+    (set-marker preview-last-location (point))
+    (set-marker preview-marker (point))
+    (preview-move-point))
+  (set-marker preview-marker (point)))
+
+(defun preview-restore-position (ov window)
+  "Tweak position after opening/closing preview.
+The treated overlay OV has been triggered in WINDOW.  This function
+records the original buffer position for reopening, or restores it
+after reopening.  Note that by using the mouse, you can open/close
+overlays not in the active window."
+  (when (eq (overlay-buffer ov) (window-buffer window))
+    (with-current-buffer (overlay-buffer ov)
+      (if (eq (overlay-get ov 'preview-state) 'active)
+         (setq preview-last-location
+               (set-marker (or preview-last-location (make-marker))
+                           (window-point window)))
+       (when (and
+              (markerp preview-last-location)
+              (eq (overlay-buffer ov) (marker-buffer preview-last-location))
+              (< (overlay-start ov) preview-last-location)
+              (> (overlay-end ov) preview-last-location))
+         (set-window-point window preview-last-location))))))
+
+(defun preview-move-point ()
+  "Move point out of fake-intangible areas."
+  (preview-check-changes)
+  (let* (newlist (pt (point)) (lst (overlays-at pt)) distance)
+    (setq preview-temporary-opened
+         (dolist (ov preview-temporary-opened newlist)
+           (and (overlay-buffer ov)
+                (eq (overlay-get ov 'preview-state) 'inactive)
+                (if (and (eq (overlay-buffer ov) (current-buffer))
+                         (or (<= pt (overlay-start ov))
+                             (>= pt (overlay-end ov))))
+                    (preview-toggle ov t)
+                  (push ov newlist)))))
+    (when lst
+      (if (or disable-point-adjustment
+             global-disable-point-adjustment
+             (preview-auto-reveal-p
+              preview-auto-reveal
+              (setq distance
+                    (and (eq (marker-buffer preview-marker)
+                             (current-buffer))
+                         (- pt (marker-position preview-marker))))))
+         (preview-open-overlays lst)
+       (while lst
+         (setq lst
+               (if (and
+                    (eq (overlay-get (car lst) 'preview-state) 'active)
+                    (> pt (overlay-start (car lst))))
+                   (overlays-at
+                    (setq pt (if (and distance (< distance 0))
+                                 (overlay-start (car lst))
+                               (overlay-end (car lst)))))
+                 (cdr lst))))
+       (goto-char pt)))))
+
+(defun preview-open-overlays (list &optional pos)
+  "Open all previews in LIST, optionally restricted to enclosing POS."
+  (dolist (ovr list)
+    (when (and (eq (overlay-get ovr 'preview-state) 'active)
+              (or (null pos)
+                  (and
+                   (> pos (overlay-start ovr))
+                   (< pos (overlay-end ovr)))))
+      (preview-toggle ovr)
+      (push ovr preview-temporary-opened))))
+
+(defadvice replace-highlight (before preview)
+  "Make `query-replace' open preview text about to be replaced."
+  (preview-open-overlays
+   (overlays-in (ad-get-arg 0) (ad-get-arg 1))))
+
+(defcustom preview-query-replace-reveal t
+  "*Make `query-replace' autoreveal previews."
+  :group 'preview-appearance
+  :type 'boolean
+  :require 'preview
+  :set (lambda (symbol value)
+        (set-default symbol value)
+        (if value
+            (ad-enable-advice 'replace-highlight 'before 'preview)
+          (ad-disable-advice 'replace-highlight 'before 'preview))
+        (ad-activate 'replace-highlight))
+  :initialize #'custom-initialize-reset)
+
 (defun preview-relaxed-string= (&rest args)
 "Check for functional equality of arguments.
 The arguments ARGS are checked for equality by using
@@ -1702,8 +2163,7 @@ surroundings don't extend into unmodified previews or past
 contiguous previews invalidated by modifications.
 
 Overriding any other action, if a region is
-active (`transient-mark-mode' or `zmacs-regions'), it is run
-through `preview-region'."
+active (`transient-mark-mode'), it is run through `preview-region'."
   (interactive)
   (if (TeX-active-mark)
       (preview-region (region-beginning) (region-end))
@@ -2582,6 +3042,32 @@ pp")
       (customize-save-variable 'preview-TeX-style-dir nil)
     (customize-set-variable 'preview-TeX-style-dir nil)))
 
+(defun preview-mode-setup ()
+  "Setup proper buffer hooks and behavior for previews."
+  (set (make-local-variable 'desktop-save-buffer)
+       #'desktop-buffer-preview-misc-data)
+  (add-hook 'pre-command-hook #'preview-mark-point nil t)
+  (add-hook 'post-command-hook #'preview-move-point nil t)
+  (unless preview-tb-icon
+    (setq preview-tb-icon (preview-filter-specs preview-tb-icon-specs)))
+  (when preview-tb-icon
+    (define-key LaTeX-mode-map [tool-bar preview]
+      `(menu-item "Preview at point" preview-at-point
+                 :image ,preview-tb-icon
+                 :help "Preview on/off at point")))
+  (when buffer-file-name
+    (let* ((filename (expand-file-name buffer-file-name))
+          format-cons)
+      (when (string-match (concat "\\." TeX-default-extension "\\'")
+                         filename)
+       (setq filename (substring filename 0 (match-beginning 0))))
+      (setq format-cons (assoc filename preview-dumped-alist))
+      (when (consp (cdr format-cons))
+       (preview-unwatch-preamble format-cons)
+       (preview-watch-preamble (current-buffer)
+                               (cadr format-cons)
+                               format-cons)))))
+
 ;;;###autoload
 (defun LaTeX-preview-setup ()
   "Hook function for embedding the preview package into AUCTeX.
@@ -3153,6 +3639,27 @@ and `preview-colors' are set as given."
        preview-resolution (nth 1 geometry)
        preview-colors (nth 2 geometry)))
 
+(defun preview-get-colors ()
+  "Return colors from the current display.
+Fetches the current screen colors and makes a vector
+of colors as numbers in the range 0..65535.
+Pure borderless black-on-white will return triple NIL.
+The fourth value is the transparent border thickness."
+  (let
+      ((bg (color-values (preview-inherited-face-attribute
+                         'preview-reference-face :background 'default)))
+       (fg (color-values (preview-inherited-face-attribute
+                         'preview-reference-face :foreground 'default)))
+       (mask (preview-get-heuristic-mask)))
+    (if (equal '(65535 65535 65535) bg)
+       (setq bg nil))
+    (if (equal '(0 0 0) fg)
+       (setq fg nil))
+    (unless (and (numberp preview-transparent-border)
+                (consp mask) (integerp (car mask)))
+      (setq mask nil))
+    (vector bg fg mask preview-transparent-border)))
+
 (defun preview-start-dvipng ()
   "Start a DviPNG process.."
   (let* ((file preview-gs-file)
diff --git a/prv-emacs.el b/prv-emacs.el
deleted file mode 100644
index 0ccce7b..0000000
--- a/prv-emacs.el
+++ /dev/null
@@ -1,587 +0,0 @@
-;;; prv-emacs.el --- GNU Emacs specific code for preview.el
-
-;; Copyright (C) 2001-2005, 2018, 2019  Free Software Foundation, Inc.
-
-;; Author: David Kastrup
-;; Keywords: convenience, tex, wp
-
-;; This file 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.
-
-;; This file 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 GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; 
-
-;;; Code:
-
-(require 'tex-site)
-(require 'tex)
-(require 'latex)
-
-(defcustom preview-transparent-color '(highlight :background)
-  "Color to appear transparent in previews.
-Set this to something unusual when using `preview-transparent-border',
-to the default background in most other cases."
-  :type '(radio (const :tag "None" nil)
-                (const :tag "Autodetect" t)
-                (color :tag "By name" :value "white")
-                (list :tag "Take from face"
-                      :value (default :background)
-                      (face)
-                      (choice :tag "What to take"
-                       (const :tag "Background" :value :background)
-                       (const :tag "Foreground" :value :foreground))))
-  :group 'preview-appearance)
-
-;;; Note that the following default introduces a border only when
-;;; Emacs blinks politely when point is on an image (the tested
-;;; unrelated function was introduced at about the time image blinking
-;;; became tolerable).
-(defcustom preview-transparent-border (unless (fboundp 'posn-object-x-y) 1.5)
-  "Width of transparent border for previews in pt.
-Setting this to a numeric value will add a border of
-`preview-transparent-color' around images, and will turn
-the heuristic-mask setting of images to default to 't since
-then the borders are correctly detected even in case of
-palette operations.  If the transparent color is something
-not present otherwise in the image, the cursor display
-will affect just this border.  A width of 0 is interpreted
-by PostScript as meaning a single pixel, other widths are
-interpreted as PostScript points (1/72 of 1in)"
-  :group 'preview-appearance
-  :type '(choice (const :value nil :tag "No border")
-                (number :value 1.5 :tag "Border width in pt")))
-
-(defun preview-get-heuristic-mask ()
-  "Get heuristic-mask to use for previews.
-Consults `preview-transparent-color'."
-  (cond ((stringp preview-transparent-color)
-        (color-values preview-transparent-color))
-       ((or (not (consp preview-transparent-color))
-            (integerp (car preview-transparent-color)))
-        preview-transparent-color)
-       (t (color-values (preview-inherited-face-attribute
-                         (nth 0 preview-transparent-color)
-                         (nth 1 preview-transparent-color)
-                         'default)))))
-
-(defsubst preview-create-icon-1 (file type ascent border)
-  `(image
-    :file ,file
-    :type ,type
-    :ascent ,ascent
-    ,@(and border
-          '(:mask (heuristic t)))))
-
-(defun preview-create-icon (file type ascent border)
-  "Create an icon from FILE, image TYPE, ASCENT and BORDER."
-  (list
-   (preview-create-icon-1 file type ascent border)
-   file type ascent border))
-
-(put 'preview-filter-specs :type
-     #'(lambda (keyword value &rest args)
-        (if (image-type-available-p value)
-            `(image :type ,value
-                    ,@(preview-filter-specs-1 args))
-          (throw 'preview-filter-specs nil))))
-
-;; No defcustom here: does not seem to make sense.
-
-(defvar preview-tb-icon-specs
-  '((:type xpm :file "prvtex24.xpm")
-    (:type xbm :file "prvtex24.xbm")))
-
-(defvar preview-tb-icon nil)
-
-(defun preview-add-urgentization (fun ov &rest rest)
-  "Cause FUN (function call form) to be called when redisplayed.
-FUN must be a form with OV as first argument,
-REST as the remainder, returning T."
-  (let ((dispro (overlay-get ov 'display)))
-    (unless (eq (car dispro) 'when)
-      (overlay-put ov 'display `(when (,fun ,ov ,@rest)  . ,dispro)))))
-
-(defun preview-remove-urgentization (ov)
-  "Undo urgentization of OV by `preview-add-urgentization'.
-Returns the old arguments to `preview-add-urgentization'
-if there was any urgentization."
-  (let ((dispro (overlay-get ov 'display)))
-    (when (eq (car-safe dispro) 'when)
-      (prog1
-         (car (cdr dispro))
-       (overlay-put ov 'display (cdr (cdr dispro)))))))
-
-(defsubst preview-icon-copy (icon)
-  "Prepare a later call of `preview-replace-active-icon'."
-
-  ;; This is just a GNU Emacs specific efficiency hack because it
-  ;; is easy to do.  When porting, don't do anything complicated
-  ;; here, rather deliver just the unchanged icon and make
-  ;; `preview-replace-active-icon' do the necessary work of replacing
-  ;; the icon where it actually has been stored, probably
-  ;; in the car of the strings property of the overlay.  This string
-  ;; might probably serve as a begin-glyph as well, in which case
-  ;; modifying the string in the strings property would change that
-  ;; glyph automatically.
-
-  (cons 'image (cdr icon)))
-
-(defsubst preview-replace-active-icon (ov replacement)
-  "Replace the active Icon in OV by REPLACEMENT, another icon."
-  (let ((img (overlay-get ov 'preview-image)))
-    (setcdr (car img) (cdar replacement))
-    (setcdr img (cdr replacement))))
-
-(defvar preview-button-1 [mouse-2])
-(defvar preview-button-2 [mouse-3])
-
-(defmacro preview-make-clickable (&optional map glyph helpstring click1 click2)
-  "Generate a clickable string or keymap.
-If MAP is non-nil, it specifies a keymap to add to, otherwise
-a new one is created.  If GLYPH is given, the result is made
-to display it wrapped in a string.  In that case,
-HELPSTRING is a format string with one or two %s specifiers
-for preview's clicks, displayed as a help-echo.  CLICK1 and CLICK2
-are functions to call on preview's clicks."
-  `(let ((resmap ,(or map '(make-sparse-keymap))))
-     ,@(if click1
-           `((define-key resmap preview-button-1 ,click1)))
-     ,@(if click2
-           `((define-key resmap preview-button-2 ,click2)))
-     ,(if glyph
-         `(propertize
-           "x"
-           'display ,glyph
-           'mouse-face 'highlight
-           'help-echo
-           ,(if (stringp helpstring)
-                (format helpstring preview-button-1 preview-button-2)
-              `(format ,helpstring preview-button-1 preview-button-2))
-           'keymap resmap)
-       'resmap)))
-
-(defvar preview-overlay nil)
-
-(put 'preview-overlay
-     'modification-hooks
-     '(preview-handle-modification))
-
-(put 'preview-overlay
-     'insert-in-front-hooks
-     '(preview-handle-insert-in-front))
-
-(put 'preview-overlay
-     'insert-behind-hooks
-     '(preview-handle-insert-behind))
-
-;; We have to fake our way around atomicity.
-
-;; Here is the beef: for best intuitiveness, we want to have
-;; insertions be carried out as expected before iconized text
-;; passages, but we want to insert *into* the overlay when not
-;; iconized.  A preview that has become empty can not get content
-;; again: we remove it.  A disabled preview needs no insert-in-front
-;; handler.
-
-(defvar preview-change-list nil
-  "List of tentatively changed overlays.")
-
-(defcustom preview-dump-threshold
-  "^ *\\\\begin *{document}[ %]*$"
-  "*Regexp denoting end of preamble.
-This is the location up to which preamble changes are considered
-to require redumping of a format."
-  :group 'preview-latex
-  :type 'string)
-
-(defun preview-preamble-changed-function
-  (ov after-change beg end &optional length)
-  "Hook function for change hooks on preamble.
-See info node `(elisp) Overlay Properties' for
-definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
-  (let ((format-cons (overlay-get ov 'format-cons)))
-    (preview-unwatch-preamble format-cons)
-    (preview-format-kill format-cons)
-    (setcdr format-cons t)))
-
-(defun preview-watch-preamble (file command format-cons)
-  "Set up a watch on master file FILE.
-FILE can be an associated buffer instead of a filename.
-COMMAND is the command that generated the format.
-FORMAT-CONS contains the format info for the main
-format dump handler."
-  (let ((buffer (if (bufferp file)
-                   file
-                 (find-buffer-visiting file))) ov)
-    (setcdr
-     format-cons
-     (cons command
-          (when buffer
-            (with-current-buffer buffer
-              (save-excursion
-                (save-restriction
-                  (widen)
-                  (goto-char (point-min))
-                  (unless (re-search-forward preview-dump-threshold nil t)
-                    (error "Can't find preamble of `%s'" file))
-                  (setq ov (make-overlay (point-min) (point)))
-                  (overlay-put ov 'format-cons format-cons)
-                  (overlay-put ov 'insert-in-front-hooks
-                               '(preview-preamble-changed-function))
-                  (overlay-put ov 'modification-hooks
-                               '(preview-preamble-changed-function))
-                  ov))))))))
-
-(defun preview-unwatch-preamble (format-cons)
-  "Stop watching a format on FORMAT-CONS.
-The watch has been set up by `preview-watch-preamble'."
-  (when (consp (cdr format-cons))
-    (when (cddr format-cons)
-      (delete-overlay (cddr format-cons)))
-    (setcdr (cdr format-cons) nil)))
-
-(defun preview-register-change (ov)
-  "Register not yet changed OV for verification.
-This stores the old contents of the overlay in the
-`preview-prechange' property and puts the overlay into
-`preview-change-list' where `preview-check-changes' will
-find it at some later point of time."
-  (unless (overlay-get ov 'preview-prechange)
-    (if (eq (overlay-get ov 'preview-state) 'disabled)
-       (overlay-put ov 'preview-prechange t)
-      (overlay-put ov 'preview-prechange
-                  (save-restriction
-                    (widen)
-                    (buffer-substring-no-properties
-                     (overlay-start ov) (overlay-end ov)))))
-    (push ov preview-change-list)))
-
-(defun preview-check-changes ()
-  "Check whether the contents under the overlay have changed.
-Disable it if that is the case.  Ignores text properties."
-  (dolist (ov preview-change-list)
-    (condition-case nil
-       (with-current-buffer (overlay-buffer ov)
-         (let ((text (save-restriction
-                       (widen)
-                       (buffer-substring-no-properties
-                        (overlay-start ov) (overlay-end ov)))))
-           (if (zerop (length text))
-               (preview-delete ov)
-             (unless
-                 (or (eq (overlay-get ov 'preview-state) 'disabled)
-                     (preview-relaxed-string=
-                      text (overlay-get ov 'preview-prechange)))
-               (overlay-put ov 'insert-in-front-hooks nil)
-               (overlay-put ov 'insert-behind-hooks nil)
-               (preview-disable ov)))))
-      (error nil))
-    (overlay-put ov 'preview-prechange nil))
-  (setq preview-change-list nil))
-
-(defun preview-handle-insert-in-front
-  (ov after-change beg end &optional length)
-  "Hook function for `insert-in-front-hooks' property.
-See info node `(elisp) Overlay Properties' for
-definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
-  (if after-change
-      (unless undo-in-progress
-       (if (eq (overlay-get ov 'preview-state) 'active)
-           (move-overlay ov end (overlay-end ov))))
-    (preview-register-change ov)))
-
-(defun preview-handle-insert-behind
-  (ov after-change beg end &optional length)
-  "Hook function for `insert-behind-hooks' property.
-This is needed in case `insert-before-markers' is used at the
-end of the overlay.  See info node `(elisp) Overlay Properties'
-for definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
-  (if after-change
-      (unless undo-in-progress
-       (if (eq (overlay-get ov 'preview-state) 'active)
-           (move-overlay ov (overlay-start ov) beg)))
-    (preview-register-change ov)))
-
-(defun preview-handle-modification
-  (ov after-change beg end &optional length)
-  "Hook function for `modification-hooks' property.
-See info node `(elisp) Overlay Properties' for
-definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
-  (unless after-change
-    (preview-register-change ov)))
-
-(defun preview-toggle (ov &optional arg event)
-  "Toggle visibility of preview overlay OV.
-ARG can be one of the following: t displays the overlay,
-nil displays the underlying text, and 'toggle toggles.
-If EVENT is given, it indicates the window where the event
-occured, either by being a mouse event or by directly being
-the window in question.  This may be used for cursor restoration
-purposes."
-  (let ((old-urgent (preview-remove-urgentization ov))
-       (preview-state
-        (if (if (eq arg 'toggle)
-                (null (eq (overlay-get ov 'preview-state) 'active))
-              arg)
-            'active
-          'inactive))
-       (strings (overlay-get ov 'strings)))
-    (unless (eq (overlay-get ov 'preview-state) 'disabled)
-      (overlay-put ov 'preview-state preview-state)
-      (if (eq preview-state 'active)
-         (progn
-           (overlay-put ov 'category 'preview-overlay)
-           (if (eq (overlay-start ov) (overlay-end ov))
-               (overlay-put ov 'before-string (car strings))
-             (dolist (prop '(display keymap mouse-face help-echo))
-               (overlay-put ov prop
-                            (get-text-property 0 prop (car strings))))
-             (overlay-put ov 'before-string nil))
-           (overlay-put ov 'face nil))
-       (dolist (prop '(display keymap mouse-face help-echo))
-         (overlay-put ov prop nil))
-       (overlay-put ov 'face 'preview-face)
-       (unless (cdr strings)
-         (setcdr strings (preview-inactive-string ov)))
-       (overlay-put ov 'before-string (cdr strings)))
-      (if old-urgent
-         (apply 'preview-add-urgentization old-urgent))))
-  (if event
-      (preview-restore-position
-       ov
-       (if (windowp event)
-          event
-        (posn-window (event-start event))))))
-
-(defun preview-mode-setup ()
-  "Setup proper buffer hooks and behavior for previews."
-  (set (make-local-variable 'desktop-save-buffer)
-       #'desktop-buffer-preview-misc-data)
-  (add-hook 'pre-command-hook #'preview-mark-point nil t)
-  (add-hook 'post-command-hook #'preview-move-point nil t)
-  (easy-menu-add preview-menu LaTeX-mode-map)
-  (unless preview-tb-icon
-    (setq preview-tb-icon (preview-filter-specs preview-tb-icon-specs)))
-  (when preview-tb-icon
-    (define-key LaTeX-mode-map [tool-bar preview]
-      `(menu-item "Preview at point" preview-at-point
-                 :image ,preview-tb-icon
-                 :help "Preview on/off at point")))
-  (when buffer-file-name
-    (let* ((filename (expand-file-name buffer-file-name))
-          format-cons)
-      (when (string-match (concat "\\." TeX-default-extension "\\'")
-                         filename)
-       (setq filename (substring filename 0 (match-beginning 0))))
-      (setq format-cons (assoc filename preview-dumped-alist))
-      (when (consp (cdr format-cons))
-       (preview-unwatch-preamble format-cons)
-       (preview-watch-preamble (current-buffer)
-                               (cadr format-cons)
-                               format-cons)))))
-
-(defvar preview-marker (make-marker)
-  "Marker for fake intangibility.")
-
-(defvar preview-temporary-opened nil)
-
-(defvar preview-last-location nil
-  "Restored cursor position marker for reopened previews.")
-(make-variable-buffer-local 'preview-last-location)
-
-(defun preview-mark-point ()
-  "Mark position for fake intangibility."
-  (when (eq (get-char-property (point) 'preview-state) 'active)
-    (unless preview-last-location
-      (setq preview-last-location (make-marker)))
-    (set-marker preview-last-location (point))
-    (set-marker preview-marker (point))
-    (preview-move-point))
-  (set-marker preview-marker (point)))
-
-(defun preview-restore-position (ov window)
-  "Tweak position after opening/closing preview.
-The treated overlay OV has been triggered in WINDOW.  This function
-records the original buffer position for reopening, or restores it
-after reopening.  Note that by using the mouse, you can open/close
-overlays not in the active window."
-  (when (eq (overlay-buffer ov) (window-buffer window))
-    (with-current-buffer (overlay-buffer ov)
-      (if (eq (overlay-get ov 'preview-state) 'active)
-         (setq preview-last-location
-               (set-marker (or preview-last-location (make-marker))
-                           (window-point window)))
-       (when (and
-              (markerp preview-last-location)
-              (eq (overlay-buffer ov) (marker-buffer preview-last-location))
-              (< (overlay-start ov) preview-last-location)
-              (> (overlay-end ov) preview-last-location))
-         (set-window-point window preview-last-location))))))
-      
-(defun preview-move-point ()
-  "Move point out of fake-intangible areas."
-  (preview-check-changes)
-  (let* (newlist (pt (point)) (lst (overlays-at pt)) distance)
-    (setq preview-temporary-opened
-         (dolist (ov preview-temporary-opened newlist)
-           (and (overlay-buffer ov)
-                (eq (overlay-get ov 'preview-state) 'inactive)
-                (if (and (eq (overlay-buffer ov) (current-buffer))
-                         (or (<= pt (overlay-start ov))
-                             (>= pt (overlay-end ov))))
-                    (preview-toggle ov t)
-                  (push ov newlist)))))
-    (when lst
-      (if (or disable-point-adjustment
-             global-disable-point-adjustment
-             (preview-auto-reveal-p
-              preview-auto-reveal
-              (setq distance
-                    (and (eq (marker-buffer preview-marker)
-                             (current-buffer))
-                         (- pt (marker-position preview-marker))))))
-         (preview-open-overlays lst)
-       (while lst
-         (setq lst
-               (if (and
-                    (eq (overlay-get (car lst) 'preview-state) 'active)
-                    (> pt (overlay-start (car lst))))
-                   (overlays-at
-                    (setq pt (if (and distance (< distance 0))
-                                 (overlay-start (car lst))
-                               (overlay-end (car lst)))))
-                 (cdr lst))))
-       (goto-char pt)))))
-
-(defun preview-open-overlays (list &optional pos)
-  "Open all previews in LIST, optionally restricted to enclosing POS."
-  (dolist (ovr list)
-    (when (and (eq (overlay-get ovr 'preview-state) 'active)
-              (or (null pos)
-                  (and
-                   (> pos (overlay-start ovr))
-                   (< pos (overlay-end ovr)))))
-      (preview-toggle ovr)
-      (push ovr preview-temporary-opened))))
-
-(defadvice replace-highlight (before preview)
-  "Make `query-replace' open preview text about to be replaced."
-  (preview-open-overlays
-   (overlays-in (ad-get-arg 0) (ad-get-arg 1))))
-
-(defcustom preview-query-replace-reveal t
-  "*Make `query-replace' autoreveal previews."
-  :group 'preview-appearance
-  :type 'boolean
-  :require 'preview
-  :set (lambda (symbol value)
-        (set-default symbol value)
-        (if value
-            (ad-enable-advice 'replace-highlight 'before 'preview)
-          (ad-disable-advice 'replace-highlight 'before 'preview))
-        (ad-activate 'replace-highlight))
-  :initialize #'custom-initialize-reset)
-
-;; Check whether the four-argument form of `face-attribute' exists.
-;; If not, we will get a `wrong-number-of-arguments' error thrown.
-;; Use `defun' instead of `defsubst' here so that the decision may be
-;; reverted at load time if you are compiling with one Emacs and using
-;; another.
-(if (condition-case nil
-       (progn
-         (face-attribute 'default :height nil nil)
-         t)
-      (wrong-number-of-arguments nil))
-
-    (defun preview-inherited-face-attribute (face attribute &optional inherit)
-      "Fetch face attribute while adhering to inheritance.
-This searches FACE for an ATTRIBUTE, using INHERIT
-for resolving unspecified or relative specs.  See the fourth
-argument of function `face-attribute' for details."
-      (face-attribute face attribute nil inherit))
-
-  (defun preview-inherited-face-attribute (face attribute &optional inherit)
-    "Fetch face attribute while adhering to inheritance.
-This searches FACE for an ATTRIBUTE.  If it is 'unspecified,
-first inheritance is consulted (if INHERIT is non-NIL), then
-INHERIT is searched if it is a face or a list of faces.
-Relative specs are evaluated recursively until they get absolute or
-are not resolvable.  Relative specs are float values."
-    (let ((value (face-attribute face attribute)))
-      (when inherit
-       (setq inherit
-             (append
-              (let ((ancestors (face-attribute face :inherit)))
-                (cond ((facep ancestors) (list ancestors))
-                      ((consp ancestors) ancestors)))
-              (cond ((facep inherit) (list inherit))
-                    ((consp inherit) inherit)))))
-      (cond ((null inherit) value)
-           ((floatp value)
-            (let ((avalue
-                   (preview-inherited-face-attribute
-                    (car inherit) attribute (or (cdr inherit) t))))
-              (cond ((integerp avalue)
-                     (round (* avalue value)))
-                    ((floatp avalue)
-                     (* value avalue))
-                    (t value))))
-           ((eq value 'unspecified)
-            (preview-inherited-face-attribute
-             (car inherit) attribute (or (cdr inherit) t)))
-           (t value)))))
-
-(defun preview-get-colors ()
-  "Return colors from the current display.
-Fetches the current screen colors and makes a vector
-of colors as numbers in the range 0..65535.
-Pure borderless black-on-white will return triple NIL.
-The fourth value is the transparent border thickness."
-  (let
-      ((bg (color-values (preview-inherited-face-attribute
-                         'preview-reference-face :background 'default)))
-       (fg (color-values (preview-inherited-face-attribute
-                         'preview-reference-face :foreground 'default)))
-       (mask (preview-get-heuristic-mask)))
-    (if (equal '(65535 65535 65535) bg)
-       (setq bg nil))
-    (if (equal '(0 0 0) fg)
-       (setq fg nil))
-    (unless (and (numberp preview-transparent-border)
-                (consp mask) (integerp (car mask)))
-      (setq mask nil))
-    (vector bg fg mask preview-transparent-border)))
-
-(defun preview-import-image (image)
-  "Convert the printable IMAGE rendition back to an image."
-  (cond ((stringp image)
-        (propertize image 'face 'preview-face))
-       ((eq (car image) 'image)
-        image)
-       (t
-        (preview-create-icon-1 (nth 0 image)
-                               (nth 1 image)
-                               (nth 2 image)
-                               (if (< (length image) 4)
-                                   (preview-get-heuristic-mask)
-                                 (nth 3 image))))))
-
-(defsubst preview-supports-image-type (imagetype)
-  "Check if IMAGETYPE is supported."
-  (image-type-available-p imagetype))
-
-(provide 'prv-emacs)
-;;; prv-emacs.el ends here
diff --git a/style/amsmath.el b/style/amsmath.el
index 0fd9817..ebae233 100644
--- a/style/amsmath.el
+++ b/style/amsmath.el
@@ -29,30 +29,11 @@
 ;; This will also load the amstext, amsbsy and amsopn style files.
 
 ;;; Code:
-(eval-when-compile (require 'cl-lib))
 
 ;; Fontification
 (declare-function font-latex-add-keywords
                  "font-latex"
                  (keywords class))
-(declare-function font-latex-update-math-env
-                 "font-latex")
-(require 'texmathp)
-(let ((list '(("equation*"     env-on)
-             ("align"         env-on) ("align*"        env-on)
-             ("gather"        env-on) ("gather*"       env-on)
-             ("multline"      env-on) ("multline*"     env-on)
-             ("flalign"       env-on) ("flalign*"      env-on)
-             ("alignat"       env-on) ("alignat*"      env-on)
-             ("xalignat"      env-on) ("xalignat*"     env-on)
-             ("xxalignat"     env-on) ("\\boxed"       arg-on)
-             ("\\text"        arg-off) ("\\intertext"   arg-off))))
-  (dolist (entry list)
-    (cl-pushnew entry texmathp-tex-commands-default :test #'equal)))
-(texmathp-compile)
-(if (and (featurep 'font-latex)
-        (eq TeX-install-font-lock 'font-latex-setup))
-    (font-latex-update-math-env))
 
 (TeX-add-style-hook
  "amsmath"
diff --git a/style/arabxetex.el b/style/arabxetex.el
index fefd63e..2dd9fc2 100644
--- a/style/arabxetex.el
+++ b/style/arabxetex.el
@@ -44,6 +44,8 @@
    (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/bidi.el b/style/bidi.el
index c000535..0638482 100644
--- a/style/bidi.el
+++ b/style/bidi.el
@@ -1,6 +1,6 @@
 ;;; bidi.el --- AUCTeX style for the (XeLaTeX) bidi package
 
-;; Copyright (C) 2016--2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2020 Free Software Foundation, Inc.
 
 ;; Author: Uwe Brauer <oub@mat.ucm.es>
 ;; Created: 2016-03-06
@@ -50,6 +50,8 @@
  "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/breqn.el b/style/breqn.el
index 22c45aa..cef8519 100644
--- a/style/breqn.el
+++ b/style/breqn.el
@@ -49,7 +49,6 @@
 ;;; Code:
 
 (require 'latex)
-(eval-when-compile (require 'cl-lib))
 
 (defvar LaTeX-breqn-key-val-options
   '(("style" ("\\tiny" "\\scriptsize" "\\footnotesize" "\\small"
@@ -96,21 +95,6 @@ Keys offered for key=val query depend on ENV.  \"label\" and
 
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
-;; Fontification
-(declare-function font-latex-update-math-env "font-latex")
-(require 'texmathp)
-(let ((list '(("dmath"         env-on) ("dmath*"        env-on)
-             ("dseries"       env-on) ("dseries*"      env-on)
-             ("dgroup"        env-on) ("dgroup*"       env-on)
-             ("darray"        env-on) ("darray*"       env-on)
-             ("dsuspend"      env-off))))
-  (dolist (entry list)
-    (cl-pushnew entry texmathp-tex-commands-default :test #'equal)))
-(texmathp-compile)
-(if (and (featurep 'font-latex)
-        (eq TeX-install-font-lock 'font-latex-setup))
-    (font-latex-update-math-env))
-
 (TeX-add-style-hook
  "breqn"
  (lambda ()
diff --git a/style/csquotes.el b/style/csquotes.el
index a34a775..8f64627 100644
--- a/style/csquotes.el
+++ b/style/csquotes.el
@@ -1,6 +1,6 @@
-;;; csquotes.el --- AUCTeX style for `csquotes.sty'
+;;; csquotes.el --- AUCTeX style for `csquotes.sty' (v5.2j)
 
-;; Copyright (C) 2004, 2005, 2006, 2014, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2006, 2014, 2018, 2020 Free Software Foundation, 
Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
@@ -26,7 +26,8 @@
 
 ;;; Commentary:
 
-;; This file adds support for `csquotes.sty', version 3.7.
+;; This file adds support for `csquotes.sty', version 5.2j from
+;; 2019/12/06.
 
 ;;; Code:
 
@@ -35,109 +36,165 @@
                  "font-latex"
                  (keywords class))
 
-;; FIXME: It would be nice to be able to dump this function in favor
-;; of a generalized handling of additional arguments for environments
-;; specified via `LaTeX-add-environments'.  `TeX-parse-arguments' and
-;; friends would be the functions to be used for that, but those
-;; functions currently insert text directly into the buffer.  There
-;; would either have to be a way of preventing this and letting them
-;; return a string, or the insertion could happen in a temporary buffer
-;; and the buffer content be returned.
-(defun LaTeX-csquotes-insert-environment (env &rest args)
-  "Insert environment ENV considering optional arguments ARGS.
-
-This is basically a variant of `LaTeX-environment-menu'
-specialized for csquotes.el.  ARGS can be made up of strings and
-vectors containing single strings.  Plain strings will be used as
-prompts for mandatory arguments and strings in vectors as prompts
-for optional arguments of the environment to be inserted.
-
-That means, in contrast to `LaTeX-environment-menu' it supports
-the insertion of optional arguments."
-  (let (env-extra prompt optional user-input)
-    (dolist (elt args)
-      (if (vectorp elt)
-         (setq prompt (aref elt 0)
-               optional t)
-       (setq prompt elt
-             optional nil))
-      (setq user-input (TeX-read-string (TeX-argument-prompt optional prompt 
nil)))
-      (unless (and optional (zerop (length user-input)))
-       (setq env-extra (concat env-extra
-                               (if optional LaTeX-optop TeX-grop)
-                               user-input
-                               (if optional LaTeX-optcl TeX-grcl)))))
-    (LaTeX-insert-environment env env-extra)))
+(defun LaTeX-csquotes-read-language (optional &optional prompt)
+  "Read and return a language for csquotes macros.
+If OPTIONAL is non-nil, indicate it in minibuffer while reading
+user input.  PROMPT replaces the standard one \"Language\".  This
+function checks if the functions `LaTeX-babel-active-languages'
+or `LaTeX-polyglossia-active-languages' are bound and use them to
+retrieve the active languages.  If none available, user is
+requested to enter a language."
+  (cond ((and (fboundp 'LaTeX-babel-active-languages)
+             (LaTeX-babel-active-languages))
+        (completing-read
+         (TeX-argument-prompt optional prompt "Language")
+         (LaTeX-babel-active-languages)))
+       ((and (fboundp 'LaTeX-polyglossia-active-languages)
+             (LaTeX-polyglossia-active-languages))
+        (completing-read
+         (TeX-argument-prompt optional prompt "Language")
+         (LaTeX-polyglossia-active-languages)))
+       (t
+        (TeX-read-string
+         (TeX-argument-prompt optional prompt "Language")))))
+
+(defun LaTeX-arg-csquotes-language (optional &optional prompt)
+  "Insert a language for csquotes macros.
+If OPTIONAL is non-nil, insert the language in square brackets.
+PROMPT replaces the standard one \"Language\"."
+  (TeX-argument-insert
+   (LaTeX-csquotes-read-language optional prompt)
+   optional))
 
 (TeX-add-style-hook
  "csquotes"
  (lambda ()
-   (let ((quote-style-variant-list '(("quotes") ("guillemets") ("american")
-                                    ("british") ("oldstyle") ("imprimerie")
-                                    ("swiss")))
-        (quote-style-name-list '(("danish") ("dutch") ("english") ("finnish")
-                                 ("french") ("german") ("italian")
-                                 ("norwegian") ("swedish"))))
+   (let ((quote-style-variant-list '(("american")   ("brazilian")
+                                    ("british")    ("german")
+                                    ("guillemets") ("guillemets*")
+                                    ("mexican")    ("portuguese")
+                                    ("quotes")     ("quotes*")
+                                    ("spanish")    ("swiss")))
+        (quote-style-name-list '(("austrian")   ("croatian") ("czech")
+                                 ("danish")     ("dutch")    ("english")
+                                 ("finnish")    ("french")   ("german")
+                                 ("greek")      ("italian")  ("norwegian")
+                                 ("portuguese") ("russian")  ("serbian")
+                                 ("spanish")    ("swedish"))))
      ;; New symbols
      (TeX-add-symbols
+
+      ;; 3.1 Quoting Regular Text
       '("enquote" 1)
       '("enquote*" 1)
-      '("foreignquote" 2)
-      '("foreignquote*" 2)
-      '("hyphenquote" 2)
-      '("hyphenquote*" 2)
-      '("textquote" ["Citation"] ["Punctuation"] t)
+
+      ;; 3.2 Quoting Text in a Foreign Language
+      '("foreignquote"  LaTeX-arg-csquotes-language 1)
+      '("foreignquote*" LaTeX-arg-csquotes-language 1)
+      '("hyphenquote"   LaTeX-arg-csquotes-language 1)
+      '("hyphenquote*"  LaTeX-arg-csquotes-language 1)
+
+      ;; 3.3 Formal Quoting of Regular Text
+      '("textquote"  ["Citation"] ["Punctuation"] t)
       '("textquote*" ["Citation"] ["Punctuation"] t)
-      '("foreigntextquote" "Language" ["Citation"] ["Punctuation"] t)
-      '("foreigntextquote*" "Language" ["Citation"] ["Punctuation"] t)
-      '("hyphentextquote" "Language" ["Citation"] ["Punctuation"] t)
-      '("hyphentextquote*" "Language" ["Citation"] ["Punctuation"] t)
+
+      ;; 3.4 Formal Quoting of Text in a Foreign Language
+      '("foreigntextquote"
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+      '("foreigntextquote*"
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+      '("hyphentextquote"
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+      '("hyphentextquote*"
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+
+      ;; 3.5 Block Quoting of Regular Text
       '("blockquote" ["Citation"] ["Punctuation"] t)
-      '("foreignblockquote" "Language" ["Citation"] ["Punctuation"] t)
-      '("hyphenblockquote" "Language" ["Citation"] ["Punctuation"] t)
+
+      ;; 3.6 Block Quoting of Text in a Foreign Language
+      '("foreignblockquote"
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+      '("hyphenblockquote"
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+      '("hybridblockquote"
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+
+      ;; 3.7 Selecting Quote Styles
       `("setquotestyle"
        [ (TeX-arg-eval completing-read "Quote style variant: "
                        ',quote-style-variant-list) ]
        (TeX-arg-eval completing-read "Quote style name or alias: "
                      ',quote-style-name-list))
       "setquotestyle*"
+
+      ;; 4.1 Quoting Regular Text
       '("MakeInnerQuote" "Character")
       '("MakeOuterQuote" "Character")
-      '("MakeAutoQuote" "Opening quotation mark" "Closing quotation mark")
+      '("MakeAutoQuote"  "Opening quotation mark" "Closing quotation mark")
       '("MakeAutoQuote*" "Opening quotation mark" "Closing quotation mark")
-      '("MakeForeignQuote" "Babel's language name"
+
+      ;; 4.2 Quoting Text in a Foreign Language
+      '("MakeForeignQuote" LaTeX-arg-csquotes-language
        "Opening quotation mark" "Closing quotation mark")
-      '("MakeForeignQuote*" "Babel's language name"
+      '("MakeForeignQuote*" LaTeX-arg-csquotes-language
        "Opening quotation mark" "Closing quotation mark")
-      '("MakeHyphenQuote" "Babel's language name"
+
+      '("MakeHyphenQuote" LaTeX-arg-csquotes-language
        "Opening quotation mark" "Closing quotation mark")
-      '("MakeHyphenQuote" "Babel's language name"
+      '("MakeHyphenQuote" LaTeX-arg-csquotes-language
        "Opening quotation mark" "Closing quotation mark")
+
+      ;; 4.3 Block Quoting of Regular Text
       '("MakeBlockQuote" "Opening quotation mark" "Delimiter for citation"
        "Closing quotation mark")
-      '("MakeForeignBlockQuote" "Language" "Opening quotation mark"
-       "Delimiter for citation" "Closing quotation mark")
-      '("MakeHyphenBlockQuote" "Language" "Opening quotation mark"
-       "Delimiter for citation" "Closing quotation mark")
+
+      ;; 4.4 Block Quoting of Text in a Foreign Language
+      '("MakeForeignBlockQuote" LaTeX-arg-csquotes-language
+       "Opening quotation mark" "Delimiter for citation" "Closing quotation 
mark")
+      '("MakeHyphenBlockQuote" LaTeX-arg-csquotes-language
+       "Opening quotation mark" "Delimiter for citation" "Closing quotation 
mark")
+      '("MakeHybridBlockQuote" LaTeX-arg-csquotes-language
+       "Opening quotation mark" "Delimiter for citation" "Closing quotation 
mark")
+
+      ;; 4.5 Controlling Active Quotes
       "EnableQuotes"
       "DisableQuotes"
       "VerbatimQuotes"
       "DeleteQuotes"
-      '("textcquote" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+
+      ;; 5.1 Formal Quoting of Regular Text
+      '("textcquote"  ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
       '("textcquote*" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
-      '("foreigntextcquote" "Language" ["Pre-note"] ["Post-note"] "Key"
-       ["Punctuation"] t)
-      '("foreigntextcquote*" "Language" ["Pre-note"] ["Post-note"] "Key"
-       ["Punctuation"] t)
-      '("hyphentextcquote" "Language" ["Pre-note"] ["Post-note"] "Key"
-       ["Punctuation"] t)
-      '("hyphentextcquote*" "Language" ["Pre-note"] ["Post-note"] "Key"
-       ["Punctuation"] t)
+
+      ;; 5.2 Formal Quoting of Text in a Foreign Language
+      '("foreigntextcquote" LaTeX-arg-csquotes-language
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+      '("foreigntextcquote*" LaTeX-arg-csquotes-language
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+      '("hyphentextcquote" LaTeX-arg-csquotes-language
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+      '("hyphentextcquote*" LaTeX-arg-csquotes-language
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+
+      ;; 5.3 Block Quoting of Regular Text
       '("blockcquote" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
-      '("foreignblockcquote" "Language" ["Pre-note"] ["Post-note"] "Key"
-       ["Punctuation"] t)
-      '("hyphenblockcquote" "Language" ["Pre-note"] ["Post-note"] "Key"
-       ["Punctuation"] t)
+
+      ;; 5.4 Block Quoting of Text in a Foreign Language
+      '("foreignblockcquote" LaTeX-arg-csquotes-language
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+      '("hyphenblockcquote" LaTeX-arg-csquotes-language
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+      '("hybridblockcquote" LaTeX-arg-csquotes-language
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
+
+      ;; 7 Auxiliary Commands
+      '("textelp" 1)
+      '("textelp*" 1)
+      '("textins" 1)
+      '("textins*" 1)
+      '("textdel" 1)
+
+      ;; 8.1 Defining Quote Styles
       `("DeclareQuoteStyle"
        [ (TeX-arg-eval completing-read "Quote style variant: "
                        ',quote-style-variant-list) ]
@@ -154,97 +211,178 @@ the insertion of optional arguments."
        (TeX-arg-eval completing-read "Quote style name: "
                      ',quote-style-name-list)
        "Alias name")
-    '("DeclareQuoteOption" 1)
-    '("ExecuteQuoteOptions" 1)
-    '("DeclarePlainStyle" "Opening outer quotation mark"
-      "Closing outer quotation mark" "Opening inner quotation mark"
-      "Closing inner quotation mark")
-    '("SetBlockThreshold" "Number of lines")
-    '("SetBlockEnvironment" "Environment")
-    '("SetCiteCommand" "Command")
-    "mkcitation"
-    "mkccitation"
-    "mkpreblockpunct"
-    "mkmidblockpunct"
-    "mkfinblockpunct"
-    "mkpretextpunct"
-    "mkmidtextpunct"
-    "mkfintextpunct"
-    "mkpredisppunct"
-    "mkmiddisppunct"
-    "mkfindisppunct"
-    '("ifblockquote" 2)
-    '("ifquotepunct" 2)
-    '("ifquoteterm" 2)
-    '("ifquoteperiod" 2)
-    '("ifquotecomma" 2)
-    '("ifquotesemicolon" 2)
-    '("ifquotecolon" 2)
-    '("ifquoteexclam" 2)
-    '("ifquotequestion" 2)
-    '("ifstringblank" 2)
-    '("BlockquoteDisable" 1))
-   ;; New environments
-   (LaTeX-add-environments
-    "quoteblock"
-    "quotetext"
-    '("displayquote" LaTeX-csquotes-insert-environment ["Citation"]
-      ["Punctuation"])
-    '("foreigndisplayquote" LaTeX-csquotes-insert-environment "Language"
-      ["Citation"] ["Punctuation"])
-    '("hyphendisplayquote" LaTeX-csquotes-insert-environment "Language"
-      ["Citation"] ["Punctuation"])
-    '("displaycquote" LaTeX-csquotes-insert-environment
-      ["Pre-note"] ["Post-note"] "Key" ["Punctuation"])
-    '("foreigndisplaycquote" LaTeX-csquotes-insert-environment
-      "Language" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"])
-    '("hyphendisplaycquote" LaTeX-csquotes-insert-environment
-      "Language" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"]))
-   ;; Quotation marks
-   (when (and (> (length LaTeX-csquotes-open-quote) 0)
-             (> (length LaTeX-csquotes-close-quote) 0))
-     (setq TeX-quote-language
-          `(override ,LaTeX-csquotes-open-quote ,LaTeX-csquotes-close-quote
-                     ,LaTeX-csquotes-quote-after-quote)))
-   ;; Fontification
-   (when (and (featurep 'font-latex)
-             (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("DisableQuotes" "")
-                               ("RestoreQuotes" ""))
-                             'function)
-     (font-latex-add-keywords '(("enquote" "*{")
-                               ("foreignquote" "*{{")
-                               ("hyphenquote" "*{{")
-                               ("textcquote" "*[[{[{")
-                               ("foreigntextcquote" "*{[[{[{")
-                               ("hyphentextcquote" "*{[[{[{")
-                               ("textquote" "*[[{")
-                               ("foreigntextquote" "*{[[{")
-                               ("hyphentextquote" "*{[[{")
-                               ("blockquote" "[[{")
-                               ("foreignblockquote" "{[[{")
-                               ("hyphenblockquote" "{[[{")
-                               ("blockcquote" "[[{[{")
-                               ("foreignblockcquote" "{[[{[{")
-                               ("hyphenblockcquote" "{[[{[{"))
-                             'textual)
-     (font-latex-add-keywords '(("setquotestyle" "[{")
-                               ("MakeOuterQuote" "{")
-                               ("MakeInnerQuote" "{")
-                               ("MakeAutoQuote" "*{{")
-                               ("MakeForeignQuote" "*{{{")
-                               ("MakeHyphenQuote" "*{{{")
-                               ("MakeBlockQuote" "{{{")
-                               ("MakeForeignBlockQuote" "{{{{")
-                               ("MakeHyphenBlockQuote" "{{{{")
-                               ("DeclareQuoteStyle" "[{[[{[{[{[{")
-                               ("DeclareQuoteAlias" "[{{")
-                               ("DeclareQuoteOption" "{")
-                               ("DeclarePlainStyle" "{{{{")
-                               ("SetBlockThreshold" "{")
-                               ("SetBlockEnvironment" "{")
-                               ("SetCiteCommand" "{"))
-                             'variable))))
+      '("DeclareQuoteOption" 1)
+      '("ExecuteQuoteOptions" 1)
+      '("DeclarePlainStyle" "Opening outer quotation mark"
+       "Closing outer quotation mark" "Opening inner quotation mark"
+       "Closing inner quotation mark")
+      '("SetBlockThreshold" "Number of lines")
+      '("SetBlockEnvironment" "Environment")
+      '("SetCiteCommand" "Command")
+
+      ;; 8.7 Hooks for Quotations and Citations
+      "mkcitation"
+      "mkccitation"
+      "mktextquote"
+      "mkblockquote"
+      "mkbegdispquote"
+      "mkenddispquote"
+
+      ;; 8.8 Additional Tests in Quotation Hooks
+      '("ifpunctmark" "Character" 2)
+      '("ifpunct" 2)
+      '("ifterm" 2)
+      '("iftextpunctmark" 4)
+      '("iftextpunct" 3)
+      '("iftextterm" 3)
+      '("ifblockquote" 2)
+      '("ifblank" 3)
+      "unspace"
+
+      ;; 8.9 Configuring Punctuation Look-Ahead
+      '("DeclareAutoPunct" "Characters"))
+
+     ;; New environments
+     (LaTeX-add-environments
+
+      ;; 6.1 Basic Display Environments
+      '("displayquote" LaTeX-env-args
+       ["Citation"] ["Punctuation"])
+
+      '("foreigndisplayquote" LaTeX-env-args
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"])
+
+      '("hyphendisplayquote" LaTeX-env-args
+       LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"])
+
+      ;; 6.2 Integrated Display Environments
+      '("displaycquote" LaTeX-env-args
+       ["Pre-note"] ["Post-note"] "Key" ["Punctuation"])
+
+      '("foreigndisplaycquote" LaTeX-env-args
+       LaTeX-arg-csquotes-language["Pre-note"] ["Post-note"] "Key" 
["Punctuation"])
+
+      '("hyphendisplaycquote" LaTeX-env-args
+       LaTeX-arg-csquotes-language["Pre-note"] ["Post-note"] "Key" 
["Punctuation"]))
+
+     ;; Quotation marks
+     (when (and (> (length LaTeX-csquotes-open-quote) 0)
+               (> (length LaTeX-csquotes-close-quote) 0))
+       (setq TeX-quote-language
+            `(override ,LaTeX-csquotes-open-quote ,LaTeX-csquotes-close-quote
+                       ,LaTeX-csquotes-quote-after-quote)))
+     ;; Fontification
+     (when (and (featurep 'font-latex)
+               (eq TeX-install-font-lock 'font-latex-setup))
+       (font-latex-add-keywords '(("EnableQuotes"   "")
+                                 ("DisableQuotes"  "")
+                                 ("VerbatimQuotes" "")
+                                 ("DeleteQuotes"   ""))
+                               'function)
+       (font-latex-add-keywords '(("enquote"            "*{")
+                                 ("foreignquote"       "*{{")
+                                 ("hyphenquote"        "*{{")
+                                 ("textquote"          "*[[{")
+                                 ("foreigntextquote"   "*{[[{")
+                                 ("hyphentextquote"    "*{[[{")
+                                 ("blockquote"         "[[{")
+                                 ("foreignblockquote"  "{[[{")
+                                 ("hyphenblockquote"   "{[[{")
+                                 ("hybridblockquote"   "{[[{")
+                                 ("textcquote"         "*[[{[{")
+                                 ("foreigntextcquote"  "*{[[{[{")
+                                 ("hyphentextcquote"   "*{[[{[{")
+                                 ("blockcquote"        "[[{[{")
+                                 ("foreignblockcquote" "{[[{[{")
+                                 ("hyphenblockcquote"  "{[[{[{")
+                                 ("hybridblockcquote"  "{[[{[{"))
+                               'textual)
+       (font-latex-add-keywords '(("setquotestyle"         "[{")
+                                 ("MakeOuterQuote"        "{")
+                                 ("MakeInnerQuote"        "{")
+                                 ("MakeAutoQuote"         "*{{")
+                                 ("MakeForeignQuote"      "*{{{")
+                                 ("MakeHyphenQuote"       "*{{{")
+                                 ("MakeBlockQuote"        "{{{")
+                                 ("MakeForeignBlockQuote" "{{{{")
+                                 ("MakeHyphenBlockQuote"  "{{{{")
+                                 ("DeclareQuoteStyle"     "[{[[{[{[{[{")
+                                 ("DeclareQuoteAlias"     "[{{")
+                                 ("DeclareQuoteOption"    "{")
+                                 ("DeclarePlainStyle"     "{{{{")
+                                 ("SetBlockThreshold"     "{")
+                                 ("SetBlockEnvironment"   "{")
+                                 ("SetCiteCommand"        "{"))
+                               'variable))))
  LaTeX-dialect)
 
+(defun LaTeX-csquotes-package-options ()
+  "Prompt for package options for the csquotes package."
+  (TeX-read-key-val t '(("strict"     ("true" "false"))
+                       ("style"      ("american"
+                                      "australian"
+                                      "austrian"
+                                      "brazil"
+                                      "brazilian"
+                                      "british"
+                                      "canadian"
+                                      "croatian"
+                                      "czech"
+                                      "danish"
+                                      "dutch"
+                                      "english"
+                                      "finnish"
+                                      "french"
+                                      "german"
+                                      "greek"
+                                      "italian"
+                                      "mexican"
+                                      "naustrian"
+                                      "newzealand"
+                                      "ngerman"
+                                      "norsk"
+                                      "norwegian"
+                                      "nswissgerman"
+                                      "nynorsk"
+                                      "portuges"
+                                      "portuguese"
+                                      "russian"
+                                      "serbian"
+                                      "spanish"
+                                      "swedish"
+                                      "swiss"
+                                      "swissgerman"
+                                      "UKenglish"
+                                      "USenglish"))
+                       ("autostyle"  ("true" "false" "try" "once" "tryonce"))
+                       ("austrian"   ("quotes" "guillemets"))
+                       ("croatian"   ("quotes" "guillemets" "guillemets*"))
+                       ("czech"      ("quotes" "guillemets"))
+                       ("danish"     ("quotes" "guillemets" "topquotes"))
+                       ("english"    ("american" "british"))
+                       ("estonian")
+                       ("french"     ("quotes" "quotes*" "guillemets" 
"guillemets*"))
+                       ("galician"   ("quotes" "guillemets"))
+                       ("german"     ("quotes" "guillemets" "swiss"))
+                       ("hungarian")
+                       ("italian"    ("guillemets" "quotes"))
+                       ("latvian")
+                       ("norwegian"  ("guillemets" "quotes"))
+                       ("polish"     ("guillemets" "guillemets*"))
+                       ("portuguese" ("portuguese" "brazilian"))
+                       ("serbian"    ("quotes" "guillemets" "german"))
+                       ("spanish"    ("spanish" "mexican"))
+                       ("swedish"    ("quotes" "guillemets" "guillemets*"))
+                       ("maxlevel")
+                       ("autopunct"     ("true" "false"))
+                       ("threshold")
+                       ("thresholdtype" ("lines" "words"))
+                       ("parthreshold"  ("true" "false"))
+                       ("splitcomp"     ("true" "false"))
+                       ("csdisplay"     ("true" "false"))
+                       ("debug"         ("true" "false"))
+                       ;; "babel" key is deprecated, replaced by "autostyle":
+                       ;; ("babel" ("true" "false" "try" "once" "tryonce"))
+                       ("version"       ("4.4" "3.6" "3.0")))))
+
 ;;; csquotes.el ends here
diff --git a/style/dinbrief.el b/style/dinbrief.el
index 8c08b66..6375afd 100644
--- a/style/dinbrief.el
+++ b/style/dinbrief.el
@@ -1,6 +1,6 @@
 ;;; dinbrief.el --- Special code for LaTeX-Style dinbrief.
 
-;; Copyright (C) 1994, 2013, 2014, 2018  Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2013, 2014, 2018, 2020 Free Software Foundation, Inc.
 
 ;; Author: Werner Fink <werner@suse.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -33,36 +33,36 @@
 
 (require 'tex)
 
-(TeX-add-style-hook "dinbrief"
- (function
-  (lambda ()
-    (add-hook 'LaTeX-document-style-hook
-     'LaTeX-dinbrief-style)
-    (LaTeX-add-environments
-     '("letter" LaTeX-dinbrief-env-recipient)
-     "dinquote")
-    (TeX-add-symbols
-     '("address" "Absender: ")
-     '("postremark" "Postvermerk: ")
-     '("date" "Datum: ")
-     '("subject" "Betreff: ")
-     '("handling" "Behandlungsvermerk: ")
-     '("cc" "Verteiler: ")
-     '("place" "Heutiger Ort: ")
-     "makelabels"
-     "nowindowrules"
-     "windowrules"
-     "nowindowtics"
-     "windowtics"
-     "disabledraftstandard"
-     "enabledraftstandard"
-     "centeraddress"
-     "normaladdress"
-     '("encl" "Anlagen: ")
-     '("backaddress" "Retouradresse: ")
-     '("signature" "Unterschrift: ")
-     '("opening" "Anrede: ")
-     '("closing" "Schluss: "))))
+(TeX-add-style-hook
+ "dinbrief"
+ (lambda ()
+   (add-hook 'LaTeX-document-style-hook
+            'LaTeX-dinbrief-style)
+   (LaTeX-add-environments
+    '("letter" LaTeX-dinbrief-env-recipient)
+    "dinquote")
+   (TeX-add-symbols
+    '("address" "Absender")
+    '("postremark" "Postvermerk")
+    '("date" "Datum")
+    '("subject" "Betreff")
+    '("handling" "Behandlungsvermerk")
+    '("cc" "Verteiler")
+    '("place" "Heutiger Ort")
+    "makelabels"
+    "nowindowrules"
+    "windowrules"
+    "nowindowtics"
+    "windowtics"
+    "disabledraftstandard"
+    "enabledraftstandard"
+    "centeraddress"
+    "normaladdress"
+    '("encl" "Anlagen: ")
+    '("backaddress" "Retouradresse")
+    '("signature" "Unterschrift")
+    '("opening" "Anrede")
+    '("closing" "Schluss")))
  LaTeX-dialect)
 
 (defmacro LaTeX-dinbrief-insert (&rest args)
@@ -72,43 +72,45 @@
 
 (defun LaTeX-dinbrief-style ()
   "Insert some useful packages for writing german letters."
-  (save-excursion
-    (goto-char (point-min)) ; insert before \begin{document}
-    (if (re-search-forward ".begin.document." (point-max) t)
-        (beginning-of-line 1))
-    (open-line 2)
-    (indent-relative-maybe)
+  (let ((func (if (fboundp 'indent-relative-first-indent-point)
+                 'indent-relative-first-indent-point
+               'indent-relative-maybe)))
+    (save-excursion
+      (goto-char (point-min)) ; insert before \begin{document}
+      (if (re-search-forward ".begin.document." (point-max) t)
+          (beginning-of-line 1))
+      (open-line 2)
+      (funcall func)
       (LaTeX-dinbrief-insert TeX-esc "usepackage"
-             LaTeX-optop "latin1,utf8" LaTeX-optcl
-             TeX-grop "inputenc" TeX-grcl)
+                            LaTeX-optop "latin1,utf8" LaTeX-optcl
+                            TeX-grop "inputenc" TeX-grcl)
       (newline-and-indent)
       (LaTeX-dinbrief-insert TeX-esc "usepackage"
-             LaTeX-optop "T1" LaTeX-optcl
-             TeX-grop "fontenc" TeX-grcl)
-      (newline-and-indent)
+                            LaTeX-optop "T1" LaTeX-optcl
+                            TeX-grop "fontenc" TeX-grcl)
+      (funcall func)
       (LaTeX-dinbrief-insert TeX-esc "usepackage"
-             TeX-grop "ngerman" TeX-grcl)
-      (TeX-run-style-hooks "inputenc")
-      (TeX-run-style-hooks "fontenc")
-      (TeX-run-style-hooks "ngerman")))
+                            TeX-grop "ngerman" TeX-grcl))
+    (TeX-run-style-hooks "inputenc" "fontenc" "ngerman")))
 
 (defun LaTeX-dinbrief-env-recipient (environment)
   "Insert ENVIRONMENT and prompt for recipient and address."
-  (let (
-       (sender (LaTeX-dinbrief-sender))
+  (let ((sender (LaTeX-dinbrief-sender))
        (recipient (TeX-read-string "Empfänger: "))
        (address (LaTeX-dinbrief-recipient))
        (date (TeX-read-string "Datum: " (LaTeX-dinbrief-today)))
        (postremark (TeX-read-string "Postvermerk: "))
-       (fenster (TeX-read-string "Fenster \(ja/nein\): "))
+       (fenster (TeX-read-string "Fenster (ja/nein): "))
        (vermerk (TeX-read-string "Behandlungsvermerk: "))
        (verteil (TeX-read-string "Verteiler: "))
        (betreff (TeX-read-string "Betreff: "))
        (opening (TeX-read-string "Anrede: "))
        (closing (TeX-read-string "Schluss: "))
        (signature (TeX-read-string "Unterschrift: "))
-       (anlage (TeX-read-string "Anlagen: ")))
-
+       (anlage (TeX-read-string "Anlagen: "))
+       (func (if (fboundp 'indent-relative-first-indent-point)
+                 'indent-relative-first-indent-point
+               'indent-relative-maybe)))
     (if (string= fenster "ja")
        (progn
          (LaTeX-dinbrief-insert TeX-esc "enabledraftstandard")
@@ -121,11 +123,11 @@
          (newline-and-indent)
          (let ((retouradr (TeX-read-string "Retouradresse: " sender)))
            (newline-and-indent)
-         (if (not (zerop (length retouradr)))
-             (progn
-               (if mark-active (deactivate-mark))
-               (LaTeX-dinbrief-insert TeX-esc "backaddress" TeX-grop retouradr 
TeX-grcl)
-               (newline-and-indent)))))
+           (if (not (zerop (length retouradr)))
+               (progn
+                 (if mark-active (deactivate-mark))
+                 (LaTeX-dinbrief-insert TeX-esc "backaddress" TeX-grop 
retouradr TeX-grcl)
+                 (newline-and-indent)))))
       (LaTeX-dinbrief-insert TeX-esc "enabledraftstandard")
       (newline-and-indent)
       (LaTeX-dinbrief-insert TeX-esc "centeraddress")
@@ -133,7 +135,7 @@
       (LaTeX-dinbrief-insert TeX-esc "nowindowrules")
       (newline-and-indent)
       (LaTeX-dinbrief-insert TeX-esc "windowtics"))
-      (newline-and-indent)
+    (newline-and-indent)
     (if (not (zerop (length signature)))
        (progn
          (LaTeX-dinbrief-insert TeX-esc "signature" TeX-grop signature 
TeX-grcl)
@@ -189,21 +191,21 @@
          (LaTeX-dinbrief-insert TeX-esc "encl" TeX-grop anlage TeX-grcl)
          (newline-and-indent)))
     (LaTeX-dinbrief-insert TeX-esc "opening"
-           TeX-grop
-           (if (zerop (length opening))
-               (concat TeX-esc " ")
-             opening)
-           TeX-grcl "\n")
+                          TeX-grop
+                          (if (zerop (length opening))
+                              (concat TeX-esc " ")
+                            opening)
+                          TeX-grcl "\n")
 
-    (indent-relative-maybe)
+    (funcall func)
     (save-excursion
       (LaTeX-dinbrief-insert "\n" TeX-esc "closing"
-             TeX-grop
-             (if (zerop (length closing))
-                 (concat TeX-esc " ")
-               closing)
-             TeX-grcl "\n")
-      (indent-relative-maybe))))
+                            TeX-grop
+                            (if (zerop (length closing))
+                                (concat TeX-esc " ")
+                              closing)
+                            TeX-grcl "\n")
+      (funcall func))))
 
 (defun LaTeX-dinbrief-sender ()
   "Read and write the senders address."
@@ -216,7 +218,7 @@
          (goto-char (point-min)) ; insert before \end{document}
          (if (re-search-forward ".end.document." (point-max) t)
              (beginning-of-line 1))
-         (previous-line 1)             ;FIXME: Use forward-line!
+         (forward-line -1)
          (LaTeX-dinbrief-insert TeX-esc "address" TeX-grop name)
          (if (not (zerop (length str)))
              (progn
diff --git a/style/empheq.el b/style/empheq.el
index 9add6c4..749964a 100644
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -41,8 +41,6 @@
 (declare-function font-latex-add-keywords
                  "font-latex"
                  (keywords class))
-(declare-function font-latex-update-math-env
-                 "font-latex")
 
 (declare-function LaTeX-item-equation-alignat
                  "amsmath" (&optional suppress))
@@ -276,24 +274,6 @@ number of ampersands if possible."
       (save-excursion
        (insert (make-string (+ ncols ncols -1) ?&))))))
 
-;; Fontification
-(require 'texmathp)
-(let ((list '(("empheq"        env-on)
-             ;; XXX: Should we add the remaining entries only when
-             ;; "overload" or "overload2" option is given?
-             ("AmSequation"   env-on) ("AmSequation*"  env-on)
-             ("AmSalign"      env-on) ("AmSalign*"     env-on)
-             ("AmSgather"     env-on) ("AmSgather*"    env-on)
-             ("AmSmultline"   env-on) ("AmSmultline*"  env-on)
-             ("AmSflalign"    env-on) ("AmSflalign*"   env-on)
-             ("AmSalignat"    env-on) ("AmSalignat*"   env-on))))
-  (dolist (entry list)
-    (cl-pushnew entry texmathp-tex-commands-default :test #'equal)))
-(texmathp-compile)
-(if (and (featurep 'font-latex)
-        (eq TeX-install-font-lock 'font-latex-setup))
-    (font-latex-update-math-env))
-
 (TeX-add-style-hook
  "empheq"
  (lambda ()
diff --git a/style/exam.el b/style/exam.el
index 3ecc38d..76bff4b 100644
--- a/style/exam.el
+++ b/style/exam.el
@@ -122,14 +122,16 @@ Arguments NAME and TYPE are the same as for the function
 
    ;; Append us only once:
    (unless (and (string-match "question" LaTeX-item-regexp)
-                (string-match "subsub" LaTeX-item-regexp))
+                (string-match "sub" LaTeX-item-regexp))
      (set (make-local-variable 'LaTeX-item-regexp)
           (concat
            LaTeX-item-regexp
            "\\|"
+          "choice\\b"
+          "\\|"
            "\\(titled\\)?question\\b"
            "\\|"
-           "\\(sub\\|subsub\\)?part\\b"))
+           "\\(sub\\)*part\\b"))
      (LaTeX-set-paragraph-start))
 
    (TeX-add-symbols
diff --git a/style/fontspec.el b/style/fontspec.el
index 0688e98..44bc167 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -1,6 +1,6 @@
 ;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.6a.
 
-;; Copyright (C) 2013, 2017, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2017, 2018, 2020 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano <mose@gnu.org>
@@ -253,6 +253,8 @@ 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")
 
diff --git a/style/ifluatex.el b/style/ifluatex.el
index 20d3c8d..246bc22 100644
--- a/style/ifluatex.el
+++ b/style/ifluatex.el
@@ -1,6 +1,6 @@
 ;;; ifluatex.el --- AUCTeX style for `ifluatex.sty' version 1.3.
 
-;; Copyright (C) 2014, 2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2016, 2018, 2020 Free Software Foundation, Inc.
 
 ;; Author: Davide G. M. Salvetti <salve@debian.org>
 ;; Maintainer: auctex-devel@gnu.org
diff --git a/style/kpfonts.el b/style/kpfonts.el
index 2e8ffc3..4938416 100644
--- a/style/kpfonts.el
+++ b/style/kpfonts.el
@@ -1,9 +1,9 @@
 ;;; kpfonts.el --- AUCTeX style for `kpfonts.sty' version 3.31.
 
-;; Copyright (C) 2013, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2018, 2020 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.
@@ -33,6 +33,9 @@
 (declare-function font-latex-add-keywords
                  "font-latex"
                  (keywords class))
+;; These are generated by the minor mode or easy menu:
+(defvar LaTeX-kpfonts-mode-map)
+(defvar LaTeX-kpfonts-mode-menu)
 
 ;;; Kpfonts Minor Mode (heavily based on LaTeX Math Minor Mode code)
 
diff --git a/style/letter.el b/style/letter.el
index 5757b06..e2cc8be 100644
--- a/style/letter.el
+++ b/style/letter.el
@@ -1,6 +1,6 @@
 ;;; letter.el - Special code for letter style.
 
-;; Copyright (C) 1993, 2012, 2013, 2014, 2018  Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2012, 2013, 2014, 2018, 2020 Free Software Foundation, 
Inc.
 
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Maintainer: auctex-devel@gnu.org
@@ -49,11 +49,11 @@
    (LaTeX-add-pagestyles "headings" "firstpage")
    (setq LaTeX-default-document-environment "letter")
    (TeX-add-symbols
-    '("name" "Sender: ")
-    '("address" "Sender address: ")
-    '("signature" "Signature: ")
-    '("opening" "Opening: ")
-    '("closing" "Closing: ")
+    '("name" "Sender")
+    '("address" "Sender address")
+    '("signature" "Signature")
+    '("opening" "Opening")
+    '("closing" "Closing")
     "location"
     "telephone"
     "makelabels"
@@ -92,13 +92,16 @@
   "Insert ENVIRONMENT and prompt for recipient and address."
   (let ((sender (TeX-read-string "Sender: " (user-full-name)))
        (sender-address (TeX-read-string "Sender address: "
-                                    LaTeX-letter-sender-address))
+                                        LaTeX-letter-sender-address))
        (recipient (TeX-read-string "Recipient: "))
        (address (TeX-read-string "Recipient address: "))
        (signature (TeX-read-string "Signature: "))
        (opening (TeX-read-string "Opening: "))
        (closing (TeX-read-string "Closing: "))
-       (date (TeX-read-string "Date: " (LaTeX-today))))
+       (date (TeX-read-string "Date: " (LaTeX-today)))
+       (func (if (fboundp 'indent-relative-first-indent-point)
+                 'indent-relative-first-indent-point
+               'indent-relative-maybe)))
 
     (insert TeX-esc "name" TeX-grop sender TeX-grcl)
     (newline-and-indent)
@@ -148,7 +151,7 @@
              opening)
            TeX-grcl "\n")
 
-    (indent-relative-maybe)
+    (funcall func)
     (save-excursion
       (insert "\n" TeX-esc "closing"
              TeX-grop
@@ -156,7 +159,7 @@
                  (concat TeX-esc " ")
                closing)
              TeX-grcl "\n")
-      (indent-relative-maybe))))
+      (funcall func))))
 
 (defun LaTeX-today nil
   "Return a string representing todays date according to flavor."
diff --git a/style/mathtools.el b/style/mathtools.el
index 5695f11..5ee9c96 100644
--- a/style/mathtools.el
+++ b/style/mathtools.el
@@ -39,8 +39,6 @@
 ;; Needed for auto-parsing:
 (require 'tex)
 
-(eval-when-compile (require 'cl-lib))
-
 ;; Silence the compiler:
 (declare-function font-latex-add-keywords
                  "font-latex"
@@ -237,12 +235,6 @@ Put line break macro on the last line.  Next, insert an 
ampersand."
   (save-excursion
     (insert ?&)))
 
-;; Fontification
-(require 'texmathp)
-(cl-pushnew '("\\shortintertext" arg-off)
-           texmathp-tex-commands-default :test #'equal)
-(texmathp-compile)
-
 (TeX-add-style-hook
  "mathtools"
  (lambda ()
diff --git a/style/polyglossia.el b/style/polyglossia.el
index c9366d0..b9aa3d4 100644
--- a/style/polyglossia.el
+++ b/style/polyglossia.el
@@ -231,6 +231,8 @@ 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/pstricks.el b/style/pstricks.el
index 33652f9..1a24767 100644
--- a/style/pstricks.el
+++ b/style/pstricks.el
@@ -1,6 +1,7 @@
 ;;; pstricks.el --- AUCTeX style for the `pstricks' package.
 
-;; Copyright (C) 2007, 2009, 2013-2015, 2018  Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2009, 2013-2015, 2018, 2020
+;;                Free Software Foundation, Inc.
 
 ;; Author: Holger Sparr <holger.sparr@gmx.net>
 ;; Maintainer: auctex-devel@gnu.org
@@ -781,7 +782,11 @@ comma separated list. Point has to be within the sexp to 
modify."
  (lambda ()
    (unless (or (member "pst-pdf" TeX-active-styles)
               (eq TeX-engine 'xetex))
-     (TeX-PDF-mode-off))
+     ;; Leave at user's choice whether to disable `TeX-PDF-mode' or
+     ;; not. Instead set up `TeX-PDF-from-DVI' option so that AUCTeX
+     ;; takes dvips+ps2pdf route when `TeX-PDF-mode' is enabled.
+     ;; (TeX-PDF-mode-off)
+     (setq TeX-PDF-from-DVI "Dvips"))
    (mapc 'TeX-auto-add-regexp LaTeX-auto-pstricks-regexp-list)
    (LaTeX-add-environments
     '("pspicture" LaTeX-pst-env-pspicture)
diff --git a/style/shortvrb.el b/style/shortvrb.el
index a8cf2a1..932df29 100644
--- a/style/shortvrb.el
+++ b/style/shortvrb.el
@@ -49,6 +49,15 @@
 (TeX-add-style-hook
  "shortvrb"
  (lambda ()
+
+   ;; Ispell: Add entries to `ispell-tex-skip-alist':
+   (when LaTeX-shortvrb-chars
+     (TeX-ispell-skip-setcar
+      (mapcar (lambda (char)
+               (let ((str (char-to-string char)))
+                 (cons str str)))
+             LaTeX-shortvrb-chars)))
+
    ;; Fontification
    (when (and LaTeX-shortvrb-chars
              (featurep 'font-latex)
diff --git a/style/tikz.el b/style/tikz.el
index 4a2fc03..ded4d25 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -1,6 +1,6 @@
 ;;; tikz.el --- AUCTeX style for `tikz.sty'
 
-;; Copyright (C) 2016 Free Software Foundation, Inc.
+;; Copyright (C) 2016, 2020 Free Software Foundation, Inc.
 
 ;; Author: Matthew Leach <matthew@mattleach.net>
 ;; Maintainer: auctex-devel@gnu.org
@@ -30,6 +30,48 @@
 
 ;;; Code:
 
+(defcustom TeX-TikZ-point-name-regexp
+  "(\\([A-Za-z0-9]+\\))"
+  "A regexp that matches TikZ names."
+  :type 'regexp
+  :group 'auctex-tikz)
+
+(defconst TeX-TikZ-point-function-map
+  '(("Rect Point" TeX-TikZ-arg-rect-point)
+    ("Polar Point" TeX-TikZ-arg-polar-point)
+    ("Named Point" TeX-TikZ-arg-named-point))
+  "An alist of point specification types and their functions.")
+
+(defconst TeX-TikZ-relative-point-function-map
+  (apply #'append (mapcar
+                  (lambda (point-map)
+                    (let ((key (car point-map))
+                          (value (cadr point-map)))
+                      `((,(concat "+" key) ,value "+")
+                        (,(concat "++" key) ,value "++"))))
+                  TeX-TikZ-point-function-map))
+  "`TeX-TikZ-point-function-map' with \"+\" and \"++\" as a
+prefix.")
+
+(defconst TeX-TikZ-path-connector-function-map
+  '(("--" identity)
+    ("|-" identity)
+    ( "-|" identity)
+    ("sin" identity)
+    ("cos" identity))
+  "An alist of path connectors.")
+
+(defconst TeX-TikZ-draw-arg-function-map
+  `(,@TeX-TikZ-point-function-map
+    ,@TeX-TikZ-relative-point-function-map
+    ,@TeX-TikZ-path-connector-function-map
+    ("Node" TeX-TikZ-arg-node)
+    ("Circle" TeX-TikZ-arg-circle)
+    ("Arc" TeX-TikZ-arg-arc)
+    ("Parabola" TeX-TikZ-arg-parabola)
+    ("Grid" TeX-TikZ-arg-grid))
+  "An alist of argument names and functoins for TikZ's \draw.")
+
 (defun TeX-TikZ-get-opt-arg-string (arg &optional open close)
   "Return a string for optional arguments.
 If ARG is nil or \"\", return \"\".  Otherwise return \"OPEN ARG
@@ -150,12 +192,6 @@ is finished."
     ;; Finish the macro.
     (insert ";")))
 
-(defcustom TeX-TikZ-point-name-regexp
-  "(\\([A-Za-z0-9]+\\))"
-  "A regexp that matches TikZ names."
-  :type 'regexp
-  :group 'auctex-tikz)
-
 (defun TeX-TikZ-find-named-points ()
   "Find TiKZ named points in current enviroment.
 Begin by finding the span of the current TikZ enviroment and then
@@ -213,42 +249,6 @@ If OPTIONAL is non-nil and the user doesn't provide a 
point,
   (let ((options (TeX-TikZ-arg-options t)))
     (concat "grid" options)))
 
-(defconst TeX-TikZ-point-function-map
-  '(("Rect Point" TeX-TikZ-arg-rect-point)
-    ("Polar Point" TeX-TikZ-arg-polar-point)
-    ("Named Point" TeX-TikZ-arg-named-point))
-  "An alist of point specification types and their functions.")
-
-(defconst TeX-TikZ-relative-point-function-map
-  (apply 'append (mapcar
-                  (lambda (point-map)
-                    (let ((key (car point-map))
-                          (value (cadr point-map)))
-                      `((,(concat "+" key) ,value "+")
-                        (,(concat "++" key) ,value "++"))))
-                  TeX-TikZ-point-function-map))
-  "`TeX-TikZ-point-function-map' with \"+\" and \"++\" as a
-prefix.")
-
-(defconst TeX-TikZ-path-connector-function-map
-  '(("--" identity)
-    ("|-" identity)
-    ( "-|" identity)
-    ("sin" identity)
-    ("cos" identity))
-  "An alist of path connectors.")
-
-(defconst TeX-TikZ-draw-arg-function-map
-  `(,@TeX-TikZ-point-function-map
-    ,@TeX-TikZ-relative-point-function-map
-    ,@TeX-TikZ-path-connector-function-map
-    ("Node" TeX-TikZ-arg-node)
-    ("Circle" TeX-TikZ-arg-circle)
-    ("Arc" TeX-TikZ-arg-arc)
-    ("Parabola" TeX-TikZ-arg-parabola)
-    ("Grid" TeX-TikZ-arg-grid))
-  "An alist of argument names and functoins for TikZ's \draw.")
-
 (defun TeX-TikZ-draw-arg (_ignored)
   "Prompt the user for the arguments to a TikZ draw macro."
   (TeX-TikZ-macro-arg TeX-TikZ-draw-arg-function-map))
diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
index c45a7b5..a869fe4 100644
--- a/tests/latex/font-latex-test.el
+++ b/tests/latex/font-latex-test.el
@@ -41,4 +41,44 @@ $a$")
              (setq font-latex--updated-region-end (point-max))
              (font-latex-match-dollar-math (point-max))))))
 
+(ert-deftest font-latex-extend-region-backwards-quotation ()
+  "Test f-l-e-r-b-q doesn't extend region too eagerly."
+  (with-temp-buffer
+    (let ((TeX-install-font-lock 'font-latex-setup)
+         (font-latex-quotes 'french)
+         font-lock-beg font-lock-end)
+      (LaTeX-mode)
+
+      ;; Test 1: Double prime in math expression doesn't cause region
+      ;; extension.
+      (setq font-lock-beg (point))
+      (insert "$f''(x)=x^{3}$")
+      (setq font-lock-end (point))
+      (should-not (font-latex-extend-region-backwards-quotation))
+
+      (erase-buffer)
+      (insert "abc ``def ghi'' jkl ")
+      (setq font-lock-beg (point))
+      (insert "$f''(x)=x^{3}$")
+      (setq font-lock-end (point))
+      (should-not (font-latex-extend-region-backwards-quotation))
+
+      ;; Test 2: open-close pair before '' in math expression is
+      ;; picked up.
+      (erase-buffer)
+      (insert "abc ``def ")
+      (setq font-lock-beg (point))
+      (insert "ghi'' jkl $f''(x)=x^{3}$")
+      (setq font-lock-end (point))
+      (should (font-latex-extend-region-backwards-quotation))
+      (should (= font-lock-beg 5))
+
+      (erase-buffer)
+      (insert "abc <<def ")
+      (setq font-lock-beg (point))
+      (insert "ghi>> jkl $f''(x)=x^{3}$")
+      (setq font-lock-end (point))
+      (should (font-latex-extend-region-backwards-quotation))
+      (should (= font-lock-beg 5)))))
+
 ;;; font-latex-test.el ends here
diff --git a/tex-bar.el b/tex-bar.el
index 3098b4d..a908695 100644
--- a/tex-bar.el
+++ b/tex-bar.el
@@ -117,35 +117,11 @@ alists, see variable `TeX-bar-TeX-all-button-alists'."
                    (const bibtex)
                    (const clean)
                    (const spell))
-                   ;; (const latex-symbols-experimental)
+              ;; (const latex-symbols-experimental)
               (repeat (choice (symbol :tag "Label")
                               (sexp :tag "General element"))))
   :group 'TeX-tool-bar)
 
-(defun TeX-bar-TeX-buttons ()
-  "Display in a buffer a list of buttons for `tex-bar.el'."
-  (interactive)
-  (let ((assqs-button-alists)
-       (labels))
-    (dolist (m-alist TeX-bar-TeX-all-button-alists)
-      (setq labels nil)
-      (dolist (as (eval m-alist))
-       (setq labels (cons (car as) labels)))
-      (setq assqs-button-alists (cons (cons m-alist (nreverse labels))
-                                      assqs-button-alists)))
-    (setq assqs-button-alists (nreverse assqs-button-alists))
-    ;; displaying results
-    (with-current-buffer (get-buffer-create "*TeX tool bar buttons*")
-      (erase-buffer)
-      (insert "Available buttons for TeX mode
-================================")
-      (dolist (i assqs-button-alists)
-       (insert (format "\n\n`%s' provides the following buttons:\n  " (car i)))
-       (dolist (j (cdr i))
-         (insert (format " %s" j)))
-       (fill-region (point-at-bol) (point-at-eol))))
-    (display-buffer "*TeX tool bar buttons*" t)))
-
 (defgroup TeX-tool-bar-button-definitions nil
   "Collections of button definitions."
   :group 'TeX-tool-bar)
@@ -208,6 +184,30 @@ format of the argument MEANING-ALIST in the mentioned 
function."
   :type '(alist :key-type symbol :value-type sexp)
   :group 'TeX-tool-bar-button-definitions)
 
+(defun TeX-bar-TeX-buttons ()
+  "Display in a buffer a list of buttons for `tex-bar.el'."
+  (interactive)
+  (let ((assqs-button-alists)
+       (labels))
+    (dolist (m-alist TeX-bar-TeX-all-button-alists)
+      (setq labels nil)
+      (dolist (as (eval m-alist))
+       (setq labels (cons (car as) labels)))
+      (setq assqs-button-alists (cons (cons m-alist (nreverse labels))
+                                     assqs-button-alists)))
+    (setq assqs-button-alists (nreverse assqs-button-alists))
+    ;; displaying results
+    (with-current-buffer (get-buffer-create "*TeX tool bar buttons*")
+      (erase-buffer)
+      (insert "Available buttons for TeX mode
+================================")
+      (dolist (i assqs-button-alists)
+       (insert (format "\n\n`%s' provides the following buttons:\n  " (car i)))
+       (dolist (j (cdr i))
+         (insert (format " %s" j)))
+       (fill-region (point-at-bol) (point-at-eol))))
+    (display-buffer "*TeX tool bar buttons*" t)))
+
 ;;; Installation of the tool bar
 ;;;###autoload
 (defun TeX-install-toolbar ()
@@ -226,7 +226,7 @@ format of the argument MEANING-ALIST in the mentioned 
function."
 
 (defcustom TeX-bar-LaTeX-buttons
   '(new-file open-file dired kill-buffer save-buffer cut copy paste undo
-             [separator nil] latex next-error view bibtex spell)
+            [separator nil] latex next-error view bibtex spell)
   "List of buttons available in `latex-mode'.
 It should be a list in the same format of the BUTTONS parameter
 in function `toolbarx-install-toolbar', often a symbol that
@@ -263,30 +263,6 @@ alists, see variable `TeX-bar-LaTeX-all-button-alists'."
                               (sexp :tag "General element"))))
   :group 'TeX-tool-bar)
 
-(defun TeX-bar-LaTeX-buttons ()
-  "Display in a buffer a list of buttons for `tex-bar.el'."
-  (interactive)
-  (let ((assqs-button-alists)
-       (labels))
-    (dolist (m-alist TeX-bar-LaTeX-all-button-alists)
-      (setq labels nil)
-      (dolist (as (eval m-alist))
-       (setq labels (cons (car as) labels)))
-      (setq assqs-button-alists (cons (cons m-alist (nreverse labels))
-                                      assqs-button-alists)))
-    (setq assqs-button-alists (nreverse assqs-button-alists))
-    ;; displaying results
-    (with-current-buffer (get-buffer-create "*TeX tool bar buttons*")
-      (erase-buffer)
-      (insert "Available buttons for LaTeX mode
-================================")
-      (dolist (i assqs-button-alists)
-       (insert (format "\n\n`%s' provides the following buttons:\n  " (car i)))
-       (dolist (j (cdr i))
-         (insert (format " %s" j)))
-       (fill-region (point-at-bol) (point-at-eol))))
-    (display-buffer "*TeX tool bar buttons*" t)))
-
 (defgroup TeX-tool-bar-button-definitions nil
   "Collections of button definitions."
   :group 'TeX-tool-bar)
@@ -353,6 +329,30 @@ format of the argument MEANING-ALIST in the mentioned 
function."
   :type '(alist :key-type symbol :value-type sexp)
   :group 'TeX-tool-bar-button-definitions)
 
+(defun TeX-bar-LaTeX-buttons ()
+  "Display in a buffer a list of buttons for `tex-bar.el'."
+  (interactive)
+  (let ((assqs-button-alists)
+       (labels))
+    (dolist (m-alist TeX-bar-LaTeX-all-button-alists)
+      (setq labels nil)
+      (dolist (as (eval m-alist))
+       (setq labels (cons (car as) labels)))
+      (setq assqs-button-alists (cons (cons m-alist (nreverse labels))
+                                     assqs-button-alists)))
+    (setq assqs-button-alists (nreverse assqs-button-alists))
+    ;; displaying results
+    (with-current-buffer (get-buffer-create "*TeX tool bar buttons*")
+      (erase-buffer)
+      (insert "Available buttons for LaTeX mode
+================================")
+      (dolist (i assqs-button-alists)
+       (insert (format "\n\n`%s' provides the following buttons:\n  " (car i)))
+       (dolist (j (cdr i))
+         (insert (format " %s" j)))
+       (fill-region (point-at-bol) (point-at-eol))))
+    (display-buffer "*TeX tool bar buttons*" t)))
+
 ;;; Installation of the tool bar
 ;;;###autoload
 (defun LaTeX-install-toolbar ()
diff --git a/tex-buf.el b/tex-buf.el
index ff6be7e..510722c 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1883,9 +1883,11 @@ variable is nil."
 (defvar compilation-in-progress nil
   "List of compilation processes now running.")
 
-(or (assq 'compilation-in-progress minor-mode-alist)
-    (setq minor-mode-alist (cons '(compilation-in-progress " Compiling")
-                                minor-mode-alist)))
+;; COMPATIBILITY for emacs < 27
+(if (< emacs-major-version 27)
+    (or (assq 'compilation-in-progress minor-mode-alist)
+       (setq minor-mode-alist (cons '(compilation-in-progress " Compiling")
+                                    minor-mode-alist))))
 
 (defun TeX-process-get-variable (name symbol &optional default)
   "Return the value in the process buffer for NAME of SYMBOL.
diff --git a/tex-font.el b/tex-font.el
index 27c9cf2..cdedc42 100644
--- a/tex-font.el
+++ b/tex-font.el
@@ -148,7 +148,8 @@
 
 (defface tex-math-face
   '((t :inherit font-lock-string-face))
-  "Face used to highlight TeX math expressions.")
+  "Face used to highlight TeX math expressions."
+  :group 'tex)
 (defvar tex-math-face 'tex-math-face)
 
 ;; Use string syntax but math face for $...$.
diff --git a/tex-info.el b/tex-info.el
index 22e726e..7c4b8a9 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -437,6 +437,7 @@ is assumed by default."
 (defvar reftex-level-indent)
 (defvar reftex-label-menu-flags)
 (defvar reftex-tables-dirty)
+(defvar reftex-label-alist-builtin)
 
 (declare-function reftex-match-string "reftex" (n))
 (declare-function reftex-section-number "reftex-parse" (&optional level star))
diff --git a/tex.el b/tex.el
index 9a1d1b6..b2bbbbf 100644
--- a/tex.el
+++ b/tex.el
@@ -35,6 +35,78 @@
 (require 'tex-site)
 (eval-when-compile
   (require 'cl-lib))
+(require 'texmathp)
+
+;; Silence the compiler for functions:
+(declare-function dbus-ignore-errors "ext:dbus"
+                 (&rest body))
+(declare-function dbus-get-unique-name "ext:dbusbind.c"
+                 (bus))
+(declare-function dbus-ping "ext:dbus"
+                 (bus service &optional timeout))
+(declare-function dbus-introspect-get-method "ext:dbus"
+                 (bus service path interface method))
+(declare-function dbus-call-method "ext:dbus"
+                 (bus service path interface method &rest args))
+(declare-function dbus-register-signal "ext:dbus"
+                 (bus service path interface signal handler &rest args))
+(declare-function TeX-output-extension "tex-buf"
+                 nil)
+(declare-function TeX-command-expand "tex-buf"
+                 (command file &optional list))
+(declare-function TeX-active-master "tex-buf"
+                 (&optional extension nondirectory ignore))
+(declare-function TeX-pop-to-buffer "tex-buf"
+                 (buffer &optional other-window norecord))
+(declare-function LaTeX-environment-list "latex"
+                 nil)
+(declare-function tex--prettify-symbols-compose-p "ext:tex-mode"
+                 (start end match))
+;; spell-buffer was removed in 2008 in favor of ispell
+(declare-function spell-buffer "ext:text-mode"
+                 t)
+
+;; Silence the compiler for variables:
+;; tex.el: Variables defined somewhere in this file:
+(defvar TeX-PDF-from-DVI)
+(defvar TeX-PDF-mode)
+(defvar TeX-PDF-mode-parsed)
+(defvar TeX-all-extensions)
+(defvar TeX-command-default)
+(defvar TeX-default-extension)
+(defvar TeX-esc)
+(defvar TeX-interactive-mode)
+(defvar TeX-macro-global)
+(defvar TeX-mode-map)
+(defvar TeX-mode-p)
+(defvar TeX-output-extension)
+(defvar TeX-output-extension)
+(defvar TeX-source-correlate-mode)
+(defvar TeX-source-specials-places)
+(defvar TeX-source-specials-tex-flags)
+(defvar TeX-synctex-tex-flags)
+;; Variables defined in other AUCTeX libraries:
+;; latex.el:
+(defvar BibLaTeX-global-style-files)
+(defvar BibTeX-global-files)
+(defvar BibTeX-global-style-files)
+(defvar LaTeX-default-verb-delimiter)
+(defvar LaTeX-global-class-files)
+(defvar LaTeX-optcl)
+(defvar LaTeX-optop)
+(defvar TeX-Biber-global-files)
+(defvar TeX-global-input-files)
+;; tex-buf.el
+(defvar TeX-current-process-region-p)
+(defvar TeX-region)
+(defvar TeX-region-orig-buffer)
+;; tex-ispell.el
+(defvar TeX-ispell-verb-delimiters)
+;; graphicx.el
+(defvar LaTeX-includegraphics-global-files)
+;; Others:
+(defvar tex--prettify-symbols-alist)   ; tex-mode.el
+(defvar Info-file-list-for-emacs)      ; info.el
 
 (defgroup TeX-file nil
   "Files used by AUCTeX."
@@ -1162,7 +1234,7 @@ entry in `TeX-view-program-list-builtin'."
   (if (and TeX-source-correlate-mode
           (fboundp 'pdf-sync-forward-search))
       (with-current-buffer (or (when TeX-current-process-region-p
-                                (get-file-buffer (TeX-region-file t)))
+                                (get-file-buffer (TeX-region-file t)))
                               (current-buffer))
        (pdf-sync-forward-search))
     (let ((pdf (concat file "." (TeX-output-extension))))
diff --git a/texmathp.el b/texmathp.el
index 326caad..733f639 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -53,10 +53,9 @@
 ;;
 ;;  To configure which macros and environments influence LaTeX math
 ;;  mode, customize the variable `texmathp-tex-commands'. By default
-;;  it recognizes the plain TeX and LaTeX core (see the variable
-;;  `texmathp-tex-commands-default', also as an example). Support for
-;;  AMS-LaTeX and packages mathtools, empheq and breqn is added as
-;;  well if `TeX-parse-self' option is enabled.
+;;  it recognizes the plain TeX and LaTeX core as well as AMS-LaTeX
+;;  and packages mathtools, empheq and breqn (see the variable
+;;  `texmathp-tex-commands-default', also as an example).
 ;;
 ;;  To try out the code interactively, use `M-x texmathp RET'.
 ;;
@@ -136,7 +135,38 @@
     ("\\textrm"      arg-off)
     ("\\("           sw-on)       ("\\)"           sw-off)
     ("\\["           sw-on)       ("\\]"           sw-off)
-    ("\\ensuremath"  arg-on))
+    ("\\ensuremath"  arg-on)
+
+    ;; AMS-LaTeX
+    ("equation*"     env-on)
+    ("align"         env-on)      ("align*"        env-on)
+    ("gather"        env-on)      ("gather*"       env-on)
+    ("multline"      env-on)      ("multline*"     env-on)
+    ("flalign"       env-on)      ("flalign*"      env-on)
+    ("alignat"       env-on)      ("alignat*"      env-on)
+    ("xalignat"      env-on)      ("xalignat*"     env-on)
+    ("xxalignat"     env-on)      ("\\boxed"       arg-on)
+    ("\\text"        arg-off)     ("\\intertext"   arg-off)
+    ("\\tag"         arg-off)     ("\\tag*"        arg-off)
+
+    ;; mathtools
+    ("\\shortintertext"   arg-off)
+
+    ;; empheq
+    ("empheq"        env-on)
+    ("AmSequation"   env-on)      ("AmSequation*"  env-on)
+    ("AmSalign"      env-on)      ("AmSalign*"     env-on)
+    ("AmSgather"     env-on)      ("AmSgather*"    env-on)
+    ("AmSmultline"   env-on)      ("AmSmultline*"  env-on)
+    ("AmSflalign"    env-on)      ("AmSflalign*"   env-on)
+    ("AmSalignat"    env-on)      ("AmSalignat*"   env-on)
+
+    ;; breqn
+    ("dmath"         env-on)      ("dmath*"        env-on)
+    ("dseries"       env-on)      ("dseries*"      env-on)
+    ("dgroup"        env-on)      ("dgroup*"       env-on)
+    ("darray"        env-on)      ("darray*"       env-on)
+    ("dsuspend"      env-off))
   "The default entries for `texmathp-tex-commands', which see.")
 
 (defun texmathp-compile ()



reply via email to

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