From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ikumi Keita Newsgroups: gmane.emacs.bugs Subject: bug#67008: 30.0.50; Multiple major mode parents Date: Sat, 11 Nov 2023 21:21:36 +0900 Message-ID: <51598.1699705296@localhost> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30313"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67008@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 11 13:22:53 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r1n0m-0007dm-58 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Nov 2023 13:22:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1n0K-0005Qt-46; Sat, 11 Nov 2023 07:22:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r1n0I-0005Qe-I4 for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 07:22:22 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1n0I-0004Oj-9V for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 07:22:22 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r1n0w-0007us-II for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 07:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ikumi Keita Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Nov 2023 12:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67008 X-GNU-PR-Package: emacs Original-Received: via spool by 67008-submit@debbugs.gnu.org id=B67008.169970534730385 (code B ref 67008); Sat, 11 Nov 2023 12:23:02 +0000 Original-Received: (at 67008) by debbugs.gnu.org; 11 Nov 2023 12:22:27 +0000 Original-Received: from localhost ([127.0.0.1]:52266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1n0M-0007u0-Ji for submit@debbugs.gnu.org; Sat, 11 Nov 2023 07:22:27 -0500 Original-Received: from smtp1a.inetd.co.jp ([210.129.88.11]:34218) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1n0J-0007tp-Q4 for 67008@debbugs.gnu.org; Sat, 11 Nov 2023 07:22:25 -0500 Original-Received: from localhost (42-144-34-11.rev.home.ne.jp [42.144.34.11]) by smtp1a.inetd.co.jp (Postfix) with ESMTPA id CF8635C; Sat, 11 Nov 2023 21:21:39 +0900 (JST) In-reply-to: Comments: In-reply-to Stefan Monnier message dated "Thu, 09 Nov 2023 00:38:22 -0500." X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.1 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274160 Archived-At: --=-=-= Content-Type: text/plain Hi Stefan, >>>>> Stefan Monnier writes: > I pushed to the branch `feature/derived-mode-add-parents` a bunch of > patches which add support for such limited form of `multiple > inheritance`. I tried the branch with the attached tentative addition to AUCTeX feature/fix-mode-names-overlap branch. I tested two modes, namely latex mode and japanese latex mode, with the second attachment to see whether the directory local variables stored in the .dir-locals.el are reflected or not. For latex mode, it works as expected. Thank you, it is promising. On the contrary, it fails for japanese latex mode with the error: File mode specification error: (error Cycle in the major mode hierarchy: japanese-LaTeX-mode) I think the reason is that AUCTeX has (defalias 'japanese-latex-mode #'japanese-LaTeX-mode) for backward compatibility. AUCTeX major modes are divided into two categories. [a] Modes with former names which are overlapped with built-in tex modes: plain-TeX-mode, LaTeX-mode, docTeX-mode, Texinfo-mode [b] Modes with former names which aren't overlapped with built-in tex modes: ConTeXt-mode, AmSTeX-mode, japanese-plain-TeX-mode, japanese-LaTeX-mode For category [b], AUCTeX feature branch has defalias'es similar to the above example for compatibility with files which have "%%% mode:" tag with former mode name such as "japanese-latex". This new feature of multiple inheritance would work well for category [a], which retains backward compatibility by `major-mode-remap-alist' and doesn't use defalias. However, it doesn't work for category [b]. It seems to me very difficult to arrange the proposed feature to cover category [b], looking at its way to handle mode alias. So I think AUCTeX feature branch must rely on some very ugly hack to be able to pick up directory local variable entry with former mode name. :-( (Or AUCTeX should entirely give up such compatibility with directory local variables for category [b].) Best regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=patch Content-Description: Use multiple inheritance diff --git a/latex.el b/latex.el index e9b08cc1..0551c320 100644 --- a/latex.el +++ b/latex.el @@ -8087,6 +8087,8 @@ Run after mode hooks and file local variables application." ;;;###autoload (put 'LaTeX-mode 'auctex-function-definition (symbol-function 'LaTeX-mode)) +(TeX-derived-mode-add-parents 'LaTeX-mode '(latex-mode)) + (with-eval-after-load 'semantic/symref/grep (push '(docTeX-mode "*.dtx") semantic-symref-filepattern-alist)) diff --git a/tex-jp.el b/tex-jp.el index ff562e22..36a39ec1 100644 --- a/tex-jp.el +++ b/tex-jp.el @@ -471,6 +471,9 @@ Now `japanese-latex-mode-initialization' is no-op. Don't use it.")) ;;;###autoload (defalias 'japanese-latex-mode #'japanese-LaTeX-mode) +(TeX-derived-mode-add-parents 'japanese-LaTeX-mode + '(japanese-latex-mode latex-mode)) + (defun japanese-LaTeX-guess-engine () "Guess Japanese TeX engine and set it to `TeX-engine'. Document class and its option are taken into account. Do not diff --git a/tex.el b/tex.el index d4fded73..f67e1e31 100644 --- a/tex.el +++ b/tex.el @@ -3875,6 +3875,15 @@ Run after mode hooks and file local variables application." ;;;###autoload (put 'TeX-mode 'auctex-function-definition (symbol-function 'TeX-mode)) +;; COMPATIBILITY for Emacs<30 +(unless (fboundp 'derived-mode-add-parents) + (advice-add 'derived-mode-p :after-until #'TeX--compat-derived-mode-p) + (defun TeX--compat-derived-mode-p (&rest modes) + (let ((extra-parents (get major-mode 'derived-mode-extra-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. @@ -4828,6 +4837,16 @@ Also see `ignore'. This is a compatibility function for Emacs versions prior to v.28." t)) +;; COMPATIBILITY for Emacs<30 +(if (fboundp 'derived-mode-add-parents) + (defalias 'TeX-derived-mode-add-parents #'derived-mode-add-parents) + ;; Adapted copy of `derived-mode-add-parents'. + (defun TeX-derived-mode-add-parents (mode extra-parents) + "Add EXTRA-PARENTS to the parents of MODE. +Declares the parents of MODE to be its main parent (as defined +in `define-derived-mode') plus EXTRA-PARENTS." + (put mode 'derived-mode-extra-parents extra-parents))) + (defun TeX-match-buffer (n) "Return the substring corresponding to the N'th match. See `match-data' for details." --=-=-= Content-Type: application/gzip Content-Disposition: attachment; filename=dirlocal.tar.gz Content-Transfer-Encoding: base64 Content-Description: Test suit H4sICPBpT2UCA2RpcmxvY2FsLnRhcgDtmV1vmzAUhnPNr7AqRSKTkmGwQQra1T6uellNk5ZeGHA2 NsAVOFqzKPvtsw1xoEtTaSsJzXwUCXz8wUHO49f4JGmZsZhkr0f9meM4QYCBuMIAw/ZVG4AIu57v owBi4EAPumgE8OgEtqo4KUUo32nKyZF2T9U376GvL8SS3fzPxN1U3VYzmj33/PsIPT7/2Hf1/GPf E/OPMQ5GwDHz37uFYQjepSWNOSvX4FrOP/hIypREGa0sWfuBlSBnJQVpsWRlTnjKClBRCmzpAFc2 zUlcTVqj6P5XE8uyQwvYGeH0fpqzhFoA2CSKwQxk7ActJ7K8ZEyUobq/X/+UdbL9RDjsa3JDP+me da3yydayQcLi9th1i9qpBvhG7khBKzrtxrBz64ftA/G6/Q5F0K1s9UWqb8wKMSTXnXYvKOom1kD5 F5MCZyLqftb/o/xDB2r+fewL/hFCvuH/FGaNx+OH2M+VU/555zUcqqwoIBWn5Rxw5XlfJHNrZOwl m+Y/7gn+hn//CP+e0HzBP5Ty7wVI8u8EyPB/ClvI1+dSrSxrUQkBF+r+akMI2cryKmpcmyiKdp69 M45j5ZRDNL7PPOUZfbO5oRVPiy9g8ZYVYuXg21shhDdf0wqIX74GmwXNwTItK77VbTZbKdyrnBZ8 Jkdld82gdaEO8on1qpFes2L9hf57Per/Mf4h3O///cBT+o89w/8Q9L+7fTZYXTL/7rn4b+//fVTz 7xj+h8C/+sA12P8X/KMB6H/geOb7f4j6bxaCy+a/e/7/65Tnf0L11fd/4ArwXSjP/wNk9v8nsf7P ///l+F88vpMBEOWHSQDlqodwJ8+aEAj/PO4/mCqQQR7MFoTh4wmDVthnzRlo/pMkgWfb/7uafy9w av13Df9D0P8aHKP7F6//gn93CPzv8n8m/z8U/s2+35gxY8Yu0H4DYLQStAAqAAA= --=-=-=--