[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex ebc69e7ae7 14/43: Canonicalize mode names
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex ebc69e7ae7 14/43: Canonicalize mode names |
Date: |
Wed, 7 Feb 2024 06:07:10 -0500 (EST) |
branch: externals/auctex
commit ebc69e7ae76d46c331346bb44e10d7ad3fda4053
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Canonicalize mode names
In order to discard ugly defvaralias'es needed to keep compatibility,
use canonical mode names LaTeX-mode, plain-TeX-mode and TeX-mode.
Save the function definitions of those modes in the symbol property
`auctex-function-definition', and restore them after tex-mode.el is
loaded via `with-eval-after-load'.
* tex.el (TeX-mode): Rename from TeX--VirTeX-mode. Absorb
`VirTeX-common-initialization'.
(TeX--VirTeX-mode-map, TeX--VirTeX-mode-hook): Delete defvaralias.
(TeX-mode-syntax-table, TeX-mode-map): Remove explicit defvar and let
them defined by `define-derived-mode'.
* latex.el (LaTeX-mode): Rename from TeX-LaTeX-mode.
(TeX-LaTeX-mode-map, TeX-LaTeX-mode-hook): Delete defvaralias.
* plain-tex.el (plain-TeX-mode): Rename from TeX-plain-TeX-mode.
(TeX-plain-TeX-mode-map, plain-TeX-mode-hook): Delete defvaralias.
* tex-site.el.in (tex-site-unload-function): Erase data no longer
needed.
(TeX--alias-overlapped-modes): New function to manipulate function
definitions of the overlapped modes.
(): Use it to delete predefined aliases.
(with-eval-after-load): Use it to restore AUCTeX definition.
* context.el (ConTeXt-mode): Update parent mode name.
* font-latex.el (font-latex-setup): Update reference in comment from
`VirTeX-common-initialization' to `TeX-mode'.
---
context.el | 2 +-
font-latex.el | 6 +++---
latex.el | 21 ++-----------------
plain-tex.el | 20 ++----------------
tex-site.el.in | 31 ++++++++++++++++++++++------
tex.el | 65 +++++++++++++++++-----------------------------------------
6 files changed, 52 insertions(+), 93 deletions(-)
diff --git a/context.el b/context.el
index fc448e9aaf..5774ac9340 100644
--- a/context.el
+++ b/context.el
@@ -1913,7 +1913,7 @@ that is, you do _not_ have to cater for this yourself by
adding \\\\\\=' or $."
(defalias 'context-mode #'ConTeXt-mode)
;;;###autoload
-(define-derived-mode ConTeXt-mode TeX--VirTeX-mode "ConTeXt"
+(define-derived-mode ConTeXt-mode TeX-mode "ConTeXt"
"Major mode in AUCTeX for editing ConTeXt files.
Entering `ConTeXt-mode' calls the value of `text-mode-hook',
diff --git a/font-latex.el b/font-latex.el
index 71a5b25a9e..61309433bf 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1311,9 +1311,9 @@ 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.
+ ;; 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))
diff --git a/latex.el b/latex.el
index 81069f999f..1bcc66baea 100644
--- a/latex.el
+++ b/latex.el
@@ -6517,9 +6517,6 @@ environments."
;;; Keymap
-;; We can remove this defvaralias in future. See the comment before
-;; the definition of `TeX-LaTeX-mode'.
-(defvaralias 'TeX-LaTeX-mode-map 'LaTeX-mode-map)
(defvar LaTeX-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map TeX-mode-map)
@@ -7953,9 +7950,6 @@ This happens when \\left is inserted."
:type 'boolean
:group 'LaTeX-macro)
-;; We can remove this defvaralias in future. See the comment before
-;; the definition of `TeX-LaTeX-mode'.
-(defvaralias 'TeX-LaTeX-mode-hook 'LaTeX-mode-hook)
(defcustom LaTeX-mode-hook nil
"A hook run in LaTeX mode buffers."
:type 'hook
@@ -7972,30 +7966,20 @@ This happens when \\left is inserted."
(declare-function LaTeX-preview-setup "preview")
-;; We want to use `LaTeX-mode' as the function name. However, it is
-;; overwritten when tex-mode.el, prior to Emacs 29, is loaded afterwards
-;; because it has non-commented out (defalias 'LaTeX-mode
-;; #'latex-mode) in it.
-;; When the least supported emacsen version becomes 29, we can safely
-;; transform this definition to `(define-derived-mode LaTeX-mode
-;; TeX-mode ...)' and remove defaliases for compatibility.
;;;###autoload
-(define-derived-mode TeX-LaTeX-mode TeX--VirTeX-mode "LaTeX"
+(define-derived-mode LaTeX-mode TeX-mode "LaTeX"
"Major mode in AUCTeX for editing LaTeX files.
See info under AUCTeX for full documentation.
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'."
- :syntax-table LaTeX-mode-syntax-table
- :abbrev-table LaTeX-mode-abbrev-table
:after-hook ;; Defeat filladapt
(if (bound-and-true-p filladapt-mode)
(turn-off-filladapt-mode))
(LaTeX-common-initialization)
(setq TeX-base-mode-name mode-name)
- (setq major-mode 'LaTeX-mode)
(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)
@@ -8027,9 +8011,8 @@ of `LaTeX-mode-hook'."
(add-hook 'flymake-diagnostic-functions #'LaTeX-flymake nil t))
;; COMPATIBILITY for Emacs<29
-;; Override defalias in tex-mode.el.
;;;###autoload
-(defalias 'LaTeX-mode #'TeX-LaTeX-mode)
+(put 'LaTeX-mode 'auctex-function-definition (symbol-function 'LaTeX-mode))
(TeX-abbrev-mode-setup docTeX-mode doctex-mode-abbrev-table)
diff --git a/plain-tex.el b/plain-tex.el
index a314337a38..37370aabce 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -48,9 +48,6 @@ Install tool bar if `plain-TeX-enable-toolbar' and
;;; Keymap and menu
-;; We can remove this defvaralias in future. See the comment before
-;; the definition of `TeX-plain-TeX-mode'.
-(defvaralias 'TeX-plain-TeX-mode-map 'plain-TeX-mode-map)
(defvar plain-TeX-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map TeX-mode-map)
@@ -111,9 +108,6 @@ argument DIALECT-EXPR when the hook is to be run only on
plain-TeX file, or any mode derived thereof. See variable
`TeX-style-hook-dialect'." )
-;; We can remove this defvaralias in future. See the comment before
-;; the definition of `TeX-plain-TeX-mode'.
-(defvaralias 'TeX-plain-TeX-mode-hook 'plain-TeX-mode-hook)
(defcustom plain-TeX-mode-hook nil
"A hook run in plain TeX mode buffers."
:type 'hook
@@ -121,15 +115,8 @@ plain-TeX file, or any mode derived thereof. See variable
(TeX-abbrev-mode-setup plain-TeX-mode plain-tex-mode-abbrev-table)
-;; We want to use `plain-TeX-mode' as the function name. However, it is
-;; overwritten when tex-mode.el, prior to Emacs 29, is loaded afterwards
-;; because it has non-commented out (defalias 'plain-TeX-mode
-;; #'plain-tex-mode) in it.
-;; When the least supported emacsen version becomes 29, we can safely
-;; transform this definition to `(define-derived-mode plain-TeX-mode
-;; TeX-mode ...)' and remove defaliases for compatibility.
;;;###autoload
-(define-derived-mode TeX-plain-TeX-mode TeX--VirTeX-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
@@ -142,10 +129,8 @@ 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'."
:syntax-table nil
- :abbrev-table plain-TeX-mode-abbrev-table
(plain-TeX-common-initialization)
- (setq major-mode 'plain-TeX-mode)
(setq TeX-base-mode-name mode-name)
(setq TeX-command-default "TeX")
@@ -159,9 +144,8 @@ of `plain-TeX-mode-hook'."
nil t))
;; COMPATIBILITY for Emacs<29
-;; Override defalias in tex-mode.el.
;;;###autoload
-(defalias 'plain-TeX-mode #'TeX-plain-TeX-mode)
+(put 'plain-TeX-mode 'auctex-function-definition (symbol-function
'plain-TeX-mode))
(defun plain-TeX-common-initialization ()
"Common initialization for plain TeX like modes."
diff --git a/tex-site.el.in b/tex-site.el.in
index 59318bd9ce..b9e0e268b2 100644
--- a/tex-site.el.in
+++ b/tex-site.el.in
@@ -94,6 +94,12 @@ shared by all users of a site."
(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)
@@ -140,16 +146,29 @@ 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.
-;; This `with-eval-after-load' should be removed when the supported
-;; emacsens version becomes 29 or higher and (defun TeX-LaTeX-mode
-;; ...) etc. are turned into (define-derived-mode LaTeX-mode ...) etc.
(with-eval-after-load 'tex-mode
;; This must be no-op after (unload-feature 'tex-site).
- (when (featurep 'tex-site)
- (defalias 'plain-TeX-mode #'TeX-plain-TeX-mode)
- (defalias 'LaTeX-mode #'TeX-LaTeX-mode)))
+ (if (featurep 'tex-site)
+ (TeX--alias-overlapped-modes t)))
(defconst AUCTeX-version "@AUCTEXVERSION@"
"AUCTeX version.
diff --git a/tex.el b/tex.el
index 7fc288fc50..ced88a816e 100644
--- a/tex.el
+++ b/tex.el
@@ -76,9 +76,6 @@
(defvar TeX-esc)
(defvar TeX-interactive-mode)
(defvar TeX-macro-global)
-;; We can remove this defvaralias in future. See the comment before
-;; the definition of `TeX--VirTeX-mode'.
-(defvaralias 'TeX--VirTeX-mode-map 'TeX-mode-map)
(defvar TeX-mode-map)
(defvar TeX-mode-p)
(defvar TeX-output-extension)
@@ -172,9 +169,6 @@ If nil, none is specified."
;; At least in TeXLive 2009 ConTeXt does not support an omega option anymore.
(make-obsolete-variable 'ConTeXt-Omega-engine 'TeX-engine-alist "11.86")
-;; We can remove this defvaralias in future. See the comment before
-;; the definition of `TeX--VirTeX-mode'.
-(defvaralias 'TeX--VirTeX-mode-hook 'TeX-mode-hook)
(defcustom TeX-mode-hook nil
"A hook run in TeX mode buffers."
:type 'hook
@@ -1855,9 +1849,9 @@ 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 (if TeX-source-correlate-mode
@@ -3757,8 +3751,14 @@ other entries will enter `plain-TeX-mode'."
(memq 'font-latex-verbatim-face face)
(eq face 'font-latex-verbatim-face))))))
-(defun VirTeX-common-initialization ()
- "Perform basic initialization."
+(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-set-mode-name)
+ :interactive nil
+
(setq TeX-mode-p t)
(setq TeX-output-extension (if TeX-PDF-mode "pdf" "dvi"))
(setq indent-tabs-mode nil)
@@ -3853,6 +3853,10 @@ other entries will enter `plain-TeX-mode'."
(TeX-master-file nil nil t))
(TeX-update-style t)) nil t))
+;; COMPATIBILITY for Emacs<29
+;;;###autoload
+(put 'TeX-mode 'auctex-function-definition (symbol-function 'TeX-mode))
+
;;; Hilighting
@@ -4869,14 +4873,6 @@ element to ALIST-VAR."
;;; Syntax Table
-;; XXX: Now we have `text-mode' as parent mode. Should we make AUCTeX
-;; syntax table inherit from `text-mode-syntax-table'?
-(defvar TeX-mode-syntax-table (make-syntax-table)
- "Syntax table used while in TeX mode.")
-
-;; FIXME: Does this make sense?
- (make-variable-buffer-local 'TeX-mode-syntax-table)
-
(progn ; Define TeX-mode-syntax-table.
(modify-syntax-entry (string-to-char TeX-esc)
"\\" TeX-mode-syntax-table)
@@ -5017,8 +5013,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)
@@ -5077,9 +5073,7 @@ Brace insertion is only done if point is in a math
construct and
;; Multifile
(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.")
+ (define-key map "\C-xng" #'TeX-narrow-to-group)))
(defun TeX-mode-specific-command-menu (mode)
"Return a Command menu specific to the major MODE."
@@ -5271,27 +5265,6 @@ Brace insertion is only done if point is in a math
construct and
:help ,(format "Problems with AUCTeX %s? Mail us!"
AUCTeX-version)]))
-;;; The mode (continuation)...
-;; We have to wait this `define-derived-mode' until `TeX-mode-map' and
-;; `TeX-mode-syntax-table' are ready.
-
-;; This should definitely be `TeX-mode', but then tex-mode.el would
-;; overwrite it by (defalias 'TeX-mode #'tex-mode) prior to emacs 29.
-;; When the least supported emacsen version becomes 29, we can safely
-;; transform this definition to `(define-derived-mode TeX-mode ...)'
-;; and get rid of ugly defvaralias'es for `TeX-mode-hook' and
-;; `TeX-mode-map'.
-(define-derived-mode TeX--VirTeX-mode text-mode "TeX"
- "Base mode for AUCTeX major modes except Texinfo mode.
-
-Not intended for direct use for user."
- :syntax-table TeX-mode-syntax-table
- :abbrev-table nil
- :after-hook (TeX-set-mode-name)
- :interactive nil
-
- (VirTeX-common-initialization))
-
;;; Verbatim constructs
(defvar TeX-verbatim-p-function nil
@@ -6182,7 +6155,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)))
- [elpa] externals/auctex 43be8c047b 26/43: * doc/changes.texi: Document the change related mode name renewal., (continued)
- [elpa] externals/auctex 43be8c047b 26/43: * doc/changes.texi: Document the change related mode name renewal., Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 997bff87d2 23/43: Retain compatibility for directory local variables, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 9c6f701a0c 12/43: Use `define-derived-mode' for AUCTeX major modes, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 77ae6b5652 19/43: Restore tool bar on japanese-plain-TeX-mode, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex f9fc9619a1 35/43: ; Replace keyword wp with text, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex d7f1d28159 32/43: ; * tex.el (TeX-auto-parse-length): Fix Typo., Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 5b61f6c563 42/43: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 94127f5e10 37/43: Make banner regexp customizable, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex f41fbc0eac 18/43: Improve mode cleanup functions, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 52f903a4e9 08/43: Take care of `unload-feature', Tassilo Horn, 2024/02/07
- [elpa] externals/auctex ebc69e7ae7 14/43: Canonicalize mode names,
Tassilo Horn <=
- [elpa] externals/auctex 77a02f837a 30/43: Mark options as buffer-local with the :local keyword, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 8cb64a3487 21/43: Augment suitable default entry for M-?, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex c401a1130e 38/43: ; Arrange the documentation of the previous commit, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex b407b239e2 36/43: Update style/simpleicons.el to package v11.1.0, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 4ddf6dd9bd 20/43: Tune docTeX mode abbrev table, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex ebd04735e7 16/43: Merge branch 'master' into feature/fix-mode-names-overlap, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex c12eba0ba2 17/43: Adjust menu, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex f06778a7ae 27/43: * doc/changes.texi: Update the last change., Tassilo Horn, 2024/02/07
- [elpa] externals/auctex a6e53e53d8 09/43: Refine management of mode redirection, Tassilo Horn, 2024/02/07
- [elpa] externals/auctex 15418dc957 34/43: ; * doc/changes.texi: Reshape the new entries., Tassilo Horn, 2024/02/07