Subject: Re: bug#57003: 28.1.90; Can local variables be loaded before loading major mode?

From: Stefan Monnier <[email-masked]>
Date: Sat, 29 Oct 2022 23:51:39 -0400

>>>> Will moving the whole major mode definition into
>>>> `hack-local-variables-hook' be safe?
>>> Define "safe".  I'm sure it'll cause problems in corner cases.
>>> If those problems come down to the fact that `hack-local-variables-hook'
>>> doesn't fit the bill, then we can look at fixing that.
>> I was mostly asking if you are aware about any gotchas.
>
> Not really, no.  I have no doubt that there are various (in addition to
> the one you mention above).

Looking at some of the related code, I had a feeling of "déjà vu":
`hack-local-variables-hook' indeed suffers from various gotchas
(starting with the non-intuitive name and the fact that it only
applies to file-visiting buffers), and I think my recommendation was out
of date: the better answer is to use `after-change-major-mode-hook` the
`:after-hook` thingy of `define-derived-mode`.

And the remaining gotcha (for Org's support of Emacs-25) is that in
Emacs<26 these were run *before* `hack-local-variables` :-(

        Stefan