Subject: bug#61210: 28.2; Request to modify code which can accidentally overwrite AUCTeX function

From: Stefan Monnier <[email-masked]>
Date: Sat, 18 Mar 2023 18:35:05 -0400

> If we do that in natural ways like
> (define-derived-mode LaTeX-mode text-mode "LaTeX" ...)
> or
> (defun LaTeX-mode () ...)
> , it could wreak havoc 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)
> ----------------------------------------------------------------------
> These defalias'es overwrite the AUCTeX definition unconditionally if
> tex-mode.el are loaded after AUCTeX. So AUCTeX has to do workarounds

In Emacs-29 (see commit 18d75b4ab91fef6e344e612580088b714acfdb6e), the
above `defalias` are now predefined once and for all:

    ;;;###autoload (defalias 'TeX-mode #'tex-mode)
    ;;;###autoload (defalias 'plain-TeX-mode #'plain-tex-mode)
    ;;;###autoload (defalias 'LaTeX-mode #'latex-mode)

It's still not ideal, but at least  loading `tex-mode` won't override
any other definition such as AUCTeX's.  I'd like to hear what you think
about this "solution", both in the short term and what we could try to
do in the longer term (e.g. I'd like to aim to get rid of those
defaliases, but I'm not sure how to get there progressively.
`define-obsolete-function-alias` is not a solution because almost noone
will see those obsolescence warnings, and to make matters worse the
obsolecence will stay (and thus become incorrect) after AUCTeX redefines
the function.  Maybe we should predefine things like `TeX-mode` not as
an alias but as an actual function that emits an obsolecence warning of
some kind?).

        Stefan