>From 248a8ae6a3ba7c29555c97eca2b431fcbba05238 Mon Sep 17 00:00:00 2001 From: Ikumi Keita Date: Thu, 9 Nov 2023 15:01:37 +0900 Subject: [PATCH] Enable dir local vars for former mode names Since major mode names have changed, Emacs doesn't apply directory local variables prepared for former mode names. We need somewhat dirty hack to work around that problem. * tex.el (TeX--extra-mode-parents): New constant alist to indicate pseudo mode names which should be regarded as parent modes for the respective major mode. (TeX--compat-derived-mode-p): New function to advice `derived-mode-p'. Regard the pseudo modes indicated by `TeX--extra-mode-parents' as parent modes as well. --- tex.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tex.el b/tex.el index d4fded73..e0e91f5f 100644 --- a/tex.el +++ b/tex.el @@ -3875,6 +3875,35 @@ Run after mode hooks and file local variables application." ;;;###autoload (put 'TeX-mode 'auctex-function-definition (symbol-function 'TeX-mode)) +;; Compatibility hack to enable directory local variables for modes +;; with former names. It is expected that we can remove plain-TeX, +;; LaTeX, docTeX and TeXinfo modes, which once had overlapped names +;; with built-in modes, from this list for Emacs 30, but the others +;; would still need this. +(defconst TeX--extra-mode-parents + '((plain-TeX-mode plain-tex-mode) + (LaTeX-mode latex-mode) + ;; XXX: Should we add latex-mode to pseudo-parent of docTeX-mode? + ;; It's reasonable, but is not compatible with former AUCTeX + ;; behavior. + (docTeX-mode doctex-mode) + (Texinfo-mode texinfo-mode) + (ConTeXt-mode context-mode) + (AmSTeX-mode ams-tex-mode) + (japanese-plain-TeX-mode japanese-plain-tex-mode plain-tex-mode) + (japanese-LaTeX-mode japanese-latex-mode latex-mode)) + "Alist of major modes and list of pseudo-parent modes. +For example, `LaTeX-mode' is regarded as a child of `latex-mode'. +Similarly, `japanese-LaTeX-mode' is regarded as a child of +both `japanese-latex-mode' and `latex-mode'.") + +(advice-add 'derived-mode-p :after-until #'TeX--compat-derived-mode-p) +(defun TeX--compat-derived-mode-p (&rest modes) + (let ((extra-parents (assq major-mode TeX--extra-mode-parents))) + (and extra-parents + (cl-loop for parent in extra-parents + thereis (memq parent modes))))) + ;;; Hilighting ;; FIXME: It's likely that `hilit-patterns-alist' is much obsolete. -- 2.42.0