>> We should fix this for Emacs-30. >> [ And then add some backward compatibility hack (presumably using >> an advice for when AUCTeX is used on Emacs<30). ] > I attach my tentative proposal for Emacs<30, using an advice.
So, IIUC, you're counting on Someone™ to do the work on the Emacs side 🙂 > +(defcustom TeX-hack-former-dir-local-variables nil > + "If non-nil, apply dir local vars under former mode names. > +For example, directory local variables prepared for `latex-mode' > +will be available in `LaTeX-mode' buffers. > +It is highly discouraged to enable this option. Instead, please > +rewrite mode names in .dir-locals.el whenever possible." I hope we can arrange the code in Emacs-30 so that no changes are needed in `.dir-locals.el`, in which case the advice should be activated by default and we likely shouldn't plead with our users to rewrite their `.dir-locals.el`. > + (setq orig-former-parent (get former 'derived-mode-parent)) > + (put former 'derived-mode-parent former-parent) > + ;; Very ugly hack to deceive `derived-mode-p'. Suppose > + ;; - aaa-mode is an alias of bbb-mode > + ;; - major-mode value is aaa-mode > + ;; Then (derived-mode-p 'aaa-mode) returns nil on Emacs 28 and > + ;; later, which makes `dir-locals-collect-variables' ignore a > + ;; directory local variable entry for aaa-mode and look for an > + ;; entry for bbb-mode instead. Hence we temporally make > + ;; aaa-mode an alias of aaa-mode itself. :-( > + (setq orig-former (symbol-function former)) > + (fset former former) Hmm... this does look awful 🙁 Some questions/comments about the above comment: - Indeed, I see that (derived-mode-p 'aaa-mode) returns nil in that case, which is a bug. Do we have a bug-number for that? Amusingly, it returns `aaa-mode` if `aaa-mode` is undefined :-) - Is the problem new in Emacs-28 (if so, I guess it came about in the rewrite which introduced `provided-mode-derived-p`). - How exactly is it related to the issue of activating `latex-mode` dir-local settings in `LaTeX-mode`? I really should look at how best to solve the problem in Emacs-30, it might give me some ideas about how to write a better workaround for Emacs<30. Do you think it would be OK for AUCTeX to declare that `latex-mode` is *another* parent of `LaTeX-mode`? The idea is not to allow multiple inheritance in `define-derived-mode`, but to allow it in `derived-mode-p`. Stefan