auctex-diffs
[Top][All Lists]
Advanced

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

main 5b61f6c5 242/257: Merge remote-tracking branch 'origin/master' into


From: Tassilo Horn
Subject: main 5b61f6c5 242/257: Merge remote-tracking branch 'origin/master' into externals/auctex
Date: Fri, 19 Apr 2024 15:37:07 -0400 (EDT)

branch: main
commit 5b61f6c563c5cf9702ddea3802bf0f6580c935a7
Merge: ea421071 ba27acce
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Merge remote-tracking branch 'origin/master' into externals/auctex
---
 .dir-locals.el                 |   2 +-
 RELEASE                        |   2 +-
 auctex.el.in                   |   4 +-
 configure.ac                   |   2 +-
 context-en.el                  |  19 +-
 context-nl.el                  |  20 +-
 context.el                     |  64 +++----
 doc/auctex.texi                |  80 +++++---
 doc/changes.texi               | 170 ++++++++++++++++-
 doc/faq.texi                   |   2 +-
 doc/install.texi               |   4 +-
 doc/preview-faq.texi           |   7 +-
 doc/preview-problems.texi      |   5 +
 doc/preview-readme.texi        |   5 +
 doc/preview-todo.texi          |   5 +
 doc/quickstart.texi            |   2 +-
 doc/todo.texi                  |   2 +-
 font-latex.el                  |  40 ++--
 latex.el                       | 285 ++++++++++++++++-------------
 latex/preview.dtx              |   2 +-
 plain-tex.el                   | 110 ++++++-----
 preview.el                     |  86 ++++-----
 style/amstex.el                |   2 +-
 style/fancyref.el              |   4 +-
 style/fancyvrb.el              |  16 +-
 style/ltugboat.el              |   5 +-
 style/nameref.el               |   5 +-
 style/prosper.el               |   4 +-
 style/simpleicons.el           |  26 ++-
 style/subfigure.el             |   5 +-
 style/varioref.el              |  12 +-
 tests/japanese/parse-timing.el |   3 +-
 tests/latex/latex-test.el      |  14 +-
 tests/tex/command-expansion.el |   2 +-
 tex-bar.el                     |   4 +-
 tex-fold.el                    |  24 +--
 tex-info.el                    |  33 ++--
 tex-ispell.el                  |   9 +-
 tex-jp.el                      | 150 +++++++--------
 tex-site.el.in                 |  79 ++++++--
 tex-style.el                   |  12 +-
 tex-wizard.el                  |   4 +-
 tex.el                         | 403 ++++++++++++++++++++++++-----------------
 texmathp.el                    |   2 +-
 44 files changed, 1048 insertions(+), 688 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 58cf88a2..2e19675b 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -12,7 +12,7 @@
                      (electric-quote-comment . nil)
                      (electric-quote-string . nil)
                      (indent-tabs-mode . nil)))
- (texinfo-mode . ((mode . bug-reference-prog)
+ (Texinfo-mode . ((mode . bug-reference-prog)
                   (electric-quote-comment . nil)
                   (electric-quote-string . nil)
                   (fill-column . 74))))
diff --git a/RELEASE b/RELEASE
index 3c8a52f2..040e72a8 100644
--- a/RELEASE
+++ b/RELEASE
@@ -45,7 +45,7 @@ file-local variable where the assigned value can only be 
between
 Requirements
 ------------
 
-It is required that you use at least GNU Emacs 26.1.
+It is required that you use at least GNU Emacs 27.1.
 
 The preview-latex subsystem requires image support.
 
diff --git a/auctex.el.in b/auctex.el.in
index fab355f0..a9c4b0c8 100644
--- a/auctex.el.in
+++ b/auctex.el.in
@@ -1,11 +1,11 @@
 ;;; auctex.el --- Integrated environment for *TeX*  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2014-2023 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2024 Free Software Foundation, Inc.
 
 ;; URL: https://www.gnu.org/software/auctex/
 ;; Maintainer: auctex-devel@gnu.org
 ;; Notifications-To: auctex-diffs@gnu.org
-;; Package-Requires: ((emacs "26.1"))
+;; Package-Requires: ((emacs "27.1"))
 ;; Keywords: TeX LaTeX Texinfo ConTeXt docTeX preview-latex
 
 ;; This file is part of AUCTeX.
diff --git a/configure.ac b/configure.ac
index 1dbbf368..49d2bf8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,7 @@ AC_SUBST(PREVIEWVERSION)
 
 EMACS_PROG_EMACS
 
-EMACS_CHECK_VERSION(26,1)
+EMACS_CHECK_VERSION(27,1)
 
 # The Debian package uses `--disable-build-dir-test'; normal users should
 # never need to modify the default behavior.
diff --git a/context-en.el b/context-en.el
index 62394206..c63a4fd1 100644
--- a/context-en.el
+++ b/context-en.el
@@ -188,8 +188,6 @@ That is, besides the section(-block) commands.")
 
 (defun ConTeXt-en-mode-initialization ()
   "ConTeXt english interface specific initialization."
-  ;; FIXME: Move to `ConTeXt-mode-common-initialization' replacing
-  ;; `ConTeXt-environment-list-en' with `ConTeXt-environment-list'?
   (mapc #'ConTeXt-add-environments (reverse ConTeXt-environment-list-en))
 
   (TeX-add-symbols
@@ -202,17 +200,10 @@ That is, besides the section(-block) commands.")
    '("sub" ConTeXt-arg-define-ref (TeX-arg-literal " "))
    '("sym" (TeX-arg-string "Symbol") (TeX-arg-literal " "))))
 
-;;;###autoload
-(defun context-en-mode ()
-  "Major mode for editing files for ConTeXt using its english interface.
+(defun ConTeXt--mode-en ()
+  "Set up ConTeXt mode for editing files under english interface.
+Helper function of `ConTeXt-mode'.  Don't use."
 
-Special commands:
-\\{ConTeXt-mode-map}
-
-Entering `context-mode' calls the value of `text-mode-hook',
-then the value of `TeX-mode-hook', and then the value
-of `ConTeXt-mode-hook'."
-  (interactive)
   ;; set the ConTeXt interface
   (setq ConTeXt-current-interface "en")
 
@@ -220,9 +211,7 @@ of `ConTeXt-mode-hook'."
   (ConTeXt-mode-common-initialization)
   (ConTeXt-en-mode-initialization)
 
-  ;; set mode line
-  (setq TeX-base-mode-name "ConTeXt-en")
-  (TeX-set-mode-name))
+  (setq mode-name "ConTeXt-en"))
 
 (provide 'context-en)
 
diff --git a/context-nl.el b/context-nl.el
index 825ee9fa..721b127f 100644
--- a/context-nl.el
+++ b/context-nl.el
@@ -166,8 +166,6 @@ That is, besides the section(-block) commands.")
 
 (defun ConTeXt-nl-mode-initialization ()
   "ConTeXt dutch interface specific initialization."
-  ;; FIXME: Move to `ConTeXt-mode-common-initialization' replacing
-  ;; `ConTeXt-environment-list-nl' with `ConTeXt-environment-list'?
   (mapc #'ConTeXt-add-environments (reverse ConTeXt-environment-list-nl))
 
   (TeX-add-symbols
@@ -180,17 +178,9 @@ That is, besides the section(-block) commands.")
    '("sub" ConTeXt-arg-define-ref (TeX-arg-literal " "))
    '("sym" (TeX-arg-string "Symbol") (TeX-arg-literal " "))))
 
-;;;###autoload
-(defun context-nl-mode ()
-  "Major mode for editing files for ConTeXt using its dutch interface.
-
-Special commands:
-\\{ConTeXt-mode-map}
-
-Entering `context-mode' calls the value of `text-mode-hook',
-then the value of `TeX-mode-hook', and then the value
-of `ConTeXt-mode-hook'."
-  (interactive)
+(defun ConTeXt--mode-nl ()
+  "Set up ConTeXt mode for editing files under dutch interface.
+Helper function of `ConTeXt-mode'.  Don't use."
 
   ;; set the ConTeXt interface
   (setq ConTeXt-current-interface "nl")
@@ -199,9 +189,7 @@ of `ConTeXt-mode-hook'."
   (ConTeXt-mode-common-initialization)
   (ConTeXt-nl-mode-initialization)
 
-  ;; set mode line
-  (setq TeX-base-mode-name "ConTeXt-nl")
-  (TeX-set-mode-name))
+  (setq mode-name "ConTeXt-nl"))
 
 (provide 'context-nl)
 
diff --git a/context.el b/context.el
index b4f6dea0..5ee0217d 100644
--- a/context.el
+++ b/context.el
@@ -1,6 +1,6 @@
 ;;; context.el --- Support for ConTeXt documents.  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2003-2023  Free Software Foundation, Inc.
+;; Copyright (C) 2003-2024  Free Software Foundation, Inc.
 
 ;; Maintainer: Berend de Boer <berend@pobox.com>
 ;; Keywords: tex
@@ -495,9 +495,9 @@ in your init file such as .emacs.d/init.el or .emacs."
 (defcustom ConTeXt-Mark-version "II"
   "ConTeXt Mark version used for running ConTeXt."
   :type 'string
-  :group 'TeX-command)
-(make-variable-buffer-local 'ConTeXt-Mark-version)
-(put 'ConTeXt-Mark-version 'safe-local-variable #'stringp)
+  :group 'TeX-command
+  :safe #'stringp
+  :local t)
 
 (defun ConTeXt-numbered-section-heading ()
   "Hook to prompt for ConTeXt section name.
@@ -626,8 +626,8 @@ for a label to be inserted after the sectioning command."
 (defcustom ConTeXt-default-environment "itemize"
   "The default environment when creating new ones with `ConTeXt-environment'."
   :group 'ConTeXt-environment
-  :type 'string)
-(make-variable-buffer-local 'ConTeXt-default-environment)
+  :type 'string
+  :local t)
 
 (TeX-auto-add-type "environment" "ConTeXt")
 
@@ -942,7 +942,7 @@ An entry looks like: (\"environment\" . function)")
   (metapost-mode)
   (message "Type `M-x exit-recursive-edit' to get back")
   (recursive-edit)
-  (context-mode)
+  (ConTeXt-mode)
   (widen))
 
 ;; find smarter name.  Suggestions welcome
@@ -1593,7 +1593,7 @@ else.  There might be text before point."
 (easy-menu-define ConTeXt-mode-command-menu
   ConTeXt-mode-map
   "Command menu used in ConTeXt mode."
-  (TeX-mode-specific-command-menu 'context-mode))
+  (TeX-mode-specific-command-menu 'ConTeXt-mode))
 
 ;; it seems the menu is evaluated at compile/load-time
 ;; we don't have ConTeXt-current-interface at that time
@@ -1656,7 +1656,7 @@ else.  There might be text before point."
 
 (defun ConTeXt-menu-update (&optional menu)
   "Update entries on AUCTeX menu."
-  (or (not (memq major-mode '(context-mode)))
+  (or (not (memq major-mode '(ConTeXt-mode)))
       (null ConTeXt-menu-changed)
       (progn
         (TeX-update-style)
@@ -1816,20 +1816,12 @@ that is, you do _not_ have to cater for this yourself 
by adding \\\\\\=' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
-(TeX-abbrev-mode-setup context-mode)
+(TeX-abbrev-mode-setup ConTeXt-mode context-mode-abbrev-table)
 
 (defun ConTeXt-mode-common-initialization ()
   "Initialization code that is common for all ConTeXt interfaces."
-  ;; `plain-TeX-common-initialization' kills all local variables, but
-  ;; we need to keep ConTeXt-current-interface, so save and restore
-  ;; it.
-  (let (save-ConTeXt-current-interface)
-    (setq save-ConTeXt-current-interface ConTeXt-current-interface)
-    (plain-TeX-common-initialization)
-    (setq ConTeXt-current-interface save-ConTeXt-current-interface))
-  (setq major-mode 'context-mode)
-
-  (setq local-abbrev-table context-mode-abbrev-table)
+  (plain-TeX-common-initialization)
+
   (set (make-local-variable 'TeX-style-hook-dialect) ConTeXt-dialect)
 
   (require (intern (concat "context-" ConTeXt-current-interface)))
@@ -1846,9 +1838,6 @@ that is, you do _not_ have to cater for this yourself by 
adding \\\\\\=' or $."
   (or ConTeXt-largest-level
       (setq ConTeXt-largest-level 2))
 
-  ;; keybindings
-  (use-local-map ConTeXt-mode-map)
-
   ;; Indenting
   (set (make-local-variable 'indent-line-function) #'ConTeXt-indent-line)
   (set (make-local-variable 'fill-indent-according-to-mode) t)
@@ -1875,7 +1864,6 @@ that is, you do _not_ have to cater for this yourself by 
adding \\\\\\=' or $."
          "\\|$\\)"))
 
   ;; Keybindings and menu
-  (use-local-map ConTeXt-mode-map)
   (setq ConTeXt-menu-changed t)
 
   ;; FIXME: Isn't `activate-menubar-hook' obsolete?
@@ -1900,11 +1888,12 @@ that is, you do _not_ have to cater for this yourself 
by adding \\\\\\=' or $."
   (set (make-local-variable 'imenu-create-index-function)
        #'ConTeXt-imenu-create-index-function)
 
-  ;; run hooks
   (setq TeX-command-default "ConTeXt")
-  (setq TeX-sentinel-default-function #'TeX-ConTeXt-sentinel)
-  (run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'ConTeXt-mode-hook)
+  (setq TeX-sentinel-default-function #'TeX-ConTeXt-sentinel))
 
+(defun ConTeXt-mode-cleanup ()
+  "Cleanup function for `ConTeXt-mode'.
+Run after mode hooks and file local variables application."
   ;; Create certain regular expressions based on language.
   ;; Don't overwrite the value the user set by hooks or file
   ;; (directory) variables.
@@ -1947,22 +1936,27 @@ that is, you do _not_ have to cater for this yourself 
by adding \\\\\\=' or $."
                  ConTeXt-default-interface)))))
 
 ;;;###autoload
-(defalias 'ConTeXt-mode #'context-mode)
+(defalias 'context-mode #'ConTeXt-mode)
 
 ;;;###autoload
-(defun context-mode ()
+(define-derived-mode ConTeXt-mode TeX-mode "ConTeXt"
   "Major mode in AUCTeX for editing ConTeXt files.
 
-Special commands:
-\\{ConTeXt-mode-map}
-
-Entering `context-mode' calls the value of `text-mode-hook',
+Entering `ConTeXt-mode' calls the value of `text-mode-hook',
 then the value of `TeX-mode-hook', and then the value
 of `ConTeXt-mode-hook'."
-  (interactive)
+  :after-hook (ConTeXt-mode-cleanup)
   (context-guess-current-interface)
   (require (intern (concat "context-" ConTeXt-current-interface)))
-  (funcall (intern (concat "context-" ConTeXt-current-interface "-mode"))))
+  (funcall (intern (concat "ConTeXt--mode-" ConTeXt-current-interface)))
+
+  ;; set mode line
+  (setq TeX-base-mode-name mode-name))
+
+;; Compatibility for former mode name.  Directory local variables
+;; prepared for `context-mode' continue to be valid for
+;; `ConTeXt-mode'.
+(TeX-derived-mode-add-parents 'ConTeXt-mode '(context-mode))
 
 (provide 'context)
 
diff --git a/doc/auctex.texi b/doc/auctex.texi
index c8bfbb55..dce723a3 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,7 +12,7 @@ This manual is for @AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}),
 a sophisticated @TeX{} environment for Emacs.
 
-Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2023
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2024
 Free Software Foundation, Inc.
 
 @quotation
@@ -975,6 +975,8 @@ that you use @kbd{C-c C-e} to insert complete environments 
instead.
 @deffn Command LaTeX-close-environment
 @kindex C-c ]
 (@kbd{C-c ]}) Insert an @samp{\end} that matches the current environment.
+When called with prefix argument (@kbd{C-u}), reopen environment
+afterwards.
 @end deffn
 
 @AUCTeX{} offers keyboard shortcuts for moving point to the beginning
@@ -1365,6 +1367,17 @@ candidate, multiple candidates separated by commas, or 
key-value
 candidates separated by commas and/or equal signs.
 @end defun
 
+Sometimes the list of offered candidates is enriched by annotations which
+are appended to the candidates themself.  For labels which are referenced,
+the annotations are controlled by the variable
+@code{LaTeX-label-annotation-max-length} and Ref@TeX{} being enabled in
+the buffer since the annotations are gathered from it.
+
+@defopt LaTeX-label-annotation-max-length
+Controls the length of the annotation attached to a label, default is 30.
+Setting this variable to 0 disables annotation of labels.
+@end defopt
+
 A more direct way to insert a macro is with @code{TeX-insert-macro},
 bound to @kbd{C-c C-m} which is equivalent to @kbd{C-c @key{RET}}.  It
 has the advantage over completion that it knows about the argument of
@@ -3302,7 +3315,7 @@ Another possibility is to use file local additions at the 
end of your
 @TeX{} file, e.g.:
 @example
 %%% Local Variables:
-%%% mode: latex
+%%% mode: LaTeX
 %%% TeX-master: t
 %%% eval: (TeX-ispell-skip-setcar '(("\\\\mymacro" . "@{[-0-9]+@}")))
 %%% End:
@@ -3521,6 +3534,20 @@ a command not found error.  The error code returned by 
the shell in this
 case can be set in @code{TeX-check-TeX-command-not-found} option.
 @end defopt
 
+In addition, @AUCTeX{} searches for a line similar to
+@example
+LaTeX2e <2022-11-01> patch level 1
+@end example
+in the console log to check whether @command{latex} command fails or not.
+If there isn't such a line when running @LaTeX{}, @AUCTeX{} warns the
+problem and resets the next default command to ``LaTeX''.  If this check
+doesn't suit for your use case, you can customize the
+@code{TeX-LaTeX-sentinel-banner-regexp} option:
+@defopt TeX-LaTeX-sentinel-banner-regexp
+When a @LaTeX{} run doesn't output a banner line matching this regexp,
+@AUCTeX{} considers that it failed.
+@end defopt
+
 Some @LaTeX{} packages requires the document to be compiled with a
 specific engine.  Notable examples are @samp{fontspec} and @samp{polyglossia}
 packages, which require Lua@TeX{} and Xe@TeX{} engines.  If you try to
@@ -4107,7 +4134,7 @@ documents and all files in a multifile document.  For 
example,
 
 @example
 %%% Local Variables:
-%%% mode: latex
+%%% mode: LaTeX
 %%% TeX-output-dir: "build"
 %%% End:
 @end example
@@ -4236,27 +4263,28 @@ order.  (As an exception, Texinfo mode does not run 
@code{TeX-mode-hook}.)
 The following table provides an overview of the respective mode
 functions and hooks.
 
-@multitable {Plain @TeX{}} {@code{plain-tex-mode}} {@code{plain-TeX-mode-hook}}
+@multitable {Plain @TeX{}} {@code{plain-TeX-mode}} {@code{plain-TeX-mode-hook}}
 @headitem Type @tab Mode function @tab Hook
-@item Plain @TeX{} @tab @code{plain-tex-mode} @tab @code{plain-TeX-mode-hook}
-@item @LaTeX{}     @tab @code{latex-mode}     @tab @code{LaTeX-mode-hook}
-@item AMS-@TeX{}   @tab @code{ams-tex-mode}   @tab @code{AmS-TeX-mode-hook}
-@item @ConTeXt{}   @tab @code{context-mode}   @tab @code{ConTeXt-mode-hook}
-@item Texinfo      @tab @code{texinfo-mode}   @tab @code{Texinfo-mode-hook}
-@item Doc@TeX{}    @tab @code{doctex-mode}    @tab @code{docTeX-mode-hook}
+@item Plain @TeX{} @tab @code{plain-TeX-mode} @tab @code{plain-TeX-mode-hook}
+@item @LaTeX{}     @tab @code{LaTeX-mode}     @tab @code{LaTeX-mode-hook}
+@item AMS-@TeX{}   @tab @code{AmSTeX-mode}    @tab @code{AmSTeX-mode-hook}
+@item @ConTeXt{}   @tab @code{ConTeXt-mode}   @tab @code{ConTeXt-mode-hook}
+@item Texinfo      @tab @code{Texinfo-mode}   @tab @code{Texinfo-mode-hook}
+@item Doc@TeX{}    @tab @code{docTeX-mode}    @tab @code{docTeX-mode-hook}
 @end multitable
-@findex plain-tex-mode
+@findex plain-TeX-mode
 @vindex plain-TeX-mode-hook
-@findex latex-mode
+@findex LaTeX-mode
 @vindex LaTeX-mode-hook
-@findex ams-tex-mode
-@vindex AmS-TeX-mode-hook
-@findex context-mode
+@findex AmSTeX-mode
+@vindex AmSTeX-mode-hook
+@findex ConTeXt-mode
 @vindex ConTeXt-mode-hook
-@findex texinfo-mode
+@findex Texinfo-mode
 @vindex Texinfo-mode-hook
-@findex doctex-mode
+@findex docTeX-mode
 @vindex docTeX-mode-hook
+@vindex TeX-mode-hook
 
 If you need to make a customization via a hook which is only relevant
 for one of the modes listed above, put it into the respective mode hook,
@@ -4264,6 +4292,10 @@ if it is relevant for any @AUCTeX{} mode, add it to 
@code{TeX-mode-hook}
 and if it is relevant for all text modes, append it to
 @code{text-mode-hook}.
 
+Now doc@TeX{} mode is child of @LaTeX{} mode, so doc@TeX{} mode runs
+@code{LaTeX-mode-hook} as well.  Similarly, AmS@TeX{} mode is child of plain
+@TeX{} mode and runs @code{plain-TeX-mode-hook} as well.
+
 Other useful hooks are listed below.
 
 @defvr Variable TeX-after-compilation-finished-functions
@@ -4866,15 +4898,15 @@ press.  If @code{nil} do it the other way round.
 @vindex TeX-engine
 @vindex TeX-engine-alist
 @vindex japanese-TeX-mode
-@findex japanese-plain-tex-mode
-@findex japanese-latex-mode
+@findex japanese-plain-TeX-mode
+@findex japanese-LaTeX-mode
 
 To write Japanese text with @AUCTeX{}, you need the versions of
 @TeX{} and Emacs that support Japanese.  @AUCTeX{} supports three
 Japanese @TeX{} engines by default: NTT j@TeX{}, ASCII p@TeX{} and
 up@TeX{}.
 
-Activate @code{japanese-plain-tex-mode} or @code{japanese-latex-mode} to
+Activate @code{japanese-plain-TeX-mode} or @code{japanese-LaTeX-mode} to
 use the Japanese @TeX{} engines.  If it doesn't work, send mail to
 Masayuki Ataka @email{masayuki.ataka@@gmail.com} or Ikumi Keita
 @email{ikumikeita@@jcom.home.ne.jp}, who currently concern with stuff
@@ -4882,7 +4914,7 @@ related to Japanese in @AUCTeX{}.  None of the primary 
@AUCTeX{}
 maintainers understand Japanese, so they cannot help you.
 
 It is recommended to enable @code{TeX-parse-self} for typical Japanese
-@LaTeX{} users.  When enabled, @code{japanese-latex-mode} selects the
+@LaTeX{} users.  When enabled, @code{japanese-LaTeX-mode} selects the
 suitable Japanese @TeX{} engine automatically based on the class file
 name (such as @code{jbook}, @code{jsarticle} and @code{tjreport}) and
 its option.  @xref{Parsing Files}.
@@ -4916,7 +4948,7 @@ Here is a sample code to set @code{TeX-engine} to 
@samp{uptex}:
 
 @example
 %%% Local Variables:
-%%% mode: japanese-latex
+%%% mode: japanese-LaTeX
 %%% TeX-engine: uptex
 %%% End:
 @end example
@@ -4947,7 +4979,7 @@ file is plain @TeX{} or @LaTeX{} or what.
 If you want to enter Japanese @LaTeX{} mode whenever this may happen,
 set the variable like this:
 @lisp
-(setq TeX-default-mode 'japanese-latex-mode)
+(setq TeX-default-mode 'japanese-LaTeX-mode)
 @end lisp
 @end defopt
 
@@ -6323,7 +6355,7 @@ used by @AUCTeX{} for inserting @samp{@@node}.
 @bye
 
 @c Local Variables:
-@c mode: texinfo
+@c mode: Texinfo
 @c coding: utf-8
 @c TeX-master: t
 @c End:
diff --git a/doc/changes.texi b/doc/changes.texi
index e88b9d60..f2a3a3ae 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -8,6 +8,174 @@
 
 @end ifset
 
+@heading News in 14.1
+
+@itemize @bullet
+@item
+@AUCTeX{} changes major mode names.  Its primary purpose is to avoid
+conflicts with Emacs built-in @TeX{} major modes.  It also improves
+consistency of the source code.
+
+@itemize @minus
+@item
+The overview of the former names and new names are:
+
+@multitable {@code{japanese-plain-tex-mode}} {@code{japanese-plain-TeX-mode}}
+@headitem Former name @tab New name
+@item @code{plain-tex-mode} @tab @code{plain-TeX-mode}
+@item @code{latex-mode} @tab @code{LaTeX-mode}
+@item @code{doctex-mode} @tab @code{docTeX-mode}
+@item @code{context-mode} @tab @code{ConTeXt-mode}
+@item @code{texinfo-mode} @tab @code{Texinfo-mode}
+@item @code{ams-tex-mode} @tab @code{AmSTeX-mode}
+@item @code{japanese-plain-tex-mode} @tab @code{japanese-plain-TeX-mode}
+@item @code{japanese-latex-mode} @tab @code{japanese-LaTeX-mode}
+@end multitable
+
+The undocumented modes @code{context-en-mode} and @code{context-nl-mode}
+were deleted.
+
+@item
+We paid much attention to the compatibility and expect that almost no
+particular treatment on the user side is needed.  For example, the names
+of the keymaps and mode hooks remain unchanged, and the @samp{mode:} tag
+in the file local variables in the existing files works with old mode
+names.  See below for more details.
+
+@item
+If your Emacs is 29 or newer and you use @file{desktop.el} to save and
+restore Emacs sessions, be careful before you update @AUCTeX{}; You should
+attempt to update only after
+@enumerate
+@item
+you kill all buffer under former @AUCTeX{} modes which have overlapped
+name with Emacs built-in @TeX{} modes, and
+@item
+you terminate the current Emacs session.
+@end enumerate
+The modes with such overlapped name are @code{plain-tex-mode},
+@code{latex-mode}, @code{doctex-mode} and @code{texinfo-mode}. (The above
+prescription ensures no buffer of such modes is recorded in the desktop
+file.  Otherwise those buffers would be restored in the built-in modes,
+not @AUCTeX{} modes, after the update of @AUCTeX{}.)
+
+@item
+New mode names are chosen to match the existing variables, so most user
+customizations as well as the third party libraries would continue to work
+without modification.  For example, names of keymaps and hooks don't
+change as stated above.  (@code{AmS-TeX-mode-hook} is renamed to
+@code{AmSTeX-mode-hook}, but compatibility alias is provided.)
+
+@item
+Now @code{TeX-add-local-master} adds entry of new mode names such as
+
+@example
+%%% Local Variables:
+%%% mode: LaTeX      <-- not `latex'
+%%% End:
+@end example
+
+@item
+The compatibility with the former mode names with respect to invoking the
+major mode are retained.
+
+@enumerate
+@item
+Former modes which overlap with built-in modes, namely
+@code{plain-tex-mode}, @code{latex-mode}, @code{doctex-mode},
+@code{texinfo-mode} and @code{tex-mode} are handled by redirections; the
+same override advices as before are continued to used for Emacs @math{<29}
+while @code{major-mode-remap-alist} is used for Emacs 29 and later.
+(Therefore, if there are user codes which call @code{latex-mode}
+directly, built-in @code{latex-mode} runs instead of @AUCTeX{}
+@code{LaTeX-mode} in Emacs 29 and later.)
+
+These redirections still honor your customization to @code{TeX-modes}
+option.  Thus you are served by built-in @code{plain-tex-mode} and
+@AUCTeX{} @code{LaTeX-mode} if you exclude @code{plain-tex-mode} from
+@code{TeX-modes}.
+
+@item
+Other former names, e.g.@: @code{context-mode} and
+@code{japanese-latex-mode}, are handled by aliases such as
+
+@lisp
+(defalias 'context-mode #'ConTeXt-mode)
+@end lisp
+@end enumerate
+
+@item
+New modes recognize directory local variables prepaired for the former
+mode name.  For example, directory local variables for @code{latex-mode}
+are valid in @code{LaTeX-mode} as well.  So you don't have to rewrite
+every former mode name to the new one in @file{.dir-locals.el}.
+
+@item
+Your abbrevs are preserved.  For example, @code{latex-mode-abbrev-table},
+if exists, is automatically included as a parent of
+@code{LaTeX-mode-abbrev-table}.
+
+@item
+Now all major modes are defined by @code{define-derived-mode}, so standard
+inheritance of keymaps, syntax tables etc.@: takes place.  The inheritance
+relations are:
+@verbatim
+text-mode      --+-- TeX-mode
+                 +-- Texinfo-mode
+
+TeX-mode       --+-- plain-TeX-mode
+                 +-- LaTeX-mode
+                 +-- ConTeXt-mode
+
+plain-TeX-mode --+-- AmSTeX-mode
+                 +-- japanese-plain-TeX-mode
+
+LaTeX-mode     --+-- docTeX-mode
+                 +-- japanese-LaTeX-mode
+@end verbatim
+
+These inheritance relations are taken into account for directory local
+variables in the standard way.  For example, directory local variables for
+@code{LaTeX-mode} are applied to @code{docTeX-mode} now.
+
+Note that @code{TeX-mode} isn't meant for use for end users.  It is only
+meant for the base mode for other major modes.  Its role is to provide
+base keymap, hook and syntax table under the same name with the former
+@AUCTeX{} and run the common initialization code.
+
+Now that all modes have @code{text-mode} as their ancestor, they inherit
+its keymap and syntax table.  In addition, dir local vars for
+@code{text-mode} are applied to all @AUCTeX{} major mode.
+
+However, @code{Texinfo-mode} is exceptional in the following two aspects:
+@enumerate
+@item
+It doesn't inherit @code{text-mode-syntax-table} because it simply uses
+built-in mode's @code{texinfo-mode-syntax-table}, which is independent of
+@code{text-mode-syntax-table}.  This situation is the same with the former
+@AUCTeX{} Texinfo mode.
+
+@item
+@code{Texinfo-mode-map} has @code{TeX-mode-map} as its direct parent.
+This is the same with the former @AUCTeX{} Texinfo mode.  Now it inherits
+@code{text-mode-map} indirectly through @code{TeX-mode-map}.
+@end enumerate
+
+@c Need to mention AmSTeX-mode as well?
+
+@item
+There are new keymaps, hooks and abbrev tables:
+@code{Texinfo-mode-abbrev-table}, @code{japanese-plain-TeX-mode-map},
+@code{japanese-LaTeX-mode-map}, @code{japanese-plain-TeX-mode-hook},
+@code{japanese-LaTeX-mode-hook},
+@code{japanese-plain-TeX-mode-abbrev-table},
+@code{japanese-LaTeX-mode-abbrev-table}
+@end itemize
+
+@item
+@AUCTeX{} now requires GNU Emacs 27.1 or higher.
+@end itemize
+
 @heading News in 13.3
 
 @itemize @bullet
@@ -1766,6 +1934,6 @@ Bug fixes.
 @end itemize
 
 @c Local Variables:
-@c mode: texinfo
+@c mode: Texinfo
 @c TeX-master: "auctex"
 @c End:
diff --git a/doc/faq.texi b/doc/faq.texi
index a2906d4d..0fb58dd5 100644
--- a/doc/faq.texi
+++ b/doc/faq.texi
@@ -71,7 +71,7 @@ statements related to the problem.
 @item
 What versions of Emacs are supported?
 
-@AUCTeX{} was tested with @w{GNU Emacs 26.1}.  Older versions may work but
+@AUCTeX{} was tested with @w{GNU Emacs 27.1}.  Older versions may work but
 are unsupported.
 
 @item
diff --git a/doc/install.texi b/doc/install.texi
index 8b7b00e3..52be62f9 100644
--- a/doc/install.texi
+++ b/doc/install.texi
@@ -96,7 +96,7 @@ the file @file{INSTALL.windows}.
 @end ifclear
 
 @itemize @bullet
-@item GNU Emacs 26.1 or higher
+@item GNU Emacs 27.1 or higher
 
 Using @previewlatex{} requires a version of Emacs compiled with image
 support.
@@ -623,6 +623,6 @@ set the variable for you if it could use the program 
@command{kpsewhich}.
 In this case you normally don't have to alter anything.
 
 @c Local Variables:
-@c mode: texinfo
+@c mode: Texinfo
 @c TeX-master: "auctex"
 @c End:
diff --git a/doc/preview-faq.texi b/doc/preview-faq.texi
index 3b983bf1..95d70f05 100644
--- a/doc/preview-faq.texi
+++ b/doc/preview-faq.texi
@@ -48,7 +48,7 @@ to @email{auctex-devel@@gnu.org}.
 @subsection Which version of Emacs is needed?
 
 @previewlatex{} nominally requires @w{GNU Emacs} with a version of at
-least 26.1.
+least 27.1.
 
 @subsection Which versions of Ghostscript and @AUCTeX{} are needed?
 
@@ -304,3 +304,8 @@ file looking like the following:
 \end@{plain@}
 \end@{document@}
 @end example
+
+@c Local Variables:
+@c mode: Texinfo
+@c TeX-master: "preview-latex"
+@c End:
diff --git a/doc/preview-problems.texi b/doc/preview-problems.texi
index 0f1518bf..57a1a185 100644
--- a/doc/preview-problems.texi
+++ b/doc/preview-problems.texi
@@ -204,3 +204,8 @@ rendered as black in the preview images, so it's almost 
impossible to read
 them on dark background.  Hence Xe@LaTeX{} users who like dark background
 in Emacs frame should customize @code{preview-pdf-adjust-color-method} to
 @code{nil}.
+
+@c Local Variables:
+@c mode: Texinfo
+@c TeX-master: "preview-latex"
+@c End:
diff --git a/doc/preview-readme.texi b/doc/preview-readme.texi
index 8d4c5651..079fe089 100644
--- a/doc/preview-readme.texi
+++ b/doc/preview-readme.texi
@@ -227,3 +227,8 @@ to show your appreciation with a donation to the main 
developer, you can
 do so via PayPal to @email{dak@@gnu.org}, and of course you can arrange
 for service contracts or for added functionality.  Take a look at the
 @file{TODO} list for suggestions in that area.
+
+@c Local Variables:
+@c mode: Texinfo
+@c TeX-master: "preview-latex"
+@c End:
diff --git a/doc/preview-todo.texi b/doc/preview-todo.texi
index 485373ee..ce2236b1 100644
--- a/doc/preview-todo.texi
+++ b/doc/preview-todo.texi
@@ -116,3 +116,8 @@ replace the whole color and image handling with 
@acronym{GDK} routines
 when this library is available, since it has been optimized for it.
 
 @end itemize
+
+@c Local Variables:
+@c mode: Texinfo
+@c TeX-master: "preview-latex"
+@c End:
diff --git a/doc/quickstart.texi b/doc/quickstart.texi
index d0fdf78e..8f5f7ac0 100644
--- a/doc/quickstart.texi
+++ b/doc/quickstart.texi
@@ -322,6 +322,6 @@ files.  It will run @command{latex} only on the current 
buffer, using the
 preamble from the master file.
 
 @c Local Variables: 
-@c mode: texinfo
+@c mode: Texinfo
 @c TeX-master: "auctex"
 @c End: 
diff --git a/doc/todo.texi b/doc/todo.texi
index 6819ce17..a0931307 100644
--- a/doc/todo.texi
+++ b/doc/todo.texi
@@ -341,6 +341,6 @@ Correct indentation for tabbing, table, and math 
environments.
 @end itemize
 
 @c Local Variables:
-@c mode: texinfo
+@c mode: Texinfo
 @c TeX-master: "auctex"
 @c End:
diff --git a/font-latex.el b/font-latex.el
index b9495ea3..ab33b4db 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1,12 +1,12 @@
 ;;; font-latex.el --- LaTeX fontification for Font Lock mode.  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 1996-2023  Free Software Foundation, Inc.
+;; Copyright (C) 1996-2024  Free Software Foundation, Inc.
 
 ;; Authors:    Peter S. Galbraith <psg@debian.org>
 ;;             Simon Marshall <Simon.Marshall@esrin.esa.it>
 ;; Maintainer: auctex-devel@gnu.org
 ;; Created:    06 July 1996
-;; Keywords:   tex, wp, faces
+;; Keywords:   tex, text, faces
 
 ;;; This file is not part of GNU Emacs.
 
@@ -110,9 +110,8 @@ the language option supplied to the babel package.
 
 If nil, quoted content will not be fontified."
   :type '(choice (const auto) (const french) (const german) (const nil))
-  :group 'font-latex)
-(put 'font-latex-quotes 'safe-local-variable
-     (lambda (x) (memq x '(auto french german nil))))
+  :group 'font-latex
+  :safe (lambda (x) (memq x '(auto french german nil))))
 
 (defun font-latex-add-quotes (quotes)
   "Add QUOTES to `font-latex-quote-list'.
@@ -969,11 +968,10 @@ script operators ^ and _ are not displayed."
   :type '(choice (boolean :tag "Enabled")
                  (const :tag "Multiple levels" multi-level)
                  (const :tag "Hide ^ and _" invisible))
-  :group 'font-latex)
-(put 'font-latex-fontify-script 'safe-local-variable
-     (lambda (val)
-       (or (booleanp val)
-           (memq val '(multi-level invisible)))))
+  :group 'font-latex
+  :safe (lambda (val)
+          (or (booleanp val)
+              (memq val '(multi-level invisible)))))
 
 (defcustom font-latex-fontify-script-max-level 3
   "Maximum scriptification level for which script faces are applied.
@@ -1303,7 +1301,7 @@ triggers Font Lock to recognize the change."
 
 (defun font-latex--make-syntax-propertize-function ()
   "Return a `syntax-propertize-function' for (La|Doc)TeX documents."
-  (let ((kws ;; (if (derived-mode-p 'doctex-mode)
+  (let ((kws ;; (if (derived-mode-p 'docTeX-mode)
              ;;     font-latex-doctex-syntactic-keywords
                font-latex-syntactic-keywords)) ;; )
     (syntax-propertize-via-font-lock kws)))
@@ -1318,10 +1316,10 @@ triggers Font Lock to recognize the change."
 
   ;; The test for `major-mode' currently only works with docTeX mode
   ;; because `TeX-install-font-lock' is called explicitly in
-  ;; `doctex-mode'.  In case other modes have to be distinguished as
-  ;; well, remove the call to `TeX-install-font-lock' from
-  ;; `VirTeX-common-initialization' and place it in the different
-  ;; `xxx-mode' calls instead, but _after_ `major-mode' is set.
+  ;; `docTeX-mode'.  In case other modes have to be distinguished as
+  ;; well, remove the call to `TeX-install-font-lock' from `TeX-mode'
+  ;; and place it in the different `xxx-mode' calls instead, but
+  ;; _after_ `major-mode' is set.
   (let ((defaults
          `((font-latex-keywords font-latex-keywords-1 font-latex-keywords-2)
            nil nil ,font-latex-syntax-alist nil))
@@ -1342,7 +1340,7 @@ triggers Font Lock to recognize the change."
             syntax-propertize-wholelines
             font-latex-sp-extend-region-backwards-verb-env))))
     ;; Add the mode-dependent stuff to the basic variables defined above.
-    (if (eq major-mode 'doctex-mode)
+    (if (eq major-mode 'docTeX-mode)
         (progn
           (setcar defaults (append (car defaults)
                                    '(font-latex-doctex-keywords)))
@@ -1457,7 +1455,7 @@ OPENCHAR is the opening character and CLOSECHAR is the 
closing
 character.  Character pairs are usually { } or [ ].  Comments are
 ignored during the search."
   (let ((parse-sexp-ignore-comments
-         (not (eq major-mode 'doctex-mode))) ; scan-sexps ignores comments
+         (not (eq major-mode 'docTeX-mode))) ; scan-sexps ignores comments
         (init-point (point))
         (mycount 1)
         (esc-char (or (and (boundp 'TeX-esc) TeX-esc) "\\"))
@@ -1510,7 +1508,7 @@ ignored during the search."
       (forward-line 0)
       (if (and (eq (char-after) ?\%)
                (not (font-latex-faces-present-p 'font-latex-verbatim-face)))
-          (not (eq major-mode 'doctex-mode))
+          (not (eq major-mode 'docTeX-mode))
         (catch 'found
           (while (progn (skip-chars-forward "^%" limit)
                         (< (point) limit))
@@ -1538,7 +1536,7 @@ If POS is omitted, the current position of point is used."
 (defun font-latex-forward-comment ()
   "Like `forward-comment' but with special provisions for docTeX mode.
 In docTeX mode \"%\" at the start of a line will be treated as whitespace."
-  (if (eq major-mode 'doctex-mode)
+  (if (eq major-mode 'docTeX-mode)
       ;; XXX: We should probably cater for ^^A as well.
       (progn
         (while (progn (if (bolp) (skip-chars-forward "%"))
@@ -1565,7 +1563,7 @@ Set this to nil if verification of command syntax is 
unwanted.")
   '((?\[ . ?\]) (?< . ?>) (?\( . ?\)))
   "List character pairs used as delimiters for optional arguments.")
 
-(defvar font-latex-syntax-error-modes '(latex-mode)
+(defvar font-latex-syntax-error-modes '(LaTeX-mode)
   "List of modes where syntax errors in macros should be indicated.")
 
 (defun font-latex-match-command-with-arguments (regexp keywords face limit)
@@ -1794,7 +1792,7 @@ cases.")
          (pos (funcall search)))
     (while (and pos
                 (member (match-string 1)
-                        (if (eq major-mode 'doctex-mode)
+                        (if (eq major-mode 'docTeX-mode)
                             (remove "_" font-latex-match-simple-exclude-list)
                           font-latex-match-simple-exclude-list)))
       (setq pos (funcall search)))
diff --git a/latex.el b/latex.el
index 8d734eff..f86e6ebe 100644
--- a/latex.el
+++ b/latex.el
@@ -1,6 +1,6 @@
 ;;; latex.el --- Support for LaTeX documents.  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 1991, 1993-2023 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1993-2024 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Keywords: tex
@@ -69,9 +69,8 @@
   "Default options to documentclass.
 A comma-seperated list of strings."
   :group 'LaTeX-environment
-  :type '(repeat (string :format "%v")))
-
-(make-variable-buffer-local 'LaTeX-default-options)
+  :type '(repeat (string :format "%v"))
+  :local t)
 
 (defcustom LaTeX-insert-into-comments t
   "Whether insertion commands stay in comments.
@@ -118,7 +117,7 @@ This depends on `LaTeX-insert-into-comments'."
 
 ;;; Syntax Table
 
-(defvar LaTeX-mode-syntax-table (copy-syntax-table TeX-mode-syntax-table)
+(defvar LaTeX-mode-syntax-table (make-syntax-table TeX-mode-syntax-table)
   "Syntax table used in LaTeX mode.")
 
 (progn ; set [] to match for LaTeX.
@@ -554,8 +553,8 @@ The behaviour of this hook is controlled by variable 
`LaTeX-section-label'."
 It is overridden by `LaTeX-default-document-environment' when it
 is non-nil and the current environment is \"document\"."
   :group 'LaTeX-environment
-  :type 'string)
-(make-variable-buffer-local 'LaTeX-default-environment)
+  :type 'string
+  :local t)
 
 (defvar-local LaTeX-default-document-environment nil
   "The default environment when creating new ones with
@@ -939,7 +938,7 @@ Assume the current point is on neither \"begin{foo}\" nor 
\"end{foo}\"."
                 ;; comment-prefix.  Hence, the next check just looks
                 ;; if we're inside such a group and returns non-nil to
                 ;; recognize such a situation.
-                (and (eq major-mode 'doctex-mode)
+                (and (eq major-mode 'docTeX-mode)
                      (looking-at-p (concat (regexp-quote TeX-esc)
                                    "\\(?:begin\\|end\\) *{macrocode\\*?}"))))
         (setq arg (if (= (char-after (match-beginning 1)) ?e)
@@ -1002,8 +1001,8 @@ optional argument is omitted.)"
   :group 'LaTeX-environment
   :type '(choice (const :tag "Do not prompt" nil)
                  (const :tag "Empty" "")
-                 (string :format "%v")))
-(make-variable-buffer-local 'LaTeX-float)
+                 (string :format "%v"))
+  :local t)
 
 (defcustom LaTeX-top-caption-list nil
   "List of float environments with top caption."
@@ -1047,14 +1046,14 @@ code listings and take a caption and label."
 (defcustom LaTeX-default-format ""
   "Default format for array and tabular environments."
   :group 'LaTeX-environment
-  :type 'string)
-(make-variable-buffer-local 'LaTeX-default-format)
+  :type 'string
+  :local t)
 
 (defcustom LaTeX-default-width "1.0\\linewidth"
   "Default width for minipage and tabular* environments."
   :group 'LaTeX-environment
-  :type 'string)
-(make-variable-buffer-local 'LaTeX-default-width)
+  :type 'string
+  :local t)
 
 (defcustom LaTeX-default-position ""
   "Default position for array and tabular environments.
@@ -1062,8 +1061,8 @@ If nil, act like the empty string is given, but do not 
prompt."
   :group 'LaTeX-environment
   :type '(choice (const :tag "Do not prompt" nil)
                  (const :tag "Empty" "")
-                 string))
-(make-variable-buffer-local 'LaTeX-default-position)
+                 string)
+  :local t)
 
 (defcustom LaTeX-equation-label "eq:"
   "Default prefix to equation labels."
@@ -1148,9 +1147,8 @@ corresponding entry."
   :group 'LaTeX-label
   :type '(repeat (cons (string :tag "Environment")
                        (choice (string :tag "Label prefix")
-                               (symbol :tag "Label prefix symbol")))))
-
-(make-variable-buffer-local 'LaTeX-label-alist)
+                               (symbol :tag "Label prefix symbol"))))
+  :local t)
 
 (defvar TeX-read-label-prefix nil
   "Initial input for the label in `TeX-read-label'.")
@@ -4106,7 +4104,7 @@ consideration just as is in the non-commented source 
code."
 ;;
 ;; Comments can be filled syntax-aware or not.
 ;;
-;; In `doctex-mode' line comments should always be indented
+;; In `docTeX-mode' line comments should always be indented
 ;; syntax-aware and the comment character has to be anchored at the
 ;; first column (unless the appear in a macrocode environment).  Other
 ;; comments not in the documentation parts always start after the
@@ -4117,7 +4115,7 @@ consideration just as is in the non-commented source 
code."
 ;; `LaTeX-syntactic-comments' disabled, line comments should still be
 ;; indented syntax-aware.
 ;;
-;; In `latex-mode' comments starting in different columns don't have
+;; In `LaTeX-mode' comments starting in different columns don't have
 ;; to be handled differently.  They don't have to be anchored in
 ;; column one.  That means that in any case indentation before and
 ;; after the comment characters has to be checked and adjusted.
@@ -4341,7 +4339,7 @@ the regexp's which are stored in
 `LaTeX-indent-mid-regexp-local' and
 `LaTeX-indent-end-regexp-local' accordingly.  Some standard
 macros are added to the regexp's.  This function is called in
-`LaTeX-common-initialization' to set the regexp's."
+`LaTeX-mode-cleanup' to set the regexp's."
   (let* (cmds
          symbs
          (func (lambda (in regexp out)
@@ -4395,9 +4393,9 @@ Lines starting with an item is given an extra indentation 
of
                  (concat (match-string 0) (TeX-comment-padding-string))))))
     (save-excursion
       (cond ((and fill-prefix
-                  (eq major-mode 'doctex-mode)
+                  (eq major-mode 'docTeX-mode)
                   (TeX-in-line-comment))
-             ;; If point is in a line comment in `doctex-mode' we only
+             ;; If point is in a line comment in `docTeX-mode' we only
              ;; consider the inner indentation.  An exception is when
              ;; we're inside a verbatim environment where we don't
              ;; want to touch the indentation, notably with a
@@ -4471,7 +4469,7 @@ outer indentation in case of a commented line.  The 
symbols
           entry
           found)
       (cond ((save-excursion (beginning-of-line) (bobp)) 0)
-            ((and (eq major-mode 'doctex-mode)
+            ((and (eq major-mode 'docTeX-mode)
                   fill-prefix
                   (TeX-in-line-comment)
                   (progn
@@ -4587,7 +4585,7 @@ outer indentation in case of a commented line.  The 
symbols
         comment-current-flag
         comment-last-flag
         (indent-across-comments (or docTeX-indent-across-comments
-                                    (not (eq major-mode 'doctex-mode)))))
+                                    (not (eq major-mode 'docTeX-mode)))))
     (beginning-of-line)
     (setq line-comment-current-flag (TeX-in-line-comment)
           comment-current-flag (TeX-in-commented-line))
@@ -4616,7 +4614,7 @@ outer indentation in case of a commented line.  The 
symbols
     ;; code comments).  Additionally we don't want to compute inner
     ;; indentation when a commented and a non-commented line are
     ;; compared.
-    (cond ((or (and (eq major-mode 'doctex-mode)
+    (cond ((or (and (eq major-mode 'docTeX-mode)
                     (or (and line-comment-current-flag
                              (not line-comment-last-flag))
                         (and (not line-comment-current-flag)
@@ -4637,7 +4635,7 @@ outer indentation in case of a commented line.  The 
symbols
               ;; Some people have opening braces at the end of the
               ;; line, e.g. in case of `\begin{letter}{%'.
               (TeX-brace-count-line)))
-          ((and (eq major-mode 'doctex-mode)
+          ((and (eq major-mode 'docTeX-mode)
                 (looking-at (concat (regexp-quote TeX-esc)
                                     "end[ \t]*{macrocode\\*?}"))
                 fill-prefix
@@ -4726,11 +4724,11 @@ outer indentation in case of a commented line.  The 
symbols
                      ;; If `LaTeX-syntactic-comments' is not enabled,
                      ;; do conventional indentation
                      LaTeX-syntactic-comments
-                     ;; Line comments in `doctex-mode' are always
+                     ;; Line comments in `docTeX-mode' are always
                      ;; indented syntax-aware so we need their inner
                      ;; indentation.
                      (and (TeX-in-line-comment)
-                          (eq major-mode 'doctex-mode))))))
+                          (eq major-mode 'docTeX-mode))))))
       ;; INNER indentation
       (save-excursion
         (beginning-of-line)
@@ -4754,7 +4752,7 @@ recognized."
                (eq force-type 'inner))
           (and (not force-type)
                (or (and (TeX-in-line-comment)
-                        (eq major-mode 'doctex-mode))
+                        (eq major-mode 'docTeX-mode))
                    (and (TeX-in-commented-line)
                         ;; Only move after the % if we're not
                         ;; performing a newline command (bug#47757).
@@ -5359,11 +5357,11 @@ depends on the value of `LaTeX-syntactic-comments'."
        ;; Syntax-aware filling:
        ;; * `LaTeX-syntactic-comments' enabled: Everything.
        ;; * `LaTeX-syntactic-comments' disabled: Uncommented code and
-       ;;   line comments in `doctex-mode'.
+       ;;   line comments in `docTeX-mode'.
        ((or (or LaTeX-syntactic-comments
                 (and (not LaTeX-syntactic-comments)
                      (not has-comment)))
-            (and (eq major-mode 'doctex-mode)
+            (and (eq major-mode 'docTeX-mode)
                  (TeX-in-line-comment)))
         (let ((fill-prefix comment-fill-prefix))
           (save-excursion
@@ -5537,7 +5535,7 @@ environment in commented regions with the same comment 
prefix."
                 ;; comment-prefix.  Hence, the next check just looks
                 ;; if we're inside such a group and returns non-nil to
                 ;; recognize such a situation.
-                (and (eq major-mode 'doctex-mode)
+                (and (eq major-mode 'docTeX-mode)
                      (looking-at-p " *{macrocode\\*?}")))
         (setq level
               (if (= (char-after (match-beginning 1)) ?b) ;;begin
@@ -6591,6 +6589,7 @@ commands are defined:
   :lighter nil
   :keymap (list (cons (LaTeX-math-abbrev-prefix) LaTeX-math-keymap))
   (TeX-set-mode-name))
+;; FIXME: Is this still necessary?
 (defalias 'latex-math-mode #'LaTeX-math-mode)
 
 (easy-menu-define LaTeX-math-mode-menu
@@ -6890,7 +6889,7 @@ corresponds to the variables 
`LaTeX-environment-menu-name' and
 (easy-menu-define LaTeX-mode-command-menu
     LaTeX-mode-map
     "Command menu used in LaTeX mode."
-    (TeX-mode-specific-command-menu 'latex-mode))
+    (TeX-mode-specific-command-menu 'LaTeX-mode))
 
 (easy-menu-define LaTeX-mode-menu
   LaTeX-mode-map
@@ -8113,6 +8112,54 @@ function `TeX--completion-at-point' which should come 
first in
             ;; Any other constructs?
             (t nil)))))
 
+;; The next defcustom and functions control the annotation of labels
+;; during in-buffer completion which is done by
+;; `TeX--completion-at-point' also inside the arguments of \ref and
+;; such and not with the code above.
+
+(defcustom LaTeX-label-annotation-max-length 30
+  "Maximum number of characters for annotation of labels.
+Setting this variable to 0 disables label annotation during
+in-buffer completion."
+  :group 'LaTeX-label
+  :type 'integer)
+
+(defun LaTeX-completion-label-annotation-function (label)
+  "Return context for LABEL in a TeX file.
+Context is a string gathered from RefTeX.  Return nil if
+`LaTeX-label-annotation-max-length' is set to 0 or RefTeX-mode is
+not activated.  Context is stripped to the number of characters
+defined in `LaTeX-label-annotation-max-length'."
+  (when (and (bound-and-true-p reftex-mode)
+             (> LaTeX-label-annotation-max-length 0)
+             (boundp 'reftex-docstruct-symbol))
+    (let ((docstruct (symbol-value reftex-docstruct-symbol))
+          s)
+      (and (setq s (nth 2 (assoc label docstruct)))
+           (concat " "
+                   (string-trim-right
+                    (substring s 0 (when (>= (length s)
+                                             LaTeX-label-annotation-max-length)
+                                     LaTeX-label-annotation-max-length))))))))
+
+(defun LaTeX-completion-label-list ()
+  "Return a list of defined labels for in-buffer completion.
+This function checks if RefTeX mode is activated and extracts the
+labels from there.  Otherwise the AUCTeX label list is returned.
+If the list of offered labels is out of sync, re-parse the
+document with `reftex-parse-all' or `TeX-normal-mode'."
+  (if (and (bound-and-true-p reftex-mode)
+           (fboundp 'reftex-access-scan-info)
+           (boundp 'reftex-docstruct-symbol))
+      (progn
+        (reftex-access-scan-info)
+        (let ((docstruct (symbol-value reftex-docstruct-symbol))
+              labels)
+          (dolist (label docstruct labels)
+            (when (stringp (car label))
+              (push (car label) labels)))))
+    (LaTeX-label-list)))
+
 ;;; Mode
 
 (defgroup LaTeX-macro nil
@@ -8148,33 +8195,37 @@ This happens when \\left is inserted."
   :type 'hook
   :group 'LaTeX)
 
-(TeX-abbrev-mode-setup latex-mode)
+(TeX-abbrev-mode-setup LaTeX-mode latex-mode-abbrev-table)
 
 ;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.drv\\'" . latex-mode) t) ;; append to the 
end of `auto-mode-alist' to give higher priority to Guix/Nix's derivation modes
+(add-to-list 'auto-mode-alist '("\\.drv\\'" . LaTeX-mode) t) ;; append to the 
end of `auto-mode-alist' to give higher priority to Guix/Nix's derivation modes
 
 ;; HeVeA files (LaTeX -> HTML converter: http://hevea.inria.fr/)
 ;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.hva\\'" . latex-mode))
+(add-to-list 'auto-mode-alist '("\\.hva\\'" . LaTeX-mode))
+
+(defvar semantic-symref-filepattern-alist) ; Silence compiler
+(with-eval-after-load 'semantic/symref/grep
+  ;; This entry is necessary for M-? to work.
+  ;; <URL:https://lists.gnu.org/r/auctex-devel/2023-09/msg00002.html>
+  ;; <URL:https://lists.gnu.org/r/auctex-devel/2023-09/msg00005.html>
+  (push '(LaTeX-mode "*.ltx" "*.sty" "*.cls" "*.clo" "*.bbl" "*.drv" "*.hva")
+        semantic-symref-filepattern-alist))
 
 (declare-function LaTeX-preview-setup "preview")
 
 ;;;###autoload
-(defun TeX-latex-mode ()
-  ;; FIXME: Use `define-derived-mode'.
+(define-derived-mode LaTeX-mode TeX-mode "LaTeX"
   "Major mode in AUCTeX for editing LaTeX files.
 See info under AUCTeX for full documentation.
 
-Special commands:
-\\{LaTeX-mode-map}
-
 Entering LaTeX mode calls the value of `text-mode-hook',
 then the value of `TeX-mode-hook', and then the value
 of `LaTeX-mode-hook'."
-  (interactive)
+  :after-hook (LaTeX-mode-cleanup)
+
   (LaTeX-common-initialization)
-  (setq TeX-base-mode-name "LaTeX")
-  (setq major-mode 'latex-mode)
+  (setq TeX-base-mode-name mode-name)
   (setq TeX-command-default "LaTeX")
   (setq TeX-sentinel-default-function #'TeX-LaTeX-sentinel)
   (add-hook 'tool-bar-mode-hook #'LaTeX-maybe-install-toolbar nil t)
@@ -8200,7 +8251,18 @@ of `LaTeX-mode-hook'."
                        (apply #'append
                               (mapcar #'cdr LaTeX-provided-class-options)))))
             nil t)
-  (run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'LaTeX-mode-hook)
+
+  (when (fboundp 'LaTeX-preview-setup)
+    (LaTeX-preview-setup))
+  ;; Set up flymake backend, see latex-flymake.el
+  (add-hook 'flymake-diagnostic-functions #'LaTeX-flymake nil t))
+
+(defun LaTeX-mode-cleanup ()
+  "Cleanup function for `LaTeX-mode'.
+Run after mode hooks and file local variables application."
+  ;; Defeat filladapt
+  (if (bound-and-true-p filladapt-mode)
+      (turn-off-filladapt-mode))
 
   ;; Don't overwrite the value the user set by hooks or file
   ;; (directory) local variables.
@@ -8231,35 +8293,61 @@ of `LaTeX-mode-hook'."
   ;; `LaTeX-indent-begin-list' and so on instead.
   (LaTeX-indent-commands-regexp-make)
 
-  (when (fboundp 'LaTeX-preview-setup)
-    (LaTeX-preview-setup))
-  (TeX-set-mode-name)
-  ;; Defeat filladapt
-  (if (and (boundp 'filladapt-mode)
-           filladapt-mode)
-      (turn-off-filladapt-mode))
-  ;; Set up flymake backend, see latex-flymake.el
-  (add-hook 'flymake-diagnostic-functions #'LaTeX-flymake nil t)
+  (setq TeX-complete-list
+        (append '(("\\\\cite\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
+                   1 LaTeX-bibitem-list "}")
+                  ("\\\\cite{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-bibitem-list "}")
+                  ("\\\\cite{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
+                   2 LaTeX-bibitem-list)
+                  ("\\\\nocite{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-bibitem-list "}")
+                  ("\\\\nocite{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
+                   2 LaTeX-bibitem-list)
+                  ("\\\\[Rr]ef{\\([^{}\n\r\\%,]*\\)" 1 
LaTeX-completion-label-list "}")
+                  ("\\\\eqref{\\([^{}\n\r\\%,]*\\)" 1 
LaTeX-completion-label-list "}")
+                  ("\\\\pageref{\\([^{}\n\r\\%,]*\\)" 1 
LaTeX-completion-label-list "}")
+                  ("\\\\\\(index\\|glossary\\){\\([^{}\n\r\\%]*\\)"
+                   2 LaTeX-index-entry-list "}")
+                  ("\\\\begin{\\([A-Za-z]*\\)" 1 
LaTeX-environment-list-filtered "}")
+                  ("\\\\end{\\([A-Za-z]*\\)" 1 LaTeX-environment-list-filtered 
"}")
+                  ("\\\\renewcommand\\*?{\\\\\\([A-Za-z]*\\)"
+                   1 TeX-symbol-list-filtered "}")
+                  ("\\\\renewenvironment\\*?{\\([A-Za-z]*\\)"
+                   1 LaTeX-environment-list-filtered "}")
+                  ("\\\\\\(this\\)?pagestyle{\\([A-Za-z]*\\)"
+                   2 LaTeX-pagestyle-list "}")
+                  (LaTeX--after-math-macro-prefix-p
+                   1 (lambda ()
+                       (seq-filter #'stringp
+                                   (append (mapcar #'cadr LaTeX-math-list)
+                                           (mapcar #'cadr 
LaTeX-math-default))))
+                   (if TeX-insert-braces "{}")))
+                TeX-complete-list)))
 
-  ;; Complete style initialization in buffers which don't visit files
-  ;; and which are therefore missed by the setting of `find-file-hook'
-  ;; in `VirTeX-common-initialization'.  This is necessary for
-  ;; `xref-find-references', for example. (bug#65912)
-  (unless buffer-file-truename
-    (TeX-update-style)))
+;; COMPATIBILITY for Emacs<29
+;;;###autoload
+(put 'LaTeX-mode 'auctex-function-definition (symbol-function 'LaTeX-mode))
 
-(TeX-abbrev-mode-setup doctex-mode)
+;; Compatibility for former mode name.  Directory local variables
+;; prepared for `latex-mode' continue to be valid for `LaTeX-mode'.
+(TeX-derived-mode-add-parents 'LaTeX-mode '(latex-mode))
 
-;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.dtx\\'" . doctex-mode))
+(with-eval-after-load 'semantic/symref/grep
+  (push '(docTeX-mode "*.dtx") semantic-symref-filepattern-alist))
+
+;; Enable LaTeX abbrevs in docTeX mode buffer.
+;; No need to include text mode abbrev table as parents because LaTeX
+;; mode abbrev table inherits it.
+(let ((p (list LaTeX-mode-abbrev-table)))
+  ;; Inherit abbrev table of the former name, if it exists.
+  (if (boundp 'doctex-mode-abbrev-table)
+      (push doctex-mode-abbrev-table p))
+  (define-abbrev-table 'docTeX-mode-abbrev-table nil nil :parents p))
 
 ;;;###autoload
-(define-derived-mode docTeX-mode TeX-latex-mode "docTeX"
+(define-derived-mode docTeX-mode LaTeX-mode "docTeX"
   "Major mode in AUCTeX for editing .dtx files derived from `LaTeX-mode'.
 Runs `LaTeX-mode', sets a few variables and
 runs the hooks in `docTeX-mode-hook'."
-  :abbrev-table doctex-mode-abbrev-table
-  (setq major-mode 'doctex-mode)
   (set (make-local-variable 'LaTeX-insert-into-comments) t)
   (set (make-local-variable 'LaTeX-syntactic-comments) t)
   (setq TeX-default-extension docTeX-default-extension)
@@ -8267,31 +8355,18 @@ runs the hooks in `docTeX-mode-hook'."
   (setq paragraph-start (concat paragraph-start "\\|%<")
         paragraph-separate (concat paragraph-separate "\\|%<")
         TeX-comment-start-regexp "\\(?:%\\(?:<[^>]+>\\)?\\)")
-  (setq TeX-base-mode-name "docTeX")
-  (TeX-set-mode-name)
+  (setq TeX-base-mode-name mode-name)
   ;; We can remove the next `setq' when syntax propertization
   ;; decouples font lock and `font-latex-setup' stops calling
   ;; `font-lock-set-defaults'.
   (setq font-lock-set-defaults nil)
   (funcall TeX-install-font-lock))
 
-;; Enable LaTeX abbrevs in docTeX mode buffer.
-(let ((p (abbrev-table-get doctex-mode-abbrev-table :parents)))
-  (or (memq latex-mode-abbrev-table p)
-      (abbrev-table-put doctex-mode-abbrev-table :parents
-                        (cons latex-mode-abbrev-table p))))
-
-;;This is actually a mess: to fit the scheme properly, our derived
-;;mode definition would have had to be made for TeX-doctex-mode in the
-;;first place, but then we could not have used define-derived-mode, or
-;;all mode-specific variables would have gotten non-AUCTeX names.
-;;This solution has the advantage that documentation strings are
-;;provided in the autoloads, and has the disadvantage that docTeX-mode
-;;is not aliased to doctex-mode (not even when the AUCTeX version is
-;;disabled) as would be normal for our scheme.
-
-;;;###autoload
-(defalias 'TeX-doctex-mode #'docTeX-mode)
+;; Compatibility for former mode name.  Directory local variables
+;; prepared for `doctex-mode' continue to be valid for `docTeX-mode'.
+;; In addition, dir local vars for `latex-mode' are now valid for
+;; `docTeX-mode' as well.
+(TeX-derived-mode-add-parents 'docTeX-mode '(doctex-mode latex-mode))
 
 (defcustom docTeX-clean-intermediate-suffixes
   TeX-clean-default-intermediate-suffixes
@@ -8338,12 +8413,8 @@ function would return non-nil and `(match-string 1)' 
would return
 
 (defun LaTeX-common-initialization ()
   "Common initialization for LaTeX derived modes."
-  (VirTeX-common-initialization)
-  (set-syntax-table LaTeX-mode-syntax-table)
   (set (make-local-variable 'indent-line-function) #'LaTeX-indent-line)
 
-  (setq local-abbrev-table latex-mode-abbrev-table)
-
   ;; Filling
   (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
   (set (make-local-variable 'fill-paragraph-function) #'LaTeX-fill-paragraph)
@@ -8408,36 +8479,6 @@ function would return non-nil and `(match-string 1)' 
would return
                                                 ("tabular" . LaTeX-item-array)
                                                 ("tabular*" . 
LaTeX-item-tabular*)))
 
-  (setq TeX-complete-list
-        (append '(("\\\\cite\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
-                   1 LaTeX-bibitem-list "}")
-                  ("\\\\cite{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-bibitem-list "}")
-                  ("\\\\cite{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
-                   2 LaTeX-bibitem-list)
-                  ("\\\\nocite{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-bibitem-list "}")
-                  ("\\\\nocite{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
-                   2 LaTeX-bibitem-list)
-                  ("\\\\[Rr]ef{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-                  ("\\\\eqref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-                  ("\\\\pageref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-                  ("\\\\\\(index\\|glossary\\){\\([^{}\n\r\\%]*\\)"
-                   2 LaTeX-index-entry-list "}")
-                  ("\\\\begin{\\([A-Za-z]*\\)" 1 
LaTeX-environment-list-filtered "}")
-                  ("\\\\end{\\([A-Za-z]*\\)" 1 LaTeX-environment-list-filtered 
"}")
-                  ("\\\\renewcommand\\*?{\\\\\\([A-Za-z]*\\)"
-                   1 TeX-symbol-list-filtered "}")
-                  ("\\\\renewenvironment\\*?{\\([A-Za-z]*\\)"
-                   1 LaTeX-environment-list-filtered "}")
-                  ("\\\\\\(this\\)?pagestyle{\\([A-Za-z]*\\)"
-                   2 LaTeX-pagestyle-list "}")
-                  (LaTeX--after-math-macro-prefix-p
-                   1 (lambda ()
-                       (seq-filter #'stringp
-                                   (append (mapcar #'cadr LaTeX-math-list)
-                                           (mapcar #'cadr 
LaTeX-math-default))))
-                   (if TeX-insert-braces "{}")))
-                TeX-complete-list))
-
   (LaTeX-add-environments
    '("document" LaTeX-env-document)
    '("enumerate" LaTeX-env-item)
@@ -9098,8 +9139,6 @@ function would return non-nil and `(match-string 1)' 
would return
   (set (make-local-variable 'imenu-create-index-function)
        #'LaTeX-imenu-create-index-function)
 
-  (use-local-map LaTeX-mode-map)
-
   ;; Initialization of `add-log-current-defun-function':
   (set (make-local-variable 'add-log-current-defun-function)
        #'TeX-current-defun-name)
diff --git a/latex/preview.dtx b/latex/preview.dtx
index f8b72e05..23f5b2da 100644
--- a/latex/preview.dtx
+++ b/latex/preview.dtx
@@ -1891,7 +1891,7 @@ Please complain to your document class author}%
 % \Finale{}
 % \iffalse
 % Local Variables: 
-% mode: doctex
+% mode: docTeX
 % TeX-master: "preview.drv"
 % End: 
 % \fi
diff --git a/plain-tex.el b/plain-tex.el
index b4c78fe4..779c30a0 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -92,7 +92,7 @@ Install tool bar if `plain-TeX-enable-toolbar' and
 (easy-menu-define plain-TeX-mode-command-menu
     plain-TeX-mode-map
     "Command menu used in TeX mode."
-    (TeX-mode-specific-command-menu 'plain-tex-mode))
+    (TeX-mode-specific-command-menu 'plain-TeX-mode))
 
 (easy-menu-define plain-TeX-mode-menu
     plain-TeX-mode-map
@@ -113,41 +113,48 @@ plain-TeX file, or any mode derived thereof.  See variable
   :type 'hook
   :group 'TeX-misc)
 
-(TeX-abbrev-mode-setup plain-tex-mode)
+(TeX-abbrev-mode-setup plain-TeX-mode plain-tex-mode-abbrev-table)
 
 ;;;###autoload
-(defun TeX-plain-tex-mode ()
+(define-derived-mode plain-TeX-mode TeX-mode
+  ;; The mode name can be "plain-TeX", but in that case, we have to
+  ;; change the "TeX" in the above call to `easy-menu-define' as well.
+  ;; See what "Extend this Menu" entry does in
+  ;; `TeX-common-menu-entries'.
+  "TeX"
   "Major mode in AUCTeX for editing plain TeX files.
 See info under AUCTeX for documentation.
 
-Special commands:
-\\{plain-TeX-mode-map}
-
-Entering `plain-tex-mode' calls the value of `text-mode-hook',
+Entering `plain-TeX-mode' calls the value of `text-mode-hook',
 then the value of `TeX-mode-hook', and then the value
 of `plain-TeX-mode-hook'."
-  (interactive)
+  :syntax-table nil
+  :after-hook (plain-TeX-mode-cleanup)
+
   (plain-TeX-common-initialization)
-  (setq major-mode 'plain-tex-mode)
-  (use-local-map plain-TeX-mode-map)
-  (setq TeX-base-mode-name "TeX")
-  (setq TeX-command-default "TeX")
-  (add-hook 'tool-bar-mode-hook #'plain-TeX-maybe-install-toolbar nil t)
-  (plain-TeX-maybe-install-toolbar)
-  (run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook)
-  (TeX-set-mode-name)
-  ;; Complete style initialization in buffers which don't visit files
-  ;; and which are therefore missed by the setting of `find-file-hook'
-  ;; in `VirTeX-common-initialization'.  This is necessary for
-  ;; `xref-find-references', for example. (bug#65912)
-  (unless buffer-file-truename
-    (TeX-update-style)))
+  (setq TeX-base-mode-name mode-name)
+  (setq TeX-command-default "TeX"))
+
+(defun plain-TeX-mode-cleanup ()
+  "Cleanup function for `plain-TeX-mode'.
+Run after mode hooks and file local variables application."
+  ;; Don't install tool bar in AmSTeX mode.
+  (unless (derived-mode-p 'AmSTeX-mode)
+    (add-hook 'tool-bar-mode-hook
+              #'plain-TeX-maybe-install-toolbar nil t)
+    (plain-TeX-maybe-install-toolbar)))
+
+;; COMPATIBILITY for Emacs<29
+;;;###autoload
+(put 'plain-TeX-mode 'auctex-function-definition (symbol-function 
'plain-TeX-mode))
+
+;; Compatibility for former mode name.  Directory local variables
+;; prepared for `plain-tex-mode' continue to be valid for
+;; `plain-TeX-mode'.
+(TeX-derived-mode-add-parents 'plain-TeX-mode '(plain-tex-mode))
 
 (defun plain-TeX-common-initialization ()
   "Common initialization for plain TeX like modes."
-  (VirTeX-common-initialization)
-  (set-syntax-table TeX-mode-syntax-table)
-  (setq local-abbrev-table plain-tex-mode-abbrev-table)
   (set (make-local-variable 'TeX-style-hook-dialect) plain-TeX-dialect)
   (setq TeX-sentinel-default-function #'TeX-TeX-sentinel)
   (setq paragraph-start
@@ -275,6 +282,11 @@ that is, you do _not_ have to cater for this yourself by 
adding \\\\\\=' or $."
 
 (defvar AmSTeX-mode-map
   (let ((map (make-sparse-keymap)))
+    ;; Don't use `plain-TeX-mode-map' as parent.  That would corrupt
+    ;; the menu bar in the following two ways. :-(
+    ;;  - "TeX" entry appears in addition to "AmS-TeX", with
+    ;;    duplicated content.
+    ;;  - "Command" entry disappears.
     (set-keymap-parent map TeX-mode-map)
     map)
   "Keymap used in `AmSTeX-mode'.")
@@ -283,44 +295,42 @@ that is, you do _not_ have to cater for this yourself by 
adding \\\\\\=' or $."
 (easy-menu-define AmSTeX-mode-command-menu
     AmSTeX-mode-map
     "Command menu used in AmSTeX mode."
-    (TeX-mode-specific-command-menu 'ams-tex-mode))
+    (TeX-mode-specific-command-menu 'AmSTeX-mode))
 
 (easy-menu-define AmSTeX-mode-menu
   AmSTeX-mode-map
   "Menu used in AmSTeX mode."
   (cons "AmS-TeX" plain-TeX-menu-entries))
 
-(defcustom AmS-TeX-mode-hook nil
-  "A hook run in AmS-TeX mode buffers."
+(define-obsolete-variable-alias
+  'AmS-TeX-mode-hook 'AmSTeX-mode-hook "AUCTeX 14")
+(defcustom AmSTeX-mode-hook nil
+  "A hook run in AmSTeX mode buffers."
   :type 'hook
   :group 'TeX-misc)
 
 ;;;###autoload
-(defun ams-tex-mode ()
-  "Major mode in AUCTeX for editing AmS-TeX files.
+(define-derived-mode AmSTeX-mode plain-TeX-mode "AmS-TeX"
+  "Major mode in AUCTeX for editing AmSTeX files.
 See info under AUCTeX for documentation.
 
-Special commands:
-\\{AmSTeX-mode-map}
+Entering `AmSTeX-mode' calls the value of `text-mode-hook', then
+the value of `TeX-mode-hook', `plain-TeX-mode-hook' and then the
+value of `AmSTeX-mode-hook'."
+  :syntax-table nil
+  :abbrev-table nil
 
-Entering `ams-tex-mode' calls the value of `text-mode-hook',
-then the value of `TeX-mode-hook', and then the value
-of `AmS-TeX-mode-hook'."
-  (interactive)
-  (plain-TeX-common-initialization)
-  (setq major-mode 'ams-tex-mode)
-  (use-local-map AmSTeX-mode-map)
-
-  (setq TeX-base-mode-name "AmS-TeX")
-  (setq TeX-command-default "AmSTeX")
-  (run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'AmS-TeX-mode-hook)
-  (TeX-set-mode-name)
-  ;; Complete style initialization in buffers which don't visit files
-  ;; and which are therefore missed by the setting of `find-file-hook'
-  ;; in `VirTeX-common-initialization'.  This is necessary for
-  ;; `xref-find-references', for example. (bug#65912)
-  (unless buffer-file-truename
-    (TeX-update-style)))
+  (setq TeX-base-mode-name mode-name)
+  (setq TeX-command-default "AmSTeX"))
+
+;;;###autoload
+(defalias 'ams-tex-mode #'AmSTeX-mode)
+
+;; Compatibility for former mode name.  Directory local variables
+;; prepared for `ams-tex-mode' continue to be valid for `AmSTeX-mode'.
+;; In addition, dir local vars for `plain-tex-mode' are now valid for
+;; `AmSTeX-mode' as well.
+(TeX-derived-mode-add-parents 'AmSTeX-mode '(ams-tex-mode plain-tex-mode))
 
 (defcustom AmSTeX-clean-intermediate-suffixes
   TeX-clean-default-intermediate-suffixes
diff --git a/preview.el b/preview.el
index 4eb8b2d6..d0bb67f2 100644
--- a/preview.el
+++ b/preview.el
@@ -1,9 +1,9 @@
 ;;; preview.el --- embed preview LaTeX images in source buffer  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2001-2023  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2024  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
-;; Keywords: tex, wp, convenience
+;; Keywords: tex, text, convenience
 
 ;; 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
@@ -245,9 +245,8 @@ that is."
       (apply (car hook) (append (cdr hook) rest)))))
 
 
-(defvar TeX-active-tempdir nil
+(defvar-local TeX-active-tempdir nil
   "List of directory name, top directory name and reference count.")
-(make-variable-buffer-local 'TeX-active-tempdir)
 
 (defcustom preview-bb-filesize 1024
   "Size of file area scanned for bounding box information."
@@ -289,21 +288,20 @@ If `preview-fast-conversion' is set, this option is not
   :group 'preview-gs
   :type 'number)
 
-(defvar preview-parsed-font-size nil
+(defvar-local preview-parsed-font-size nil
   "Font size as parsed from the log of LaTeX run.")
-(make-variable-buffer-local 'preview-parsed-font-size)
-(defvar preview-parsed-magnification nil
+
+(defvar-local preview-parsed-magnification nil
   "Magnification as parsed from the log of LaTeX run.")
-(make-variable-buffer-local 'preview-parsed-magnification)
-(defvar preview-parsed-pdfoutput nil
+
+(defvar-local preview-parsed-pdfoutput nil
   "PDFoutput as parsed from the log of LaTeX run.")
-(make-variable-buffer-local 'preview-parsed-pdfoutput)
-(defvar preview-parsed-counters nil
+
+(defvar-local preview-parsed-counters nil
   "Counters as parsed from the log of LaTeX run.")
-(make-variable-buffer-local 'preview-parsed-counters)
-(defvar preview-parsed-tightpage nil
+
+(defvar-local preview-parsed-tightpage nil
   "Tightpage as parsed from the log of LaTeX run.")
-(make-variable-buffer-local 'preview-parsed-tightpage)
 
 (defun preview-get-magnification ()
   "Get magnification from `preview-parsed-magnification'."
@@ -364,14 +362,12 @@ See also `preview-gs-command'."
   :group 'preview-gs
   :type '(repeat string))
 
-(defvar preview-gs-queue nil
+(defvar-local preview-gs-queue nil
   "List of overlays to convert using gs.
 Buffer-local to the appropriate TeX process buffer.")
-(make-variable-buffer-local 'preview-gs-queue)
 
-(defvar preview-gs-outstanding nil
+(defvar-local preview-gs-outstanding nil
   "Overlays currently processed.")
-(make-variable-buffer-local 'preview-gs-outstanding)
 
 (defcustom preview-gs-outstanding-limit 2
   "Number of requests allowed to be outstanding.
@@ -390,49 +386,40 @@ follow changes in the displayed buffer area faster."
                             (< value 10))))
           :tag "small number"))
 
-(defvar preview-gs-answer nil
+(defvar-local preview-gs-answer nil
   "Accumulated answer of Ghostscript process.")
-(make-variable-buffer-local 'preview-gs-answer)
 
-(defvar preview-gs-image-type nil
+(defvar-local preview-gs-image-type nil
   "Image type for gs produced images.")
-(make-variable-buffer-local 'preview-gs-image-type)
 
-(defvar preview-gs-sequence nil
+(defvar-local preview-gs-sequence nil
   "Pair of sequence numbers for gs produced images.")
-(make-variable-buffer-local 'preview-gs-sequence)
 
-(defvar preview-scale nil
+(defvar-local preview-scale nil
   "Screen scale of images.
 Magnify by this factor to make images blend with other
 screen content.  Buffer-local to rendering buffer.")
-(make-variable-buffer-local 'preview-scale)
 
-(defvar preview-colors nil
+(defvar-local preview-colors nil
   "Color setup list.
 An array with elements 0, 1 and 2 for background,
 foreground and border colors, respectively.  Each element
 is a list of 3 real numbers between 0 and 1, or nil
 of nothing special should be done for the color")
-(make-variable-buffer-local 'preview-colors)
 
-(defvar preview-gs-init-string nil
+(defvar-local preview-gs-init-string nil
   "Ghostscript setup string.")
-(make-variable-buffer-local 'preview-gs-init-string)
 
-(defvar preview-ps-file nil
+(defvar-local preview-ps-file nil
   "PostScript file name for fast conversion.")
-(make-variable-buffer-local 'preview-ps-file)
 
-(defvar preview-gs-dsc nil
+(defvar-local preview-gs-dsc nil
   "Parsed DSC information.")
-(make-variable-buffer-local 'preview-gs-dsc)
 
-(defvar preview-resolution nil
+(defvar-local preview-resolution nil
   "Screen resolution where rendering started.
 Cons-cell of x and y resolution, given in
 dots per inch.  Buffer-local to rendering buffer.")
-(make-variable-buffer-local 'preview-resolution)
 
 (defun preview-gs-resolution (scale xres yres)
   "Generate resolution argument for gs.
@@ -452,10 +439,9 @@ show as response of Ghostscript."
       (overlay-put ov 'queued nil))
     ov))
 
-(defvar preview-gs-command-line nil)
-(make-variable-buffer-local 'preview-gs-command-line)
-(defvar preview-gs-file nil)
-(make-variable-buffer-local 'preview-gs-file)
+(defvar-local preview-gs-command-line nil)
+
+(defvar-local preview-gs-file nil)
 
 (defcustom preview-fast-conversion t
   "Set this for single-file PostScript conversion.
@@ -1993,9 +1979,8 @@ purposes."
 
 (defvar preview-temporary-opened nil)
 
-(defvar preview-last-location nil
+(defvar-local 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."
@@ -2275,7 +2260,7 @@ has FUNC called with its current buffer being set to it."
       (with-current-buffer (pop buffers)
         (when
             (or (memq (current-buffer) default-buffers)
-                (and (memq major-mode '(plain-tex-mode latex-mode))
+                (and (memq major-mode '(plain-TeX-mode LaTeX-mode))
                      (or (stringp TeX-master)
                          (eq TeX-master t))
                      (string= (expand-file-name (TeX-master-file t))
@@ -2388,16 +2373,14 @@ BUFFER-MISC is the appropriate data to be used."
                    buffer-misc))))))
 
 ;; Add autoload cookies explicitly for desktop.el.
-;; <Background> preview-latex doesn't conform to the following
-;; assumptions of desktop.el:
+;; <Background> desktop.el assumes the following two:
 ;; (1) The file associated with the major mode by autoload has defun
 ;;     of handler, which restores the state of the buffer.
 ;; (2) The file has suitable `add-to-list' form also for
 ;;     `desktop-buffer-mode-handlers' to register the entry of the
 ;;     handler.
-;; This isn't the case here because the file associated with
-;; `latex-mode' is tex-mode.el, neither preview.el nor latex.el.  Thus
-;; we include both of them as explicit autoloads in preview-latex.el.
+;; This isn't the case for preview-latex.  Thus we register both of
+;; them as autoload cookies in AUCTeX initialzation code.
 ;;;###autoload
 (defun desktop-buffer-preview (file-name _buffer-name misc)
   "Hook function for restoring persistent previews into a buffer."
@@ -2411,7 +2394,7 @@ BUFFER-MISC is the appropriate data to be used."
 
 ;;;###autoload
 (add-to-list 'desktop-buffer-mode-handlers
-             '(latex-mode . desktop-buffer-preview))
+             '(LaTeX-mode . desktop-buffer-preview))
 
 (defcustom preview-auto-cache-preamble 'ask
   "Whether to generate a preamble cache format automatically.
@@ -2565,8 +2548,7 @@ it gets deleted as well."
                 (setcdr file nil)
                 (delete-directory (nth 0 tempdir)))))))))
 
-(defvar preview-buffer-has-counters nil)
-(make-variable-buffer-local 'preview-buffer-has-counters)
+(defvar-local preview-buffer-has-counters nil)
 
 (defun preview-place-preview (snippet start end
                                       box counters tempdir place-opts)
@@ -3108,7 +3090,7 @@ to add the preview functionality."
            (customize-menu-create 'preview))])
         ["Read documentation" preview-goto-info-page]
         ["Report Bug" preview-report-bug]))
-    (if (eq major-mode 'latex-mode)
+    (if (eq major-mode 'LaTeX-mode)
         (preview-mode-setup))
     (unless preview-tb-icon
       (setq preview-tb-icon (preview-filter-specs preview-tb-icon-specs)))
diff --git a/style/amstex.el b/style/amstex.el
index 75889353..702159b3 100644
--- a/style/amstex.el
+++ b/style/amstex.el
@@ -46,7 +46,7 @@
 (TeX-add-style-hook
  "amstex"
  (lambda ()
-   (unless (memq major-mode '(plain-tex-mode ams-tex-mode))
+   (unless (memq major-mode '(plain-TeX-mode AmSTeX-mode))
      (TeX-run-style-hooks "amsmath")))
  TeX-dialect)
 
diff --git a/style/fancyref.el b/style/fancyref.el
index 22fd1c17..a94c60b3 100644
--- a/style/fancyref.el
+++ b/style/fancyref.el
@@ -1,6 +1,6 @@
 ;;; fancyref.el --- AUCTeX style file with support for fancyref.sty  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 1999, 2014, 2015, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 1999--2024 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
 ;; Maintainer: auctex-devel@gnu.org
@@ -91,7 +91,7 @@
    (setq TeX-complete-list
          (append
           '(("\\\\[fF]ref\\(\\[[^]]*\\]\\)?{\\([^{}\n\r\\%,]*\\)" 
-             2 LaTeX-label-list "}")
+             2 LaTeX-completion-label-list "}")
             ("\\\\[fF]ref\\[\\([^{}\n\r\\%,]*\\)" 
              1 LaTeX-fancyref-formats "]")
             ("\\\\[fF]refformat{\\([^{}\n\r\\%,]*\\)"
diff --git a/style/fancyvrb.el b/style/fancyvrb.el
index 530b0621..49711f2f 100644
--- a/style/fancyvrb.el
+++ b/style/fancyvrb.el
@@ -1,6 +1,6 @@
 ;;; fancyvrb.el --- AUCTeX style for `fancyvrb.sty' version 4.5.  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013, 2014, 2016-2023 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2016-2024 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano <mose@gnu.org>
@@ -720,9 +720,17 @@ a list of strings."
     ;; Writing and reading verbatim files
     '("VerbatimInput" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-arg-file-relative)
+    '("VerbatimInput*" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
+      LaTeX-fancyvrb-arg-file-relative)
+
     '("BVerbatimInput" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-arg-file-relative)
+    '("BVerbatimInput*" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
+      LaTeX-fancyvrb-arg-file-relative)
+
     '("LVerbatimInput" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
+      LaTeX-fancyvrb-arg-file-relative)
+    '("LVerbatimInput*" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
       LaTeX-fancyvrb-arg-file-relative))
 
    (LaTeX-add-environments
@@ -826,9 +834,9 @@ a list of strings."
                                 ("UndefineShortVerb" "{")
                                 ("fvset"             "{"))
                               'function)
-     (font-latex-add-keywords '(("VerbatimInput"  "[{")
-                                ("BVerbatimInput" "[{")
-                                ("LVerbatimInput" "[{"))
+     (font-latex-add-keywords '(("VerbatimInput"  "*[{")
+                                ("BVerbatimInput" "*[{")
+                                ("LVerbatimInput" "*[{"))
                               'reference)
      (font-latex-add-keywords '(("Verb" "*[") ; The second argument is 
verbatim.
                                 ("SaveVerb"     "[{")
diff --git a/style/ltugboat.el b/style/ltugboat.el
index 85866df9..c6eb07d0 100644
--- a/style/ltugboat.el
+++ b/style/ltugboat.el
@@ -1,6 +1,6 @@
 ;;; ltugboat.el --- AUCTeX style for `ltugboat.cls' (v2.28)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2019--2023 Free Software Foundation, Inc.
+;; Copyright (C) 2019--2024 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -61,7 +61,8 @@
 
    (setq TeX-complete-list
          (append
-          '(("\\\\nameref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}"))
+          '(("\\\\nameref{\\([^{}\n\r\\%,]*\\)"
+             1 LaTeX-completion-label-list "}"))
           TeX-complete-list))
 
    ;; 6.1 Abstracts
diff --git a/style/nameref.el b/style/nameref.el
index d4c7b10e..22518610 100644
--- a/style/nameref.el
+++ b/style/nameref.el
@@ -1,6 +1,6 @@
 ;;; nameref.el --- AUCTeX style for `nameref.sty'  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2013--2023 Free Software Foundation, Inc.
+;; Copyright (C) 2013--2024 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <mje@inducks.org>
 ;; Maintainer: auctex-devel@gnu.org
@@ -46,7 +46,8 @@
 
    (setq TeX-complete-list
          (append
-          '(("\\\\\\(?:N\\|n\\)ameref\\*?{\\([^{}\n\r\\%,]*\\)" 1 
LaTeX-label-list "}"))
+          '(("\\\\\\(?:N\\|n\\)ameref\\*?{\\([^{}\n\r\\%,]*\\)"
+             1 LaTeX-completion-label-list "}"))
           TeX-complete-list))
 
    ;; Fontification
diff --git a/style/prosper.el b/style/prosper.el
index f1b7adc1..1ae1cb0d 100644
--- a/style/prosper.el
+++ b/style/prosper.el
@@ -1,10 +1,10 @@
 ;;; prosper.el --- Prosper style file for AUCTeX  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2001-2021  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2024  Free Software Foundation, Inc.
 
 ;; Authors:  Phillip Lord<p.lord@russet.org.uk>
 ;;           Nevin Kapur <nevin@jhu.edu>
-;; Keywords: tex, wp, prosper
+;; Keywords: tex, text, prosper
 ;; Version: 0.6
 ;; URL: http://www.mts.jhu.edu/~kapur/emacs/prosper.el
 
diff --git a/style/simpleicons.el b/style/simpleicons.el
index 52347fb1..c0ad1469 100644
--- a/style/simpleicons.el
+++ b/style/simpleicons.el
@@ -1,4 +1,4 @@
-;;; simpleicons.el --- AUCTeX style for `simpleicons.sty' (v11.0.0)  -*- 
lexical-binding: t; -*-
+;;; simpleicons.el --- AUCTeX style for `simpleicons.sty' (v11.1.0)  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2023--2024 Free Software Foundation, Inc.
 
@@ -26,8 +26,8 @@
 
 ;;; Commentary:
 
-;; This file adds support for `simpleicons.sty' (v11.0.0) from
-;; 2024/01/12.  `simpleicons.sty' is part of TeXLive.
+;; This file adds support for `simpleicons.sty' (v11..0) from
+;; 2024/01/19.  `simpleicons.sty' is part of TeXLive.
 
 ;;; Code:
 
@@ -47,6 +47,7 @@
     "4chan"
     "4d"
     "500px"
+    "7zip"
     "99designs"
     "9gag"
     "abbott"
@@ -263,6 +264,7 @@
     "artixlinux"
     "artstation"
     "arxiv"
+    "asahilinux"
     "asana"
     "asciidoctor"
     "asciinema"
@@ -312,6 +314,7 @@
     "azurefunctions"
     "azurepipelines"
     "babel"
+    "babelio"
     "backblaze"
     "backbonedotjs"
     "backendless"
@@ -407,6 +410,7 @@
     "brandfolder"
     "brave"
     "breaker"
+    "brenntag"
     "brevo"
     "brex"
     "bricks"
@@ -450,6 +454,7 @@
     "canvas"
     "capacitor"
     "cardano"
+    "carlsberggroup"
     "carrd"
     "carrefour"
     "carthrottle"
@@ -531,6 +536,7 @@
     "clyp"
     "cmake"
     "cncf"
+    "cnet"
     "cnn"
     "cocacola"
     "cockpit"
@@ -671,6 +677,7 @@
     "datefns"
     "datocms"
     "datto"
+    "davinciresolve"
     "dazn"
     "dbeaver"
     "dblp"
@@ -783,6 +790,7 @@
     "eclipsemosquitto"
     "eclipsevertdotx"
     "edeka"
+    "edgeimpulse"
     "editorconfig"
     "edotleclerc"
     "educative"
@@ -832,6 +840,7 @@
     "esea"
     "eslgaming"
     "eslint"
+    "esotericsoftware"
     "esphome"
     "espressif"
     "esri"
@@ -964,6 +973,7 @@
     "frontify"
     "fsecure"
     "fsharp"
+    "fubo"
     "fugacloud"
     "fujifilm"
     "fujitsu"
@@ -1214,6 +1224,7 @@
     "hungryjacks"
     "husqvarna"
     "hyper"
+    "hyperskill"
     "hypothesis"
     "hyundai"
     "i18next"
@@ -1395,6 +1406,7 @@
     "klm"
     "klook"
     "knative"
+    "knexdotjs"
     "knowledgebase"
     "known"
     "koa"
@@ -1478,6 +1490,7 @@
     "linkedin"
     "linkerd"
     "linkfire"
+    "linksys"
     "linktree"
     "linux"
     "linuxcontainers"
@@ -1760,6 +1773,7 @@
     "nodemon"
     "nodered"
     "nokia"
+    "nomad"
     "norco"
     "nordicsemiconductor"
     "nordvpn"
@@ -1854,6 +1868,7 @@
     "opsgenie"
     "opslevel"
     "oracle"
+    "orange"
     "orcid"
     "oreilly"
     "org"
@@ -1891,6 +1906,7 @@
     "pandora"
     "pantheon"
     "paperspace"
+    "paramountplus"
     "paritysubstrate"
     "parsedotly"
     "passport"
@@ -2137,6 +2153,7 @@
     "razorpay"
     "react"
     "reacthookform"
+    "reactiveresume"
     "reactivex"
     "reactos"
     "reactquery"
@@ -2387,6 +2404,7 @@
     "socketdotio"
     "softpedia"
     "sogou"
+    "solana"
     "solid"
     "solidity"
     "sololearn"
@@ -2423,6 +2441,7 @@
     "speedypage"
     "sphinx"
     "spigotmc"
+    "spine"
     "spinnaker"
     "spinrilla"
     "splunk"
@@ -2606,6 +2625,7 @@
     "thurgauerkantonalbank"
     "thymeleaf"
     "ticketmaster"
+    "ticktick"
     "tidal"
     "tiddlywiki"
     "tide"
diff --git a/style/subfigure.el b/style/subfigure.el
index 181b17c0..55c9c851 100644
--- a/style/subfigure.el
+++ b/style/subfigure.el
@@ -1,6 +1,6 @@
 ;;; subfigure.el --- AUCTeX style file for subfigure.sty  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2003, 2005, 2013, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2003--2024 Free Software Foundation, Inc.
 
 ;; Author: Reiner Steib  <Reiner.Steib@gmx.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -55,7 +55,8 @@
    ;; Install completion for labels:
    (setq TeX-complete-list
          (append
-          '(("\\\\[Ss]ubref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}"))
+          '(("\\\\[Ss]ubref{\\([^{}\n\r\\%,]*\\)"
+             1 LaTeX-completion-label-list "}"))
           TeX-complete-list))
 
    ;; Fontification
diff --git a/style/varioref.el b/style/varioref.el
index 32134c1d..82bcaf31 100644
--- a/style/varioref.el
+++ b/style/varioref.el
@@ -1,6 +1,6 @@
 ;;; varioref.el --- AUCTeX style for `varioref.sty' (v1.6b)  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 1999, 2013, 2015, 2018--2020 Free Software Foundation, Inc.
+;; Copyright (C) 1999--2024 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
 ;;         Mads Jensen <mje@inducks.org>
@@ -69,16 +69,12 @@
 
    ;; Install completion for labels.  Only offer completion for
    ;; commands that take only one reference as an argument
-   ;; FIXME: The first 3 entries can be reduced to
-   ;; ("\\\\[Vv]ref\\*?{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")  ???
    (setq TeX-complete-list
          (append
-          '(("\\\\[Vv]ref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-            ("\\\\vref\\*?{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-            ("\\\\vref\\*{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
-            ("\\\\fullref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
+          '(("\\\\[Vv]ref\\*?{\\([^{}\n\r\\%,]*\\)" 1 
LaTeX-completion-label-list "}")
+            ("\\\\fullref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-completion-label-list 
"}")
             ("\\\\vpageref\\*?\\(\\[[^]]*\\]\\)*{\\([^{}\n\r\\%,]*\\)"
-             2 LaTeX-label-list "}"))
+             2 LaTeX-completion-label-list "}"))
           TeX-complete-list))
 
    ;; Fontification
diff --git a/tests/japanese/parse-timing.el b/tests/japanese/parse-timing.el
index 15051bcd..63df7353 100644
--- a/tests/japanese/parse-timing.el
+++ b/tests/japanese/parse-timing.el
@@ -41,8 +41,7 @@
   "Test style hooks are not called too early."
   (let ((TeX-parse-self t)
         (TeX-master t)
-        (LaTeX-mode-hook '(japanese-latex-mode-initialization
-                           turn-on-reftex)))
+        (LaTeX-mode-hook '(turn-on-reftex)))
     (find-file parse-timing)
     (should (memq 'AMSTeX
                   (get reftex-docstruct-symbol
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index 28187b05..eae951f1 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -271,7 +271,7 @@ Test against RequirePackage."
 backend=biber % here is a comment
 ]{biblatex}
 ")
-    (latex-mode)
+    (LaTeX-mode)
     (let ((TeX-parse-self t))
       (TeX-update-style t))
     (should (member "biblatex" (TeX-style-list)))
@@ -387,7 +387,7 @@ backend=biber % here is a comment
       ;;                        (setq TeX-PDF-from-DVI "Dvips"))
       ;;                      :classopt)
       (insert "\\documentclass[dvips]{article}\n")
-      (latex-mode)
+      (LaTeX-mode)
       (TeX-update-style)
       (should (equal (TeX-PDF-from-DVI) "Dvips"))
       (should (not (member "dvips" TeX-active-styles)))
@@ -404,7 +404,7 @@ backend=biber % here is a comment
       ;;                          (setq TeX-PDF-from-DVI "Dvipdfmx")))
       ;;                      :classopt)
       (insert "\\documentclass[dvipdfmx]{article}\n")
-      (latex-mode)
+      (LaTeX-mode)
       (TeX-update-style)
       (should TeX-PDF-mode)
       (should (equal (TeX-PDF-from-DVI) "Dvipdfmx"))
@@ -423,7 +423,7 @@ backend=biber % here is a comment
       ;; This depends on the following code in latex.el:
       ;; (TeX-add-style-hook "pdftricks" #'TeX-PDF-mode-on :classopt)
       (insert "\\documentclass[pdftricks]{article}\n")
-      (latex-mode)
+      (LaTeX-mode)
       (TeX-update-style)
       (should TeX-PDF-mode)
       (should (not (member "pdftricks" TeX-active-styles)))
@@ -433,7 +433,7 @@ backend=biber % here is a comment
       ;; This depends on the following code in latex.el:
       ;; (TeX-add-style-hook "psfrag" #'TeX-PDF-mode-off :classopt)
       (insert "\\documentclass[psfrag]{article}\n")
-      (latex-mode)
+      (LaTeX-mode)
       (TeX-update-style)
       (should (not TeX-PDF-mode))
       (should (not (member "psfrag" TeX-active-styles))))))
@@ -447,7 +447,7 @@ backend=biber % here is a comment
   (with-temp-buffer
     (let ((transient-mark-mode t)
           (LaTeX-insert-into-comments t))
-      (latex-mode)
+      (LaTeX-mode)
       (auto-fill-mode 1)
 
       ;; test 1: for bug#35284
@@ -657,7 +657,7 @@ ghi"))
           ;; already.
           (or orig-mode
               (electric-pair-mode 1))
-          (latex-mode)
+          (LaTeX-mode)
 
           ;; When `LaTeX-insert-left-brace' supplies right brace,
           ;; `electric-pair-mode' shouldn't come into play.
diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index 9834487f..a89a12e9 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -88,7 +88,7 @@
   ;; Skip on w32 because the quoting style of `shell-quote-argument'
   ;; is different.
   (skip-unless (not (eq system-type 'windows-nt)))
-  (let ((major-mode 'latex-mode)
+  (let ((major-mode 'LaTeX-mode)
         (TeX-engine 'default)
         (TeX-command-extra-options " \"\\foo\"")
         TeX-master)
diff --git a/tex-bar.el b/tex-bar.el
index a6804e18..a0bf9311 100644
--- a/tex-bar.el
+++ b/tex-bar.el
@@ -83,7 +83,7 @@ If there is no help, the empty string is returned."
 (defcustom TeX-bar-TeX-buttons
   '(new-file open-file dired kill-buffer save-buffer cut copy paste undo
              separator tex next-error view bibtex spell)
-  "List of buttons available in `tex-mode'.
+  "List of buttons available in `plain-TeX-mode'.
 It should be a list in the same format of the BUTTONS parameter
 in function `toolbarx-install-toolbar', often a symbol that
 labels a button.
@@ -223,7 +223,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 latex next-error view bibtex spell)
-  "List of buttons available in `latex-mode'.
+  "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
 labels a button.
diff --git a/tex-fold.el b/tex-fold.el
index a48e4f84..92304fb2 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -1,11 +1,11 @@
 ;;; tex-fold.el --- Fold TeX macros.  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2023  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2024  Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
 ;; Created: 2004-07-04
-;; Keywords: tex, wp
+;; Keywords: tex, text
 
 ;; This file is part of AUCTeX.
 
@@ -300,7 +300,7 @@ and `TeX-fold-math-spec-list', and environments in 
`TeX-fold-env-spec-list'."
   "Fold all items in region from START to END."
   (interactive "r")
   (when (and (memq 'env TeX-fold-type-list)
-             (not (eq major-mode 'plain-tex-mode)))
+             (not (eq major-mode 'plain-TeX-mode)))
     (TeX-fold-region-macro-or-env start end 'env))
   (when (memq 'macro TeX-fold-type-list)
     (TeX-fold-region-macro-or-env start end 'macro))
@@ -323,11 +323,11 @@ for macros and `math' for math macros."
           (cl-pushnew i item-list :test #'equal)))
       (when item-list
         (setq regexp (cond ((and (eq type 'env)
-                                 (eq major-mode 'context-mode))
+                                 (eq major-mode 'ConTeXt-mode))
                             (concat (regexp-quote TeX-esc)
                                     "start" (regexp-opt item-list t)))
                            ((and (eq type 'env)
-                                 (eq major-mode 'texinfo-mode))
+                                 (eq major-mode 'Texinfo-mode))
                             (concat (regexp-quote TeX-esc)
                                     (regexp-opt item-list t)))
                            ((eq type 'env)
@@ -418,15 +418,15 @@ TYPE specifies the type of item and can be one of the 
symbols
 macros.
 Return non-nil if an item was found and folded, nil otherwise."
   (if (and (eq type 'env)
-           (eq major-mode 'plain-tex-mode))
+           (eq major-mode 'plain-TeX-mode))
       (message
        "Folding of environments is not supported in current mode")
     (let ((item-start (cond ((and (eq type 'env)
-                                  (eq major-mode 'context-mode))
+                                  (eq major-mode 'ConTeXt-mode))
                              (save-excursion
                                (ConTeXt-find-matching-start) (point)))
                             ((and (eq type 'env)
-                                  (eq major-mode 'texinfo-mode))
+                                  (eq major-mode 'Texinfo-mode))
                              (save-excursion
                                (Texinfo-find-env-start) (point)))
                             ((eq type 'env)
@@ -441,11 +441,11 @@ Return non-nil if an item was found and folded, nil 
otherwise."
                             (goto-char item-start)
                             (looking-at
                              (cond ((and (eq type 'env)
-                                         (eq major-mode 'context-mode))
+                                         (eq major-mode 'ConTeXt-mode))
                                     (concat (regexp-quote TeX-esc)
                                             "start\\([A-Za-z]+\\)"))
                                    ((and (eq type 'env)
-                                         (eq major-mode 'texinfo-mode))
+                                         (eq major-mode 'Texinfo-mode))
                                     (concat (regexp-quote TeX-esc)
                                             "\\([A-Za-z]+\\)"))
                                    ((eq type 'env)
@@ -530,12 +530,12 @@ TYPE can be either `env' for environments, `macro' for 
macros or
 `math' for math macros."
   (save-excursion
     (cond ((and (eq type 'env)
-                (eq major-mode 'context-mode))
+                (eq major-mode 'ConTeXt-mode))
            (goto-char start)
            (ConTeXt-find-matching-stop)
            (point))
           ((and (eq type 'env)
-                (eq major-mode 'texinfo-mode))
+                (eq major-mode 'Texinfo-mode))
            (goto-char (1+ start))
            (Texinfo-find-env-end)
            (point))
diff --git a/tex-info.el b/tex-info.el
index 9dc19bed..63242e0d 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -538,13 +538,16 @@ is assumed by default."
     (define-key map "\\" #'self-insert-command)
     ;; Users benefit from `TeX-electric-macro' even in Texinfo mode
     (define-key map "@" #'TeX-insert-backslash)
+
+    ;; Hide "Text" menu entry inherited from text mode.
+    (define-key map [menu-bar text] #'undefined)
     map)
   "Keymap for Texinfo mode.")
 
 (easy-menu-define Texinfo-command-menu
   Texinfo-mode-map
   "Menu used in Texinfo mode for external commands."
-  (TeX-mode-specific-command-menu 'texinfo-mode))
+  (TeX-mode-specific-command-menu 'Texinfo-mode))
 
 (easy-menu-define Texinfo-mode-menu
   Texinfo-mode-map
@@ -622,28 +625,25 @@ is assumed by default."
 
 ;;; Mode:
 
-;;;###autoload
-(defalias 'Texinfo-mode #'texinfo-mode)
+(defvar semantic-symref-filepattern-alist) ; Silence compiler
+(with-eval-after-load 'semantic/symref/grep
+  (push '(Texinfo-mode "*.texinfo" "*.texi" "*.txi")
+        semantic-symref-filepattern-alist))
 
 ;;;###autoload
-(defun TeX-texinfo-mode ()
+(define-derived-mode Texinfo-mode text-mode "Texinfo"
   "Major mode in AUCTeX for editing Texinfo files.
 
-Special commands:
-\\{Texinfo-mode-map}
-
 Entering Texinfo mode calls the value of `text-mode-hook' and then the
 value of `Texinfo-mode-hook'."
-  (interactive)
-  (kill-all-local-variables)
+  :syntax-table texinfo-mode-syntax-table
+  :after-hook (Texinfo-mode-cleanup)
+
   (setq TeX-mode-p t)
   (setq TeX-output-extension (if TeX-PDF-mode "pdf" "dvi"))
   (setq TeX-sentinel-default-function #'TeX-TeX-sentinel)
   ;; Mostly stolen from texinfo.el
-  (setq TeX-base-mode-name "Texinfo")
-  (setq major-mode 'texinfo-mode)
-  (use-local-map Texinfo-mode-map)
-  (set-syntax-table texinfo-mode-syntax-table)
+  (setq TeX-base-mode-name mode-name)
 
   ;; Moved after `run-mode-hooks'. (bug#65750)
   ;; (set (make-local-variable 'page-delimiter)
@@ -859,10 +859,11 @@ value of `Texinfo-mode-hook'."
   ;; RefTeX plugging
   (add-hook 'reftex-mode-hook #'Texinfo-reftex-hook nil t)
   (if (and (boundp 'reftex-mode) reftex-mode)
-      (Texinfo-reftex-hook))
-
-  (run-mode-hooks 'text-mode-hook 'Texinfo-mode-hook)
+      (Texinfo-reftex-hook)))
 
+(defun Texinfo-mode-cleanup ()
+  "Cleanup function for `Texinfo-mode'.
+Run after mode hooks and file local variables application."
   ;; Don't overwrite the value the user set by hooks or file
   ;; (directory) variables.
   (or (local-variable-p 'page-delimiter)
diff --git a/tex-ispell.el b/tex-ispell.el
index 3719615b..73ff5c9e 100644
--- a/tex-ispell.el
+++ b/tex-ispell.el
@@ -1,10 +1,10 @@
 ;;; tex-ispell.el --- AUCTeX skip additions for Ispell  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2016-2023 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2024 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <arash@gnu.org>
 ;; Maintainer: auctex-devel@gnu.org
-;; Keywords: tex, wp, convenience
+;; Keywords: tex, text, convenience
 
 ;; 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
@@ -177,6 +177,11 @@
       ("LUseVerbatim" . 1)
       ("LUseVerbatim*" . 1)
       ("VerbatimInput" . 1)
+      ("VerbatimInput*" . 1)
+      ("BVerbatimInput" . 1)
+      ("BVerbatimInput*" . 1)
+      ("LVerbatimInput" . 1)
+      ("LVerbatimInput*" . 1)
       ;; fontaxes.sty
       ("figureversion" . 1)
       ;; fontspec.sty
diff --git a/tex-jp.el b/tex-jp.el
index 867f3f6a..cdb62d97 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -85,7 +85,6 @@ systems are determined by their values regardless of the 
kanji option."
 ;; Define before first use.
 (defvar-local japanese-TeX-mode nil
   "Non-nil means the current buffer handles Japanese TeX/LaTeX.")
-(put 'japanese-TeX-mode 'permanent-local t)
 
 (setq TeX-expand-list-builtin
       (append
@@ -277,8 +276,8 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
   (with-current-buffer TeX-command-buffer
     (when japanese-TeX-mode
       ;; TeX-engine が ptex, jtex, uptex のいずれかである場合のみ考え
-      ;; る。luatex-ja などの場合はそもそもただの latex-mode でよく、
-      ;; わざわざ japanese-latex-mode にする必要がない。
+      ;; る。luatex-ja などの場合はそもそもただの LaTeX-mode でよく、
+      ;; わざわざ japanese-LaTeX-mode にする必要がない。
 
       ;; FIXME: 以下の処理は tex engine を対象とする場合しか考えていない。
       ;; bibtex や mendex 等の補助ツールの場合は正しくない処理かもしれない。
@@ -407,92 +406,81 @@ For inappropriate encoding, nil instead."
 ;;; Japanese TeX modes
 
 ;;;###autoload
-(defun japanese-plain-tex-mode ()
-  "Major mode in AUCTeX for editing Japanese plain TeX files.
-Set `japanese-TeX-mode' to t, and enter `TeX-plain-tex-mode'."
-  (interactive)
+(define-derived-mode japanese-plain-TeX-mode plain-TeX-mode "TeX"
+  "Major mode in AUCTeX for editing Japanese plain TeX files."
+  :syntax-table nil
+  ;; See the comments below in `japanese-LaTeX-mode' for the intent of
+  ;; the following line.
+  :after-hook (setq major-mode 'plain-TeX-mode)
+
   (setq japanese-TeX-mode t)
-  (TeX-plain-tex-mode))
+
+  (TeX-engine-set japanese-TeX-engine-default))
 
 (defun japanese-plain-tex-mode-initialization ()
-  "Japanese plain-TeX specific initializations."
-  (when japanese-TeX-mode
-    (TeX-engine-set japanese-TeX-engine-default)
+  (message "\
+Now `japanese-plain-tex-mode-initialization' is no-op.  Don't use it."))
 
-    ;; For the intent of the following lines, see the comments below
-    ;; in `japanese-latex-mode-initialization'.
-    (when enable-local-variables
-      (setq major-mode 'japanese-plain-tex-mode)
-      (add-hook 'hack-local-variables-hook #'japanese-TeX-reset-mode-name
-                nil t))))
+;;;###autoload
+(defalias 'japanese-plain-tex-mode #'japanese-plain-TeX-mode)
 
-(add-hook 'plain-TeX-mode-hook #'japanese-plain-tex-mode-initialization)
+;; Compatibility for former mode name.  Directory local variables
+;; prepared for `japanese-plain-tex-mode' and `plain-tex-mode'
+;; continue to be valid for `japanese-plain-TeX-mode'.
+(TeX-derived-mode-add-parents 'japanese-plain-TeX-mode
+                              '(japanese-plain-tex-mode plain-tex-mode))
 
 ;;;###autoload
-(defun japanese-latex-mode ()
-  "Major mode in AUCTeX for editing Japanese LaTeX files.
-Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'."
-  (interactive)
+(define-derived-mode japanese-LaTeX-mode LaTeX-mode "LaTeX"
+  "Major mode in AUCTeX for editing Japanese LaTeX files."
+  :syntax-table nil
+  ;; The value of `major-mode' should be `LaTeX-mode', not
+  ;; `japanese-LaTeX-mode', because the name `LaTeX-mode' is hard
+  ;; coded in several places of AUCTeX like
+  ;;   (eq major-mode 'LaTeX-mode),
+  ;;   (memq major-mode '(docTeX-mode LaTeX-mode)
+  ;; and so on.  By such piece of codes, `japanese-LaTeX-mode' should
+  ;; simply be regarded as `LaTeX-mode'.  However, if we change
+  ;; `major-mode' to `LaTeX-mode' here in the mode body,
+  ;; `hack-local-variables' does not apply the directory local
+  ;; variables prepared for `japanese-LaTeX-mode'.
+  ;; Thus we change `major-mode' to `LaTeX-mode' after
+  ;; `hack-local-variables' is done.
+  :after-hook (setq major-mode 'LaTeX-mode)
+
   (setq japanese-TeX-mode t)
-  (TeX-latex-mode))
+
+  ;; `TeX-match-style' を使うのは `TeX-update-style' の後に遅らせる。
+  ;; この段階で使うと、その中で呼ぶ `TeX-style-list' の中で
+  ;; `TeX-update-style' が呼ばれてしまい、local variable 等の準備が整っ
+  ;; てない段階で style hook が実行されて不適な結果になることがある。
+  ;; また、`TeX-update-style' は後から `find-file-hook' 中でもう一度呼
+  ;; ばれるので、`TeX-parse-self' が t だと parse 処理も無駄に 2 回行
+  ;; われてしまう。
+  (add-hook 'TeX-update-style-hook
+            #'japanese-LaTeX-guess-engine nil t)
+  (setq-local LaTeX-default-style japanese-LaTeX-default-style)
+
+  (when (and (fboundp 'font-latex-add-keywords)
+             (eq TeX-install-font-lock 'font-latex-setup))
+    ;; jLaTeX にはないコマンドだが、それはもう気にしなくていいだろう。
+    (font-latex-add-keywords '(("textgt" "{") ("mathgt" "{"))
+                             'bold-command)
+    (font-latex-add-keywords '("gtfamily")
+                             'bold-declaration)))
 
 (defun japanese-latex-mode-initialization ()
-  "Japanese LaTeX specific initializations."
-  (when japanese-TeX-mode
-    ;; `TeX-match-style' を使うのは `TeX-update-style' の後に遅らせる。
-    ;; この段階で使うと、その中で呼ぶ `TeX-style-list' の中で
-    ;; `TeX-update-style' が呼ばれてしまい、local variable 等の準備が
-    ;; 整ってない段階で style hook が実行されて不適な結果になることが
-    ;; ある。また、`TeX-update-style' は後から `find-file-hook' 中でも
-    ;; う一度呼ばれるので、`TeX-parse-self' が t だと parse 処理も無駄
-    ;; に 2 回行われてしまう。
-    (add-hook 'TeX-update-style-hook
-              #'japanese-LaTeX-guess-engine nil t)
-    (setq-local LaTeX-default-style japanese-LaTeX-default-style)
-
-    (when (and (fboundp 'font-latex-add-keywords)
-               (eq TeX-install-font-lock 'font-latex-setup))
-      ;; jLaTeX にはないコマンドだが、それはもう気にしなくていいだろう。
-      (font-latex-add-keywords '(("textgt" "{") ("mathgt" "{"))
-                               'bold-command)
-      (font-latex-add-keywords '("gtfamily")
-                               'bold-declaration))
-
-    ;; The value of `major-mode' should be `latex-mode', not
-    ;; `japanese-latex-mode', because the name `latex-mode' is hard
-    ;; coded in several places of AUCTeX like "(eq major-mode
-    ;; 'latex-mode)", "(memq major-mode '(doctex-mode latex-mode)" and
-    ;; so on.  By such piece of codes, `japanese-latex-mode' should
-    ;; simply be regarded as `latex-mode'.  So we'd like to leave
-    ;; `major-mode' as `latex-mode' here, but doing so confuses
-    ;; `hack-local-variables' in two ways.
-    ;; (1) It is tricked into considering that the major mode is not
-    ;;     yet initialized and calls `japanese-latex-mode' again.
-    ;; (2) It does not read the directory local variables prepared for
-    ;;     `japanese-latex-mode'.
-    ;; Thus we temporarily set `major-mode' to `japanese-latex-mode'
-    ;; here and plan to reset it to `latex-mode' after
-    ;; `hack-local-variables' is done.
-    (when enable-local-variables
-      (setq major-mode 'japanese-latex-mode)
-      (add-hook 'hack-local-variables-hook #'japanese-TeX-reset-mode-name
-                nil t))))
-
-(add-hook 'LaTeX-mode-hook #'japanese-latex-mode-initialization)
-
-;; This function is useful only within `hack-local-variables-hook'.
-(defun japanese-TeX-reset-mode-name ()
-  (cond ((eq major-mode 'japanese-latex-mode)
-         (setq major-mode 'latex-mode))
-        ((eq major-mode 'japanese-plain-tex-mode)
-         (setq major-mode 'plain-tex-mode)))
-  (remove-hook 'hack-local-variables-hook #'japanese-TeX-reset-mode-name t))
-
-;; Make `hack-dir-local-variables' to regard `latex-mode' as parent
-;; of `japanese-latex-mode', and `plain-tex-mode' as parent of
-;; `japanese-plain-tex-mode'.
-(put 'japanese-plain-tex-mode 'derived-mode-parent 'plain-tex-mode)
-(put 'japanese-latex-mode 'derived-mode-parent 'latex-mode)
+  (message "\
+Now `japanese-latex-mode-initialization' is no-op.  Don't use it."))
+
+;;;###autoload
+(defalias 'japanese-latex-mode #'japanese-LaTeX-mode)
+
+;; Compatibility for former mode name.  Directory local variables
+;; prepared for `japanese-latex-mode' and `latex-mode' continue to be
+;; valid for `japanese-LaTeX-mode'.
+(TeX-derived-mode-add-parents 'japanese-LaTeX-mode
+                              '(japanese-latex-mode latex-mode))
 
 (defun japanese-LaTeX-guess-engine ()
   "Guess Japanese TeX engine and set it to `TeX-engine'.
@@ -535,7 +523,9 @@ overwrite the value already set locally."
   (if (TeX-looking-at-backward "\\\\/\\(}+\\)" 50)
       (replace-match "\\1" t))
   (call-interactively #'japanese-TeX-self-insert-command))
-(advice-add 'TeX-insert-punctuation :override
+(define-key japanese-plain-TeX-mode-map [remap TeX-insert-punctuation]
+            #'japanese-TeX-insert-punctuation)
+(define-key japanese-LaTeX-mode-map [remap TeX-insert-punctuation]
             #'japanese-TeX-insert-punctuation)
 
 ;;; Error Messages
diff --git a/tex-site.el.in b/tex-site.el.in
index 0b585253..4bd14ce1 100644
--- a/tex-site.el.in
+++ b/tex-site.el.in
@@ -1,6 +1,6 @@
 ;;; tex-site.el - Site specific variables.  Don't edit.  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2005-2023  Free Software Foundation, Inc.
+;; Copyright (C) 2005-2024  Free Software Foundation, Inc.
 ;;
 ;; completely rewritten.
 
@@ -38,8 +38,8 @@
 
 ;;; Code:
 
-(when (< emacs-major-version 26)
-  (error "AUCTeX requires Emacs 26.1 or later"))
+(when (< emacs-major-version 27)
+  (error "AUCTeX requires Emacs 27.1 or later"))
 
 (declare-function BibTeX-auto-store "latex")
 
@@ -48,6 +48,7 @@
   ;; Try and support the case where someone loads tex-site.el or
   ;; auctex.el directly, in the old way.
   (provide 'tex-site)        ;Avoid (re)loading tex-site from auctex-autoloads.
+
   (load "auctex-autoloads" 'noerror 'nomessage))
 
 ;; Define here in order for `M-x customize-group <RET> AUCTeX <RET>'
@@ -84,17 +85,23 @@ shared by all users of a site."
   :type 'directory)
 
 (defconst TeX-mode-alist
-  '((tex-mode . tex-mode)
-    (plain-tex-mode . tex-mode)
-    (texinfo-mode . texinfo)
-    (latex-mode . tex-mode)
-    (doctex-mode . tex-mode))
-  "Alist of built-in TeX modes and their load files.")
+  '((tex-mode . TeX-tex-mode)
+    (plain-tex-mode . plain-TeX-mode)
+    (texinfo-mode . Texinfo-mode)
+    (latex-mode . LaTeX-mode)
+    (doctex-mode . docTeX-mode))
+  "Alist of built-in TeX modes and their counterparts in AUCTeX.")
 
 (defalias 'TeX-load-hack #'ignore)
 
 (defun tex-site-unload-function ()
   (TeX-modes-set 'TeX-modes nil)
+
+  ;; COMPATIBILITY for Emacs<29
+  (put 'plain-TeX-mode 'auctex-function-definition nil)
+  (put 'LaTeX-mode 'auctex-function-definition nil)
+  (put 'TeX-mode 'auctex-function-definition nil)
+
   (setq load-path (delq TeX-lisp-directory load-path))
   ;; Tell emacs to continue standard unloading procedure.
   nil)
@@ -102,25 +109,37 @@ shared by all users of a site."
 (defun TeX-modes-set (var value &optional _ignored)
   "Set VAR (which should be `TeX-modes') to VALUE.
 
-This places either the standard or the AUCTeX versions of
-functions into the respective function cell of the mode."
+Arrange the redirection of the built-in TeX modes according to VALUE.
+- The built-in modes in VALUE are redirected to the corresponding
+  AUCTeX major modes.
+- The built-in modes not in VALUE discard redirection, if any.
+If `major-mode-remap-alist' is available, use it for redirection.
+Otherwise, use advice facility."
   (custom-set-default var value)
-  (let ((list TeX-mode-alist) elt)
-    (while list
-      (setq elt (car (pop list)))
-      (let ((dst (intern (concat "TeX-" (symbol-name elt)))))
-        (if (memq elt value)
+  (let (elt dst)
+    (dolist (entry TeX-mode-alist)
+      (setq elt (car entry)
+            dst (cdr entry))
+      (if (memq elt value)
+          (if (boundp 'major-mode-remap-alist)
+              (or (eq (cdr-safe (assq elt major-mode-remap-alist)) dst)
+                  (push (cons elt dst) major-mode-remap-alist))
+            ;; COMPATIBILITY for Emacs<29
             (advice-add elt :override dst
                         ;; COMPATIBILITY for Emacs 28.[12]
                         ;; Give it higher precedence than the :around
                         ;; advice given to `tex-mode' in tex-mode.el.
                         ;; 
<URL:https://lists.gnu.org/r/auctex-devel/2022-09/msg00050.html>
-                        '((depth . -10)))
+                        '((depth . -10))))
+        (if (boundp 'major-mode-remap-alist)
+            (setq major-mode-remap-alist
+                  (delete entry major-mode-remap-alist))
+          ;; COMPATIBILITY for Emacs<29
           (advice-remove elt dst))))))
 
 (defcustom TeX-modes
   (mapcar #'car TeX-mode-alist)
-  "List of modes provided by AUCTeX.
+  "List of built-in TeX modes redirected to AUCTeX modes.
 
 This variable can't be set normally; use customize for that, or
 set it with `TeX-modes-set'."
@@ -129,6 +148,30 @@ set it with `TeX-modes-set'."
   :set #'TeX-modes-set
   :initialize #'custom-initialize-reset)
 
+(defun TeX--alias-overlapped-modes (&optional restore)
+  "Delete or restore definition of overlapped modes via `defalias'.
+Set function definition for modes overlapped between tex-mode.el
+and AUCTeX, `plain-TeX-mode', `LaTeX-mode' and `TeX-mode'.
+If optional argument RESTORE is nil, delete the definition.
+Otherwise, restore AUCTeX definition saved in the symbol property
+`auctex-function-definition'."
+  (dolist (mode '(plain-TeX-mode LaTeX-mode TeX-mode))
+    (if (eq (symbol-function mode)
+            (intern (downcase (symbol-name mode))))
+        (defalias mode (if restore
+                           (get mode 'auctex-function-definition))))))
+
+;; Delete aliases predefined in tex-mode.el so that AUCTeX
+;; autoloads provided below take precedence.
+(TeX--alias-overlapped-modes)
+
+;; COMPATIBILITY for Emacs<29, which executes
+;; (defalias 'LaTeX-mode #'latex-mode) etc. in tex-mode.el.
+(with-eval-after-load 'tex-mode
+  ;; This must be no-op after (unload-feature 'tex-site).
+  (if (featurep 'tex-site)
+      (TeX--alias-overlapped-modes t)))
+
 (defconst AUCTeX-version "@AUCTEXVERSION@"
   "AUCTeX version.
 If not a regular release, the date of the last change.")
diff --git a/tex-style.el b/tex-style.el
index 6fdeceed..f546df96 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -1,9 +1,9 @@
 ;;; tex-style.el --- Customizable variables for AUCTeX style files  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2005-2023  Free Software Foundation, Inc.
+;; Copyright (C) 2005-2024  Free Software Foundation, Inc.
 
 ;; Author: Reiner Steib <Reiner.Steib@gmx.de>
-;; Keywords: tex, wp, convenience
+;; Keywords: tex, text, convenience
 
 ;; 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
@@ -303,8 +303,8 @@ becomes the default value meaning that verbatim 
fontification is
 always performed for the characters in the list, no matter if
 your document actually defines shortverb chars using
 \\DefineShortVerb."
-  :type '(repeat character))
-(put 'LaTeX-fancyvrb-chars 'safe-local-variable #'listp)
+  :type '(repeat character)
+  :safe #'listp)
 
 ;; style/fontspec.el
 
@@ -420,8 +420,8 @@ becomes the default value meaning that verbatim 
fontification is
 always performed for the characters in the list, no matter if
 your document actually defines shortvrb chars using
 \\MakeShortVrb."
-  :type '(repeat character))
-(put 'LaTeX-shortvrb-chars 'safe-local-variable #'listp)
+  :type '(repeat character)
+  :safe #'listp)
 
 ;; style/splitidx.el
 
diff --git a/tex-wizard.el b/tex-wizard.el
index 1597e270..8c8ba819 100644
--- a/tex-wizard.el
+++ b/tex-wizard.el
@@ -1,9 +1,9 @@
 ;;; tex-wizard.el --- Check the TeX configuration  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2003-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2024 Free Software Foundation, Inc.
 
 ;; Author: David Kastrup <dak@gnu.org>
-;; Keywords: tex, wp, convenience
+;; Keywords: tex, text, convenience
 
 ;; 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
diff --git a/tex.el b/tex.el
index afa02e5e..eeb7237c 100644
--- a/tex.el
+++ b/tex.el
@@ -28,8 +28,8 @@
 
 ;;; Code:
 
-(when (< emacs-major-version 26)
-  (error "AUCTeX requires Emacs 26.1 or later"))
+(when (< emacs-major-version 27)
+  (error "AUCTeX requires Emacs 27.1 or later"))
 
 (require 'custom)
 (require 'tex-site)
@@ -56,6 +56,8 @@
                   (bus service path interface signal handler &rest args))
 (declare-function LaTeX-environment-list "latex" nil)
 (declare-function LaTeX-bibliography-list "latex" nil)
+(declare-function LaTeX-completion-label-annotation-function "latex" (label))
+(declare-function LaTeX-completion-label-list "latex" nil)
 (declare-function LaTeX-section-name "latex" (level))
 (declare-function comint-exec "ext:comint"
                   (buffer name command startfile switches))
@@ -183,73 +185,73 @@ If nil, none is specified."
 (defcustom TeX-command-list
   '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) 
%S%(PDFout)%(mode)%' %(output-dir) %t"
      TeX-run-TeX nil
-     (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX")
+     (plain-TeX-mode AmSTeX-mode Texinfo-mode) :help "Run plain TeX")
     ("LaTeX" "%`%l%(mode)%' %T"
      TeX-run-TeX nil
-     (latex-mode doctex-mode) :help "Run LaTeX")
+     (LaTeX-mode docTeX-mode) :help "Run LaTeX")
     ;; Not part of standard TeX.
     ("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil
-     (texinfo-mode) :help "Run Makeinfo with Info output")
+     (Texinfo-mode) :help "Run Makeinfo with Info output")
     ("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" 
TeX-run-compile nil
-     (texinfo-mode) :help "Run Makeinfo with HTML output")
+     (Texinfo-mode) :help "Run Makeinfo with HTML output")
     ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t"
-     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
+     TeX-run-TeX nil (AmSTeX-mode) :help "Run AMSTeX")
     ;; support for ConTeXt  --pg
     ;; first version of ConTeXt to support nonstopmode: 2003.2.10
     ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t"
-     TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
+     TeX-run-TeX nil (ConTeXt-mode) :help "Run ConTeXt once")
     ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
      TeX-run-TeX nil
-     (context-mode) :help "Run ConTeXt until completion")
+     (ConTeXt-mode) :help "Run ConTeXt until completion")
     ("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode
-                     context-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode
+                     ConTeXt-mode)
      :help "Run BibTeX")
     ("Biber" "biber %(output-dir) %s" TeX-run-Biber nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Run Biber")
     ;; Not part of standard TeX.
     ;; It seems that texindex doesn't support "--output-dir" option.
     ("Texindex" "texindex %s.??" TeX-run-command nil
-     (texinfo-mode) :help "Run Texindex")
+     (Texinfo-mode) :help "Run Texindex")
     ;; TODO:
     ;; 1. Supply "--dvipdf" option if `TeX-PDF-mode' and
     ;;    `TeX-PDF-from-DVI' are non-nil.
     ;; 2. Supply "--build-dir=DIR" option when `TeX-output-dir' is
     ;;    non-nil.
     ("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil
-     (texinfo-mode) :help "Run Texi2dvi or Texi2pdf")
+     (Texinfo-mode) :help "Run Texi2dvi or Texi2pdf")
     ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
     ("Print" "%p" TeX-run-command t t :help "Print the file")
     ("Queue" "%q" TeX-run-background nil t :help "View the printer queue"
      :visible TeX-queue-command)
     ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Generate PostScript file")
     ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Convert DVI file to PostScript")
     ("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Convert DVI file to PDF with dvipdfmx")
     ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Convert PostScript file to PDF")
     ("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Run makeglossaries to create glossary file")
     ("Index" "makeindex %(O?idx)" TeX-run-index nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Run makeindex to create index file")
     ("upMendex" "upmendex %(O?idx)" TeX-run-index t
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Run upmendex to create index file")
     ("Xindy" "texindy %s" TeX-run-command nil
-     (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode)
+     (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode)
      :help "Run xindy to create index file")
-    ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
+    ("Check" "lacheck %s" TeX-run-compile nil (LaTeX-mode)
      :help "Check LaTeX file for correctness")
-    ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode)
+    ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (LaTeX-mode)
      :help "Check LaTeX file for common mistakes")
     ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t
      :help "Spell-check the document")
@@ -346,12 +348,12 @@ Any additional elements get just transferred to the 
respective menu entries."
                         (boolean :tag "Prompt")
                         (choice :tag "Modes"
                                 (const :tag "All" t)
-                                (set (const :tag "Plain TeX" plain-tex-mode)
-                                     (const :tag "LaTeX" latex-mode)
-                                     (const :tag "DocTeX" doctex-mode)
-                                     (const :tag "ConTeXt" context-mode)
-                                     (const :tag "Texinfo" texinfo-mode)
-                                     (const :tag "AmSTeX" ams-tex-mode)))
+                                (set (const :tag "Plain TeX" plain-TeX-mode)
+                                     (const :tag "LaTeX" LaTeX-mode)
+                                     (const :tag "DocTeX" docTeX-mode)
+                                     (const :tag "ConTeXt" ConTeXt-mode)
+                                     (const :tag "Texinfo" Texinfo-mode)
+                                     (const :tag "AmSTeX" AmSTeX-mode)))
                         (repeat :tag "Menu elements" :inline t sexp))))
 
 (defcustom TeX-command-output-list
@@ -511,8 +513,8 @@ string."
 
 (defcustom TeX-command-extra-options ""
   "String with the extra options to be given to the TeX processor."
-  :type 'string)
-(make-variable-buffer-local 'TeX-command-extra-options)
+  :type 'string
+  :local t)
 
 (defvar TeX-command-text nil
   "Dynamically bound by `TeX-command-expand'.")
@@ -545,7 +547,7 @@ string."
                     "pdf"
                   "")))
     ("%(PDFout)" (lambda ()
-                   (cond ((eq major-mode 'ams-tex-mode)
+                   (cond ((eq major-mode 'AmSTeX-mode)
                           (if TeX-PDF-mode
                               " -output-format=pdf"
                             " -output-format=dvi"))
@@ -709,6 +711,13 @@ commands."
   :group 'TeX-command
   :type 'boolean)
 
+(defcustom TeX-LaTeX-sentinel-banner-regexp
+  "^\\(\\*\\* \\)?J?I?p?\\(La\\|Sli\\)TeX\\(2e\\)? \
+\\(Version\\|ver\\.\\|<[0-9/-]*\\(?:u[^>]*\\)?>\\)"
+  "Regexp to identify the banner line in the LaTeX output."
+  :group 'TeX-output
+  :type 'regexp)
+
 ;;; Portability.
 
 (defmacro TeX--if-macro-fboundp (name then &rest else)
@@ -990,12 +999,12 @@ If RESET is non-nil, `TeX-command-next' is reset to
 (defun TeX-mode-prefix (&optional mode)
   "Return the prefix for the symbol MODE as string.
 If no mode is given the current major mode is used."
-  (cdr (assoc (or mode major-mode) '((plain-tex-mode . "plain-TeX")
-                                     (latex-mode . "LaTeX")
-                                     (ams-tex-mode . "AmSTeX")
-                                     (doctex-mode . "docTeX")
-                                     (texinfo-mode . "Texinfo")
-                                     (context-mode . "ConTeXt")))))
+  (cdr (assoc (or mode major-mode) '((plain-TeX-mode . "plain-TeX")
+                                     (LaTeX-mode . "LaTeX")
+                                     (AmSTeX-mode . "AmSTeX")
+                                     (docTeX-mode . "docTeX")
+                                     (Texinfo-mode . "Texinfo")
+                                     (ConTeXt-mode . "ConTeXt")))))
 
 ;;; Viewing
 
@@ -1578,10 +1587,9 @@ It should be one of the following symbols:\n\n"
   :group 'TeX-command
   :type `(choice ,@(mapcar (lambda (x)
                              `(const :tag ,(nth 1 x) ,(car x)))
-                           (TeX-engine-alist))))
-(make-variable-buffer-local 'TeX-engine)
-(put 'TeX-engine 'safe-local-variable
-     (lambda (arg) (memq arg (mapcar #'car TeX-engine-alist-builtin))))
+                           (TeX-engine-alist)))
+  :safe (lambda (arg) (memq arg (mapcar #'car TeX-engine-alist-builtin)))
+  :local t)
 
 (defun TeX-engine-set (type)
   "Set TeX engine to TYPE.
@@ -1746,6 +1754,7 @@ If this is nil, an empty string will be returned."
 (defvar TeX-source-correlate-map (make-sparse-keymap)
   "Keymap for `TeX-source-correlate-mode'.
 You could use this for unusual mouse bindings.")
+(set-keymap-parent TeX-source-correlate-map text-mode-map)
 
 (defun TeX-source-correlate-handle-TeX-region (file line col)
   "Translate backward search info with respect to `TeX-region'.
@@ -1846,13 +1855,14 @@ SyncTeX are recognized."
   :group 'TeX-view
   ;; Since this is a global minor mode and we don't want to require
   ;; tex.el when the mode variable is set, the mode function is called
-  ;; explicitly (if necessary) in `VirTeX-common-initialization'.  We
-  ;; do it there because otherwise `kill-all-local-variables' would
-  ;; reset `TeX-source-correlate-output-page-function' which is
+  ;; explicitly (if necessary) in `TeX-mode'.  We do it there because
+  ;; otherwise `kill-all-local-variables' would reset
+  ;; `TeX-source-correlate-output-page-function' which is
   ;; buffer-local.
   :global t
-  (set-keymap-parent TeX-mode-map (and TeX-source-correlate-mode
-                                       TeX-source-correlate-map))
+  (set-keymap-parent TeX-mode-map (if TeX-source-correlate-mode
+                                      TeX-source-correlate-map
+                                    text-mode-map))
   (TeX-set-mode-name 'TeX-source-correlate-mode t t)
   (setq TeX-source-correlate-start-server-flag TeX-source-correlate-mode)
   ;; Register Emacs for the SyncSource DBUS signal emitted by
@@ -2008,8 +2018,8 @@ enabled and the `synctex' binary is available."
 (defcustom TeX-PDF-mode t nil
   :group 'TeX-command
   :set #'TeX-mode-set
-  :type 'boolean)
-(put 'TeX-PDF-mode 'safe-local-variable #'booleanp)
+  :type 'boolean
+  :safe #'booleanp)
 
 (define-minor-mode TeX-PDF-mode
   "Minor mode for using PDFTeX.
@@ -2094,17 +2104,17 @@ Programs should not use this variable directly but the 
function
           (const :tag "No DVI to PDF conversion" nil)
           (const :tag "dvips - ps2pdf sequence" "Dvips")
           (const :tag "dvipdfmx" "Dvipdfmx"))
-  :safe #'string-or-null-p)
-;; If you plan to support new values of `TeX-PDF-from-DVI' remember to update
-;; `TeX-command-default' accordingly.
-(make-variable-buffer-local 'TeX-PDF-from-DVI)
+  :safe #'string-or-null-p
+  ;; If you plan to support new values of `TeX-PDF-from-DVI' remember
+  ;; to update `TeX-command-default' accordingly.
+  :local t)
 
 (defcustom TeX-PDF-via-dvips-ps2pdf nil
   "Whether to produce PDF output through the (La)TeX - dvips - ps2pdf 
sequence."
   :group 'TeX-command
-  :type 'boolean)
-(make-variable-buffer-local 'TeX-PDF-via-dvips-ps2pdf)
-(put 'TeX-PDF-via-dvips-ps2pdf 'safe-local-variable #'booleanp)
+  :type 'boolean
+  :safe #'booleanp
+  :local t)
 (make-obsolete-variable 'TeX-PDF-via-dvips-ps2pdf 'TeX-PDF-from-DVI "11.90")
 
 (defun TeX-PDF-from-DVI ()
@@ -2135,21 +2145,21 @@ for backward compatibility."
 (defcustom TeX-command-BibTeX "BibTeX"
   "The name of the BibTeX entry in `TeX-command-list'."
   :group 'TeX-command-name
-  :type 'string)
-  (make-variable-buffer-local 'TeX-command-BibTeX)
+  :type 'string
+  :local t)
 
 (defcustom TeX-command-Biber "Biber"
   "The name of the Biber entry in `TeX-command-list'."
   :group 'TeX-command-name
-  :type 'string)
-  (make-variable-buffer-local 'TeX-command-Biber)
+  :type 'string
+  :local t)
 
 (defcustom TeX-command-Show "View"
   "The default command to show (view or print) a TeX file.
 Must be the car of an entry in `TeX-command-list'."
   :group 'TeX-command-name
-  :type 'string)
-  (make-variable-buffer-local 'TeX-command-Show)
+  :type 'string
+  :local t)
 
 (defcustom TeX-command-Print "Print"
   "The name of the Print entry in `TeX-command-Print'."
@@ -2267,12 +2277,11 @@ It is suggested that you use the File Variables (see 
the info node
                  (const :tag "This file" t)
                  (const :tag "Shared" shared)
                  (const :tag "Dwim" dwim)
-                 (string :format "%v")))
-(make-variable-buffer-local 'TeX-master)
-(put 'TeX-master 'safe-local-variable
-     (lambda (x)
-       (or (stringp x)
-           (member x (quote (t nil shared dwim))))))
+                 (string :format "%v"))
+  :safe (lambda (x)
+          (or (stringp x)
+              (member x (quote (t nil shared dwim)))))
+  :local t)
 
 (defcustom TeX-one-master "\\.\\(texi?\\|dtx\\)$"
   "Regular expression matching ordinary TeX files.
@@ -2455,14 +2464,14 @@ Get `major-mode' from master file and enable it."
                             (TeX-master-file TeX-default-extension))
                          major-mode)
                      major-mode))
-             (comment-prefix (cond ((eq mode 'texinfo-mode) "@c ")
-                                   ((eq mode 'doctex-mode) "% ")
+             (comment-prefix (cond ((eq mode 'Texinfo-mode) "@c ")
+                                   ((eq mode 'docTeX-mode) "% ")
                                    (t "%%% ")))
              (mode-string (concat (and (boundp 'japanese-TeX-mode) 
japanese-TeX-mode
                                        "japanese-")
                                   (substring (symbol-name mode) 0 -5))))
         (newline)
-        (when (eq major-mode 'doctex-mode)
+        (when (eq major-mode 'docTeX-mode)
           (insert comment-prefix TeX-esc "endinput\n"))
         (insert
          comment-prefix "Local Variables:\n"
@@ -2510,8 +2519,8 @@ is assumed to be the same as the directory of 
`TeX-master'."
   :group 'TeX-file
   :safe #'string-or-null-p
   :type '(choice (const :tag "Directory of master file" nil)
-                 (string :tag "Custom" "build")))
-(make-variable-buffer-local 'TeX-output-dir)
+                 (string :tag "Custom" "build"))
+  :local t)
 
 (defun TeX--master-output-dir (master-dir relative-to-master &optional ensure)
   "Return the directory path where output files should be placed.
@@ -3227,10 +3236,14 @@ See `completion-at-point-functions'."
                  (begin (match-beginning sub))
                  (end (match-end sub))
                  (symbol (buffer-substring-no-properties begin end))
-                 (list (funcall (nth 2 entry))))
+                 (func (nth 2 entry))
+                 (list (funcall func)))
             (list begin end (all-completions symbol list)
                   :annotation-function
-                  #'TeX--completion-annotation-function))
+                  (cond ((eq func #'LaTeX-completion-label-list)
+                         #'LaTeX-completion-label-annotation-function)
+                        (t
+                         #'TeX--completion-annotation-function))))
         ;; We intentionally don't call the fallback completion functions 
because
         ;; they do completion on their own and don't work too well with things
         ;; like company-mode.  And the default function `ispell-complete-word'
@@ -3240,9 +3253,8 @@ See `completion-at-point-functions'."
 (defcustom TeX-default-macro "ref"
   "The default macro when creating new ones with `TeX-insert-macro'."
   :group 'TeX-macro
-  :type 'string)
-
-(make-variable-buffer-local 'TeX-default-macro)
+  :type 'string
+  :local t)
 
 (defcustom TeX-insert-braces t
   "If non-nil, append an empty pair of braces after inserting a macro.
@@ -3263,8 +3275,8 @@ will use its value to decide what to do, whatever the 
value of
 the variable `TeX-insert-braces'."
   :group 'TeX-macro
   :type '(repeat (cons (string :tag "Macro name")
-                       (boolean :tag "Append braces?"))))
-(make-variable-buffer-local 'TeX-insert-braces-alist)
+                       (boolean :tag "Append braces?")))
+  :local t)
 
 (defcustom TeX-insert-macro-default-style 'show-optional-args
   "Specifies whether `TeX-insert-macro' will ask for all optional arguments.
@@ -3636,41 +3648,41 @@ Choose `ignore' if you don't want AUCTeX to install 
support for font locking."
 ;;; The Mode
 
 (defvar TeX-format-list
-  '(("JLATEX" japanese-latex-mode
+  '(("JLATEX" japanese-LaTeX-mode
      "\\\\\\(documentstyle\\|documentclass\\)[^%\n]*{u?\\(j[s-]?\\|t\\)\
 \\(article\\|report\\|book\\|slides\\)")
-    ("JTEX" japanese-plain-tex-mode
+    ("JTEX" japanese-plain-TeX-mode
      "-- string likely in Japanese TeX --")
-    ("AMSTEX" ams-tex-mode
+    ("AMSTEX" AmSTeX-mode
      "\\\\document\\b")
-    ("CONTEXT" context-mode
+    ("CONTEXT" ConTeXt-mode
      "\\\\\\(start\\(text\\|tekst\\|proje[ck]t\\|proiect\\|\
 produ[ck]t\\|produs\\|environment\\|omgeving\\|umgebung\\|prostredi\\|mediu\\|\
 component\\|onderdeel\\|komponent[ea]\\|componenta\\)\
 \\|inizia\\(testo\\|progetto\\|prodotto\\|ambiente\\|componente\\)\
 \\)\\|%.*?interface=")
-    ("LATEX" latex-mode
+    ("LATEX" LaTeX-mode
      "\\\\\\(begin\\|\\(?:sub\\)\\{0,2\\}section\\|chapter\\|documentstyle\\|\
 documentclass\\)\\b")
-    ("TEX" plain-tex-mode "."))
+    ("TEX" plain-TeX-mode "."))
   "List of format packages to consider when choosing a TeX mode.
 
 A list with an entry for each format package available at the site.
 
 Each entry is a list with three elements.
 
-1. The name of the format package.
-2. The name of the major mode.
+1. The name of the format package (as string).
+2. The name of the major mode (as symbol).
 3. A regexp typically matched in the beginning of the file.
 
-When entering `tex-mode', each regexp is tried in turn in order to find
-the major mode to be used.")
+When entering `TeX-tex-mode', each regexp is tried in turn in
+order to find the major mode to be used.")
 
-(defcustom TeX-default-mode #'latex-mode
+(defcustom TeX-default-mode #'LaTeX-mode
   "Mode to enter for a new file when it can't be determined otherwise."
   :group 'TeX-misc
-  :type '(radio (function-item latex-mode)
-                (function-item plain-tex-mode)
+  :type '(radio (function-item LaTeX-mode)
+                (function-item plain-TeX-mode)
                 (function :tag "Other")))
 
 (defcustom TeX-force-default-mode nil
@@ -3680,16 +3692,27 @@ the major mode to be used.")
 
 ;;;###autoload
 (defun TeX-tex-mode ()
-  "Major mode in AUCTeX for editing TeX or LaTeX files.
+  "Call suitable AUCTeX major mode for editing TeX or LaTeX files.
 Tries to guess whether this file is for plain TeX or LaTeX.
 
 The algorithm is as follows:
 
-   1) if the file is empty or `TeX-force-default-mode' is not set to nil,
-      `TeX-default-mode' is chosen
-   2) If \\documentstyle or \\begin{, \\section{, \\part{ or \\chapter{ is
-      found, `latex-mode' is selected.
-   3) Otherwise, use `plain-tex-mode'"
+   1) If the file is empty or `TeX-force-default-mode' is not set to nil,
+      `TeX-default-mode' is chosen.
+   2) If non-commented out content matches with regular expression in
+      `TeX-format-list', use the associated major mode.  For example,
+      if \\documentclass or \\begin{, \\section{, \\part{ or \\chapter{ is
+      found, `LaTeX-mode' is selected.
+   3) Otherwise, use `TeX-default-mode'.
+
+By default, `TeX-format-list' has a fallback entry for
+`plain-TeX-mode', thus non-empty file which didn't match any
+other entries will enter `plain-TeX-mode'."
+  ;; This is a dispatch function meaningful only as target of
+  ;; `auto-mode-alist' and `major-mode-remap-alist'.  Hence we don't
+  ;; use `define-derived-mode'.  Note that it isn't a proper major
+  ;; mode and it actually makes little sense to specify this for
+  ;; "mode:" tag of file local variable.
   (interactive)
 
   (funcall (if (or (equal (buffer-size) 0)
@@ -3722,9 +3745,14 @@ The algorithm is as follows:
                   (memq 'font-latex-verbatim-face face)
                 (eq face 'font-latex-verbatim-face))))))
 
-(defun VirTeX-common-initialization ()
-  "Perform basic initialization."
-  (kill-all-local-variables)
+(define-derived-mode TeX-mode text-mode "TeX"
+  "Base mode for AUCTeX major modes except Texinfo mode.
+
+Not intended for direct use for user."
+  :abbrev-table nil
+  :after-hook (TeX-mode-cleanup)
+  :interactive nil
+
   (setq TeX-mode-p t)
   (setq TeX-output-extension (if TeX-PDF-mode "pdf" "dvi"))
   (setq indent-tabs-mode nil)
@@ -3762,24 +3790,6 @@ The algorithm is as follows:
   ;;                           (make-display-table)))
   ;;  (aset buffer-display-table ?\t (apply 'vector (append "<TAB>" nil)))
 
-  ;; Symbol & length completion.
-  ;; We have to move the setup of `TeX-complete-list' after
-  ;; `run-mode-hooks' in order to reflect the file local customization
-  ;; of `TeX-insert-braces' and `TeX-complete-word'.
-  (setq-local TeX-complete-list
-              (list (list "\\\\\\([a-zA-Z]*\\)"
-                          1
-                          (lambda ()
-                            (append (TeX-symbol-list-filtered)
-                                    (when (fboundp 'LaTeX-length-list)
-                                      (LaTeX-length-list))
-                                    (when (fboundp 'LaTeX-counter-list)
-                                      (mapcar (lambda (x)
-                                                `(,(concat "the" (car x))))
-                                              (LaTeX-counter-list)))))
-                          (if TeX-insert-braces "{}"))
-                    (list "" TeX-complete-word)))
-
   (funcall TeX-install-font-lock)
 
   ;; We want this to be early in the list, so we do not add it before
@@ -3822,6 +3832,57 @@ The algorithm is as follows:
                 (TeX-master-file nil nil t))
               (TeX-update-style t)) nil t))
 
+(defun TeX-mode-cleanup ()
+  "Cleanup function for `TeX-mode'.
+Run after mode hooks and file local variables application."
+  ;; Symbol & length completion.
+  (or (local-variable-p 'TeX-complete-list)
+      (setq-local TeX-complete-list
+                  (list (list "\\\\\\([a-zA-Z]*\\)"
+                              1
+                              (lambda ()
+                                (append
+                                 (TeX-symbol-list-filtered)
+                                 ;; These LaTeX-*-list are called even
+                                 ;; in non-LaTeX mode buffers, but
+                                 ;; that is permissible because they
+                                 ;; return empty list immediately.
+                                 (when (fboundp 'LaTeX-length-list)
+                                   (LaTeX-length-list))
+                                 (when (fboundp 'LaTeX-counter-list)
+                                   (mapcar (lambda (x)
+                                             `(,(concat "the" (car x))))
+                                           (LaTeX-counter-list)))))
+                              (if TeX-insert-braces "{}"))
+                        (list "" TeX-complete-word))))
+
+  ;; Complete style initialization in buffers which don't visit files
+  ;; and which are therefore missed by the setting of above
+  ;; `find-file-hook'.  This is necessary for `xref-find-references',
+  ;; for example. (bug#65912)
+  (unless buffer-file-truename
+    (TeX-update-style))
+
+  (TeX-set-mode-name))
+
+;; COMPATIBILITY for Emacs<29
+;;;###autoload
+(put 'TeX-mode 'auctex-function-definition (symbol-function 'TeX-mode))
+
+;; COMPATIBILITY for Emacs<30
+(unless (fboundp 'derived-mode-add-parents)
+  (advice-add 'derived-mode-p :after-until
+              ;; Don't quote by #'-style to avoid compiler warning.
+              'TeX--compat-derived-mode-p)
+  (defun TeX--compat-derived-mode-p (&rest modes)
+    "Add pseudo-parents facility to `derived-mode-p' like Emacs 30.
+Modes registered in `derived-mode-extra-parents' property of the
+current major mode name symbol are regarded as parent modes as
+long as `derived-mode-p' is concerned."
+    (let ((extra-parents (get major-mode 'derived-mode-extra-parents)))
+      (and extra-parents
+           (cl-loop for parent in extra-parents
+                    thereis (memq parent modes))))))
 
 ;;; Hilighting
 
@@ -4230,8 +4291,8 @@ It can also be a name of a variable having such value."
                         (group (regexp :tag "Match")
                                (sexp :tag "Groups")
                                symbol)))
-  :group 'TeX-parse)
-  (make-variable-buffer-local 'TeX-auto-regexp-list)
+  :group 'TeX-parse
+  :local t)
 
 (defun TeX-auto-add-regexp (regexp)
   "Add REGEXP to `TeX-auto-regexp-list' if not already a member."
@@ -4278,16 +4339,16 @@ alter the numbering of any ordinary, non-shy groups.")
 (defcustom TeX-auto-parse-length 999999
   "Maximal length of TeX file (in characters) that will be parsed."
   :group 'TeX-parse
-  :type 'integer)
-  (make-variable-buffer-local 'TeX-auto-parse-length)
+  :type 'integer
+  :local t)
 
 (defcustom TeX-auto-x-parse-length 0
   "Maximum length of TeX file that will be parsed additionally.
 Use `TeX-auto-x-regexp-list' for parsing the region between
 `TeX-auto-parse-length' and this value."
   :group 'TeX-parse
-  :type 'integer)
-  (make-variable-buffer-local 'TeX-auto-x-parse-length)
+  :type 'integer
+  :local t)
 
 (defcustom TeX-auto-x-regexp-list 'LaTeX-auto-label-regexp-list
   "List of regular expressions used for additional parsing.
@@ -4304,8 +4365,8 @@ See `TeX-auto-x-parse-length'."
                         (group (regexp :tag "Match")
                                (sexp :tag "Groups")
                                symbol)))
-  :group 'TeX-parse)
-  (make-variable-buffer-local 'TeX-auto-x-regexp-list)
+  :group 'TeX-parse
+  :local t)
 
 (defun TeX-regexp-group-count (regexp)
   "Return number of groups in a REGEXP.  This is not foolproof:
@@ -4455,9 +4516,8 @@ Check for potential LaTeX environments."
 (defcustom TeX-default-extension "tex"
   "Default extension for TeX files."
   :group 'TeX-file-extension
-  :type 'string)
-
-  (make-variable-buffer-local 'TeX-default-extension)
+  :type 'string
+  :local t)
 
 (defvar TeX-doc-extensions
   '("dvi" "pdf" "ps" "txt" "html" "dvi\\.gz" "pdf\\.gz" "ps\\.gz" "txt\\.gz"
@@ -4769,6 +4829,16 @@ Also see `ignore'.
 This is a compatibility function for Emacs versions prior to v.28."
     t))
 
+;; COMPATIBILITY for Emacs<30
+(if (fboundp 'derived-mode-add-parents)
+    (defalias 'TeX-derived-mode-add-parents #'derived-mode-add-parents)
+  ;; Adapted copy of `derived-mode-add-parents'.
+  (defun TeX-derived-mode-add-parents (mode extra-parents)
+    "Add EXTRA-PARENTS to the parents of MODE.
+Declares the parents of MODE to be its main parent (as defined
+in `define-derived-mode') plus EXTRA-PARENTS."
+    (put mode 'derived-mode-extra-parents extra-parents)))
+
 (defun TeX-match-buffer (n)
   "Return the substring corresponding to the N'th match.
 See `match-data' for details."
@@ -4831,9 +4901,6 @@ element to ALIST-VAR."
 
 ;;; Syntax Table
 
-(defvar-local TeX-mode-syntax-table (make-syntax-table)
-  "Syntax table used while in TeX mode.")
-
 (progn ; Define TeX-mode-syntax-table.
   (modify-syntax-entry (string-to-char TeX-esc)
                        "\\" TeX-mode-syntax-table)
@@ -4974,8 +5041,8 @@ Brace insertion is only done if point is in a math 
construct and
   "Call the function specified by the variable `TeX-newline-function'."
   (interactive) (call-interactively TeX-newline-function))
 
-(defvar TeX-mode-map
-  (let ((map (make-sparse-keymap)))
+(progn
+  (let ((map TeX-mode-map))
     ;; Standard
     ;; (define-key map "\177"     #'backward-delete-char-untabify)
     (define-key map "\C-c}"    #'up-list)
@@ -5035,8 +5102,9 @@ Brace insertion is only done if point is in a math 
construct and
     (define-key map "\C-c_" #'TeX-master-file-ask)  ;*** temporary
 
     (define-key map "\C-xng" #'TeX-narrow-to-group)
-    map)
-  "Keymap for common TeX and LaTeX commands.")
+
+    ;; Hide "Text" menu entry inherited from text mode.
+    (define-key map [menu-bar text] #'undefined)))
 
 (defun TeX-mode-specific-command-menu (mode)
   "Return a Command menu specific to the major MODE."
@@ -5166,7 +5234,7 @@ Brace insertion is only done if point is in a math 
construct and
      :active (and (boundp 'TeX-fold-mode) TeX-fold-mode)
      :help "Hide the macro containing point"]
     ["Hide Current Environment" TeX-fold-env
-     :visible (not (eq major-mode 'plain-tex-mode))
+     :visible (not (eq major-mode 'plain-TeX-mode))
      :active (and (boundp 'TeX-fold-mode) TeX-fold-mode)
      :help "Hide the environment containing point"]
     ["Hide Current Comment" TeX-fold-comment
@@ -5225,8 +5293,8 @@ Brace insertion is only done if point is in a math 
construct and
          ;; mode-specific menu title?
          (list
           (cond
-           ((eq major-mode 'doctex-mode) "LaTeX")
-           ((eq major-mode 'context-mode) "ConTeXt")
+           ((eq major-mode 'docTeX-mode) "LaTeX")
+           ((eq major-mode 'ConTeXt-mode) "ConTeXt")
            (t TeX-base-mode-name)))
          (or TeX-customization-menu
              (setq TeX-customization-menu
@@ -5236,7 +5304,6 @@ Brace insertion is only done if point is in a math 
construct and
      :help ,(format "Problems with AUCTeX %s? Mail us!"
                     AUCTeX-version)]))
 
-
 ;;; Verbatim constructs
 
 (defvar-local TeX-verbatim-p-function nil
@@ -5536,7 +5603,7 @@ reset to \" \"."
     ;; Preset mode-dependent syntax entries.  (Mode-independent entries
     ;; are set when the variable `TeX-search-syntax-table' is created.)
     (modify-syntax-entry (string-to-char TeX-esc) "\\" TeX-search-syntax-table)
-    (unless (eq major-mode 'texinfo-mode)
+    (unless (eq major-mode 'Texinfo-mode)
       (modify-syntax-entry ?\% "<" TeX-search-syntax-table))
     ;; Clean up the entries which can be specified as arguments.
     (dolist (elt char-syntax-alist)
@@ -6141,7 +6208,7 @@ With optional argument ARG, also reload the style hooks."
           (save-buffer)
         (TeX-auto-write)))
     (normal-mode)
-    ;; See also addition to `find-file-hook' in `VirTeX-common-initialization'.
+    ;; See also addition to `find-file-hook' in `TeX-mode'.
     (when (eq TeX-master 'shared) (TeX-master-file nil nil t))
     (TeX-update-style t)))
 
@@ -6222,7 +6289,7 @@ With prefix argument FORCE, always inserts \" characters."
                                              font-lock-comment-face)
                                            (1- (point))))
           (texmathp)
-          (and (TeX-in-comment) (not (eq major-mode 'doctex-mode))))
+          (and (TeX-in-comment) (not (eq major-mode 'docTeX-mode))))
       (self-insert-command (prefix-numeric-value force))
     (TeX-update-style)
     (let* ((lang-override (if (eq (car TeX-quote-language) 'override)
@@ -6461,7 +6528,7 @@ enter the number of the file to view, anything else to 
skip: ") list)))
 (autoload 'info-lookup->completions "info-look")
 
 (defvar TeX-doc-backend-alist
-  '((texdoc (plain-tex-mode latex-mode doctex-mode ams-tex-mode context-mode)
+  '((texdoc (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode ConTeXt-mode)
             (lambda ()
               (when (executable-find "texdoc")
                 (TeX-search-files-by-type 'docs 'global t t)))
@@ -6469,25 +6536,25 @@ enter the number of the file to view, anything else to 
skip: ") list)))
               ;; texdoc in MiKTeX requires --view in order to start
               ;; the viewer instead of an intermediate web page.
               (call-process "texdoc" nil 0 nil "--view" doc)))
-    (latex-info (latex-mode)
+    (latex-info (LaTeX-mode)
                 (lambda ()
                   (mapcar (lambda (x)
                             (let ((x (car x)))
                               (if (string-match "\\`\\\\" x)
                                   (substring x 1) x)))
-                          (info-lookup->completions 'symbol 'latex-mode)))
+                          (info-lookup->completions 'symbol 'LaTeX-mode)))
                 (lambda (doc)
-                  (info-lookup-symbol (concat "\\" doc) 'latex-mode)))
-    (texinfo-info (texinfo-mode)
+                  (info-lookup-symbol (concat "\\" doc) 'LaTeX-mode)))
+    (texinfo-info (Texinfo-mode)
                   (lambda ()
                     (mapcar (lambda (x)
                               (let ((x (car x)))
                                 (if (string-match "\\`@" x)
                                     (substring x 1) x)))
                             (info-lookup->completions 'symbol
-                                                      'texinfo-mode)))
+                                                      'Texinfo-mode)))
                   (lambda (doc)
-                    (info-lookup-symbol (concat "@" doc) 'texinfo-mode))))
+                    (info-lookup-symbol (concat "@" doc) 'Texinfo-mode))))
   "Alist of backends used for looking up documentation.
 Each item consists of four elements.
 
@@ -6706,15 +6773,24 @@ error."
 
 ;;; Abbrev mode
 
-(defmacro TeX-abbrev-mode-setup (mode)
-  "Set up the abbrev table and variable for MODE."
+(defmacro TeX-abbrev-mode-setup (mode usertable)
+  "Set up the abbrev table and variable for MODE.
+The table inherits from USERTABLE if it is a valid abbrev table."
   (let ((symbol (intern (concat (symbol-name mode) "-abbrev-table")))
         (name (TeX-mode-prefix mode)))
     `(progn
        (defvar ,symbol nil
          ,(format "Abbrev table for %s mode." name))
        (define-abbrev-table ',symbol nil)
-       (abbrev-table-put ,symbol :parents (list text-mode-abbrev-table)))))
+       (let ((parents (list text-mode-abbrev-table)))
+         ;; Users may already have user abbrevs in tables based on the
+         ;; former mode names such as `latex-mode-abbrev-table',
+         ;; stored in .emacs.d/abbrev_defs.  In that case, add them as
+         ;; parent abbrev tables.
+         (if (and (boundp ',usertable)
+                  (abbrev-table-p ,usertable))
+             (push ,usertable parents))
+         (abbrev-table-put ,symbol :parents parents)))))
 
 
 ;;; Special provisions for other modes and libraries
@@ -7388,7 +7464,7 @@ in `TeX-expand-list-builtin' and `TeX-expand-list'."
            (format
             (if (and extra
                      (stringp TeX-command-text)
-                     (memq major-mode '(latex-mode doctex-mode))
+                     (memq major-mode '(LaTeX-mode docTeX-mode))
                      (memq TeX-engine '(default uptex)))
                 ;; Since TeXLive 2018, the default encoding for LaTeX
                 ;; files has been changed to UTF-8 if used with
@@ -7598,7 +7674,7 @@ omitted) and `TeX-region-file'."
                                 TeX-file-extensions)
              (TeX-save-document name-or-file-fn))
            TeX-command-default)
-          ((and (memq major-mode '(doctex-mode latex-mode))
+          ((and (memq major-mode '(docTeX-mode LaTeX-mode))
                 ;; Want to know if bib file is newer than .bbl
                 ;; We don't care whether the bib files are open in emacs
                 (TeX-check-files (TeX--concat-ext name-or-file-fn "bbl")
@@ -7942,7 +8018,7 @@ run of `TeX-run-format', use
 
   (let ((idx-file nil) (element nil))
     ;; Store md5 hash of the index file before running LaTeX.
-    (and (memq major-mode '(doctex-mode latex-mode))
+    (and (memq major-mode '(docTeX-mode LaTeX-mode))
          (prog1 (file-exists-p
                  (setq idx-file (expand-file-name (TeX-active-master "idx"))))
            ;; In order to avoid confusion and pollution of
@@ -8468,8 +8544,7 @@ Changebar info has changed." nil t)
           "%s" "You should run LaTeX again to synchronize exercise properties")
          (setq TeX-command-next TeX-command-default))
         ((re-search-forward
-          "^\\(\\*\\* \\)?J?I?p?\\(La\\|Sli\\)TeX\\(2e\\)? \
-\\(Version\\|ver\\.\\|<[0-9/-]*\\(?:u[^>]*\\)?>\\)" nil t)
+          TeX-LaTeX-sentinel-banner-regexp nil t)
          (let* ((warnings (and TeX-debug-warnings
                                (TeX-LaTeX-sentinel-has-warnings)))
                 (bad-boxes (and TeX-debug-bad-boxes
@@ -8864,7 +8939,7 @@ from.")
   ;; names right when analysing the process output buffer.
   ;; Note that \usepackage[utf8]{inputenc} is enabled by default in
   ;; standard (pdf)latex since TeXLive 2018.
-  (if (and (memq major-mode '(latex-mode doctex-mode))
+  (if (and (memq major-mode '(LaTeX-mode docTeX-mode))
            ;; Japanese upLaTeX requires the same treatment with
            ;; respect to non-ascii characters other than Japanese, in
            ;; file names within \message{}.
@@ -9110,7 +9185,7 @@ If a prefix argument OVERRIDE-CONFIRM is given, 
confirmation will
 depend on it being positive instead of the entry in
 `TeX-command-list'."
   (interactive "P")
-  (if (eq major-mode 'latex-mode)
+  (if (eq major-mode 'LaTeX-mode)
       (let* ((bounds (LaTeX-command-section-boundaries))
              (TeX-command-region-begin (car bounds))
              (TeX-command-region-end (cdr bounds)))
@@ -9126,7 +9201,7 @@ depend on it being positive instead of the entry in
 (defun LaTeX-command-run-all-section ()
   "Compile the current section until an error occurs or it is finished."
   (interactive)
-  (if (eq major-mode 'latex-mode)
+  (if (eq major-mode 'LaTeX-mode)
       (let* ((bounds (LaTeX-command-section-boundaries))
              (TeX-command-region-begin (car bounds))
              (TeX-command-region-end (cdr bounds)))
diff --git a/texmathp.el b/texmathp.el
index 5631916e..3316c461 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -280,7 +280,7 @@ See the variable `texmathp-tex-commands' about which 
commands are checked."
   (let* ((pos (point)) math-on sw-match
          (bound (save-excursion
                   (if (re-search-backward
-                       (if (eq major-mode 'doctex-mode)
+                       (if (memq major-mode '(doctex-mode docTeX-mode))
                            "[\n\r]%*[ \t]*[\n\r]"
                          "[\n\r][ \t]*[\n\r]")
                        nil 1 texmathp-search-n-paragraphs)



reply via email to

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