branch: feature/fix-mode-names-overlap
commit 938e82ed8e2b9bde3e2d205f42f8bde0ef17544f
Author: Ikumi Keita <ik...@ikumi.que.jp>
Commit: Ikumi Keita <ik...@ikumi.que.jp>

    Commit for plain TeX and AmS-TeX
    
    * plain-tex.el:
    * tex.el:
    * preview.el.in:
    * style/amstex.el:
    * tex-fold.el:
    * tex-bar.el:
    Change major mode names.
    plain-tex-mode -> plain-TeX-mode
    ams-tex-mode -> AmSTeX-mode
    Also, change hook name and make obsolete variable alias.
    AmS-TeX-mode-hook -> AmSTeX-mode-hook
---
 plain-tex.el    | 49 +++++++++++++++++++++++++++++++++----------------
 preview.el.in   |  2 +-
 style/amstex.el |  2 +-
 tex-bar.el      |  2 +-
 tex-fold.el     |  4 ++--
 tex.el          | 46 +++++++++++++++++++++++-----------------------
 6 files changed, 61 insertions(+), 44 deletions(-)

diff --git a/plain-tex.el b/plain-tex.el
index 0800b2f3..63366d9b 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,22 +113,29 @@ 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)
 
+;; 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
+;; text-mode ...)' and remove defaliases for compatibility.
 ;;;###autoload
-(defun TeX-plain-tex-mode ()
+(defun TeX-plain-TeX-mode ()
   "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)
   (plain-TeX-common-initialization)
-  (setq major-mode 'plain-tex-mode)
+  (setq major-mode 'plain-TeX-mode)
   (use-local-map plain-TeX-mode-map)
   (setq TeX-base-mode-name "TeX")
   (setq TeX-command-default "TeX")
@@ -137,11 +144,16 @@ of `plain-TeX-mode-hook'."
   (run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook)
   (TeX-set-mode-name))
 
+;; COMPATIBILITY for Emacs<29
+;; Override defalias in tex-mode.el.
+;;;###autoload
+(defalias 'plain-TeX-mode #'TeX-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)
+  (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
@@ -277,39 +289,44 @@ 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))
+  (cons "AmSTeX" 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.
+(defun AmSTeX-mode ()
+  "Major mode in AUCTeX for editing AmSTeX files.
 See info under AUCTeX for documentation.
 
 Special commands:
 \\{AmSTeX-mode-map}
 
-Entering `ams-tex-mode' calls the value of `text-mode-hook',
+Entering `AmSTeX-mode' calls the value of `text-mode-hook',
 then the value of `TeX-mode-hook', and then the value
-of `AmS-TeX-mode-hook'."
+of `AmSTeX-mode-hook'."
   (interactive)
   (plain-TeX-common-initialization)
-  (setq major-mode 'ams-tex-mode)
+  (setq major-mode 'AmSTeX-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)
+  (run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'AmSTeX-mode-hook)
   (TeX-set-mode-name))
 
+;;;###autoload
+(defalias 'ams-tex-mode #'AmSTeX-mode)
+
 (defcustom AmSTeX-clean-intermediate-suffixes
   TeX-clean-default-intermediate-suffixes
   "List of regexps matching suffixes of intermediate files to be deleted.
diff --git a/preview.el.in b/preview.el.in
index e26f478c..01fa864c 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -2272,7 +2272,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))
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/tex-bar.el b/tex-bar.el
index a6804e18..8e505d56 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.
diff --git a/tex-fold.el b/tex-fold.el
index 6f74f75a..fddd0af9 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -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))
@@ -418,7 +418,7 @@ 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)
diff --git a/tex.el b/tex.el
index b862d3c2..eddac66f 100644
--- a/tex.el
+++ b/tex.el
@@ -183,7 +183,7 @@ 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")
@@ -193,7 +193,7 @@ If nil, none is specified."
     ("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" 
TeX-run-compile nil
      (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"
@@ -202,11 +202,11 @@ If nil, none is specified."
      TeX-run-TeX nil
      (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
+     (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.
@@ -224,28 +224,28 @@ If nil, none is specified."
     ("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)
      :help "Check LaTeX file for correctness")
@@ -346,12 +346,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)
+                                (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)))
+                                     (const :tag "AmSTeX" AmSTeX-mode)))
                         (repeat :tag "Menu elements" :inline t sexp))))
 
 (defcustom TeX-command-output-list
@@ -545,7 +545,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"))
@@ -991,9 +991,9 @@ 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")
+  (cdr (assoc (or mode major-mode) '((plain-TeX-mode . "plain-TeX")
                                      (latex-mode . "LaTeX")
-                                     (ams-tex-mode . "AmSTeX")
+                                     (AmSTeX-mode . "AmSTeX")
                                      (doctex-mode . "docTeX")
                                      (texinfo-mode . "Texinfo")
                                      (context-mode . "ConTeXt")))))
@@ -3657,7 +3657,7 @@ Choose `ignore' if you don't want AUCTeX to install 
support for font locking."
 \\(article\\|report\\|book\\|slides\\)")
     ("JTEX" japanese-plain-tex-mode
      "-- string likely in Japanese TeX --")
-    ("AMSTEX" ams-tex-mode
+    ("AMSTEX" AmSTeX-mode
      "\\\\document\\b")
     ("CONTEXT" context-mode
      "\\\\\\(start\\(text\\|tekst\\|proje[ck]t\\|proiect\\|\
@@ -3668,7 +3668,7 @@ component\\|onderdeel\\|komponent[ea]\\|componenta\\)\
     ("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.
@@ -3686,7 +3686,7 @@ the major mode to be used.")
   "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)
+                (function-item plain-TeX-mode)
                 (function :tag "Other")))
 
 (defcustom TeX-force-default-mode nil
@@ -3705,7 +3705,7 @@ The algorithm is as follows:
       `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'"
+   3) Otherwise, use `plain-TeX-mode'"
   (interactive)
 
   (funcall (if (or (equal (buffer-size) 0)
@@ -5178,7 +5178,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
@@ -6448,7 +6448,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)))

Reply via email to