> 1. I first tried [A] because [B] wouldn't be easy to retain > compatibility for users who have > - a lot of files with "mode: latex" tag in the file local variables > section.
The `mode:` specifies which function is called to enable the mode, rather than which value of `major-mode` will be used in the resulting buffer. `mode: latex` means that we'll call `latex-mode` and that function can activate AUCTeX's `LaTeX-mode` (which sets `major-mode` to `LaTeX-mode`) without any trouble. [ And in Emacs-30, you can use `major-mode-remap-alist` so that `mode: latex` will not call `latex-mode` but some other function, such as `LaTeX-mode`. ] > - hard-coded mode names in their personal customized codes. I don't know what problem you're thinking of here. > The keymaps of AUCTeX LaTeX mode and built-in latex mode have a lot of > overlaps. And conflicts, yes :-( > It seems difficult to me to separate all of them. In > tex-mode.el, we see: > ---------------------------------------------------------------------- > (defun tex-define-common-keys (keymap) > "Define the keys that we want defined both in TeX mode and in the TeX > shell." > (define-key keymap "\C-c\C-k" #'tex-kill-job) > (define-key keymap "\C-c\C-l" #'tex-recenter-output-buffer) > (define-key keymap "\C-c\C-q" #'tex-show-print-queue) > [...] > (define-key keymap "\C-c\C-v" #'tex-view) > [...] > (defvar tex-mode-map > (let ((map (make-sparse-keymap))) > [...] > (define-key map "\"" #'tex-insert-quote) > (define-key map "\n" #'tex-handle-newline) > (define-key map "\M-\r" #'latex-insert-item) > [...] > (define-key map "\C-c{" #'tex-insert-braces) > [...] > (define-key map "\C-c\C-c" #'tex-compile) > (define-key map "\C-c\C-i" #'tex-bibtex-file) > (define-key map "\C-c\C-o" #'latex-insert-block) > > ;; Redundant keybindings, for consistency with SGML mode. > (define-key map "\C-c\C-t" #'latex-insert-block) > [...] > (define-key map "\C-c/" #'latex-close-block) > > (define-key map "\C-c\C-e" #'latex-close-block) > [...] > (define-key map "\C-c\C-m" #'tex-feed-input) > [...] > (defvar latex-mode-map > (let ((map (make-sparse-keymap))) > [...] > (define-key map "\C-c\C-s" #'latex-split-block) > ---------------------------------------------------------------------- > All these key sequences have different binding in AUCTeX (+RefTeX). > Thus I don't see a clean way to meet the assumption "if we can arrange > for latex-mode and auctex-mode not to collide in their keymaps". [ Side note: RefTeX is also used with plan `latex-mode`. ] AFAIK the only clean way is to actually change those bindings. Yes, users will complain, and it may even break some 3rd party code, so it'll be somewhat painful. > In addition, I'm afraid that menus and tool bars are intermixed if we > use `make-composed-keymap' for these two keymaps. Indeed. OTOH you should be able to completely hide the "base" menus (by overriding their bindings with something silly like the `ignore` command). > 2. Thus I tried [B] next, in the hope that we can circumvent the above > mentioned difficulties by similar workarounds employed in the current > startup codes and announcement to the users. > > If we are to take this approach, I think that the new mode name should > be, e.g., "LaTeX-mode" because the user-exposed functions and variables > have that prefix now. Agreed. > because tex-mode.el has these lines: > ---------------------------------------------------------------------- > ;;;###autoload > (defalias 'TeX-mode #'tex-mode) > ;;;###autoload > (defalias 'plain-TeX-mode #'plain-tex-mode) > ;;;###autoload > (defalias 'LaTeX-mode #'latex-mode) > ---------------------------------------------------------------------- Yuck! These need to go! > Hence I'd like to request to modify the built-in tex-modes.el to delete > those lines, or at least to do fboundp test like > (unless (fboundp 'LaTeX-mode) > (defalias 'LaTeX-mode #'latex-mode)) > in, say, emacs-30. Agreed. Could you open a bug report for that? (with me in `X-Debbugs-Cc:`) [ I wouldn't be surprised if there's a bit of reluctance to do that. ] > I'd like to discuss dispatch functions context-**-mode and > japanese-**-mode here. They only do language-specific set-ups and turn > into context-mode, latex-mode and plain-tex-mode eventually. In some > aspects, they are similar with guess functions `tex--guess-mode' and > `TeX-tex-mode': > - They can be specified as `mode' tag of file local variable and entry > of `auto-mode-alist'. > - They never hold their own `major-mode' value. > - When called, they eventually turn into another proper major mode. > Note that it isn't enough to do as > (define-derived-mode japanese-latex-mode latex-mode "LaTeX" > ... > (setq major-mode 'latex-mode) > ...) > because it doesn't respond to directory local variable entry of the form > ((japanese-latex-mode > ...)) > in that case. Hmm... this seems directly relevant to Emacs-30's new `major-mode-remap-alist`. Can you open another bug report (with me in `X-Debbugs-Cc:`) to discuss this. Basically, the question is what notion of "major mode" should be used to lookup the directory-local variable settings: should it be the major mode specified via `mode:` or the one held in `major-mode` or yet something else? > In addition, they don't need their own keymaps and syntax > tables created by define-derived-mode. (Own hooks and abbrev tables may > be useful, though.) You can use `:keymap` and `:syntax-table` args to `define-derived-mode` to avoid creating their own. Stefan