Hi, and thanks, it's great to see concrete movement towards trying to fix this longstanding issue.
> 1. I'd like to push it to savannah server as a feature branch of AUCTeX > repository (it isn't ready to merge into master branch yet.) Do you > think it's OK? Can't of any reason why not, but I'll leave it to the AUCTeX guys to give a definitive answer. > If so, I'm not sure how to do that so I'd like to confirm. FWIW, here's how I'd do it (using the command line): git push --set-upstream origin HEAD:feature/fix-mode-names-overlap > a. Invoked mode > a-1 > Suppose that Alice prefers built-in plain-tex-mode over AUCTeX and > customized `TeX-modes' to remove `plain-tex-mode' from it. She > also want AUCTeX-style auto-detection for files with .tex > extension so leave `tex-mode' in `TeX-modes'. After my patch is > applied, when she openes a plain tex file without mode: tag in the > File Local Variables section, it's opened in AUCTeX plain TeX mode > against her expectation. > The reason is that `TeX-tex-mode' calls AUCTeX mode names > according to the change in `TeX-format-list'. Maybe `TeX-format-list` should stay as it is, and `TeX-tex-mode` should instead rely on `TeX-modes` or `major-mode-remap-alist` to decide which function to call? > a-2 > Suppose that a site admin sets up AUCTeX as the default TeX modes > in site-start.el but Bob disabled them by (unload-feature > 'tex-site) in his init.el because he prefers built-in modes. In > addition, Bob has some latex files annotated with -*- LaTeX -*-, > which he recieved from someone else. After my patch is applied, > when he opens such a file, it results in File mode specification > error. > The reason is that tex-site.el is changed to delete the aliases > plain-TeX-mode -> plain-tex-mode, LaTeX-mode -> latex-mode. > > I think these are corner cases and am not sure whether we should > keep compatibility. Not sure either, but we can arrange to re-instate the aliases (they're not autoloads) upon unload, if so desired (actually, I think all it takes (in Emacs-29) is to use `(defalias 'LaTeX-mode nil)` instead of `(fset 'LaTeX-mode nil)`. Also, while I'm here, I think we should check that they are aliases before removing them). > b. Abbrev table > User abbrevs in, say, latex-mode-abbrev-table aren't inherited to > AUCTeX LaTeX mode. Is there a particular reason why `LaTeX-mode-abbrev-table` isn't made to inherit from `latex-mode-abbrev-table`? > c. desktop.el records the major mode name in the saved sessions. When > users have saved sessions with the name, say, latex-mode and > install this patch before the next session, desktop.el restores > them in wrong mode in the next session if `major-mode-remap-alist' > is available. Indeed, I hadn't thought about that use case. I can't think of a good way to "fix" it since it seems hard/impossible to reliably detect if that desktop was saved with an Emacs using the "old AUCTeX names" or the "new AUCTeX names". The best might be to accept the breakage and add a clear "release note" about it? > d. Directory local variables > d-1 > Directory local variables prepared for, say, `latex-mode' aren't > picked up by AUCTeX LaTeX-mode when `major-mode-remap-alist' is > available. > The reason is that `hack-local-variables' doesn't understand > that `LaTeX-mode' is redirected from `latex-mode'. This is something that we need to fix before this can make it into a release, I think. IIRC there's an open bug report on Debbugs about it. But it's not even clear what should be a good solution (from Emacs's point of view). Maybe in the mean time AUCTeX can "fix" it on its side by adding some clever piece of advice on the directory-local-vars code or by setting `derived-mode-parent`? > d-2 > Similar issue related to "superficial major modes" such as > japanese-LaTeX-mode still persists for directory local > variables[1] regardless whether `major-mode-remap-alist' is > available or not. > I'm still relying on ugly hack currently used for > japanese-{plain-tex,latex}-mode[2]. > > [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61211 > [2] The following code in tex-jp.el. I hope whichever fix we use for `d-1` will be applicable for `d-2`. > - TeX-tex-mode is an exception. It doesn't need > `define-derived-mode' in my opinion. Agreed (luckily: making it use `define-derived-mode` would be painful, as you can see in `tex-mode`). Stefan