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#61211: 28.2; Feature request; facility for dispatch type major mode Date: Thu, 11 May 2023 21:23:26 +0900 Message-ID: <95920.1683807806@localhost> References: <13351.1675254487@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17643"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61211@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 11 14:24:22 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 1px5LH-0004CO-AB for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 May 2023 14:24:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1px5L3-0001lO-90; Thu, 11 May 2023 08:24:05 -0400 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 1px5L0-0001l1-Pd for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 08:24:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1px5L0-00062d-Hb for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 08:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1px5L0-0003yA-22 for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 08:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ikumi Keita Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 May 2023 12:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61211 X-GNU-PR-Package: emacs Original-Received: via spool by 61211-submit@debbugs.gnu.org id=B61211.168380781515224 (code B ref 61211); Thu, 11 May 2023 12:24:02 +0000 Original-Received: (at 61211) by debbugs.gnu.org; 11 May 2023 12:23:35 +0000 Original-Received: from localhost ([127.0.0.1]:49946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1px5KZ-0003xT-0E for submit@debbugs.gnu.org; Thu, 11 May 2023 08:23:35 -0400 Original-Received: from smtp1a.inetd.co.jp ([210.129.88.11]:53970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1px5KV-0003xJ-Oq for 61211@debbugs.gnu.org; Thu, 11 May 2023 08:23:33 -0400 Original-Received: from localhost (42-144-46-173.rev.home.ne.jp [42.144.46.173]) by smtp1a.inetd.co.jp (Postfix) with ESMTPA id 29C235F; Thu, 11 May 2023 21:23:29 +0900 (JST) In-reply-to: Comments: In-reply-to Stefan Monnier message dated "Tue, 09 May 2023 11:21:20 -0400." X-Mailer: MH-E 8.6+git; nmh 1.7.1; GNU Emacs 28.2 Content-ID: <95919.1683807806.1@localhost> 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:261565 Archived-At: >>>>> Stefan Monnier writes: >> Note that it isn't enough to define them like >> (define-derived-mode japanese-latex-mode latex-mode "LaTeX" >> ... >> (setq major-mode 'latex-mode) >> ...) > IOW what are the advantages/disadvantages of using (setq major-mode > 'latex-mode) above? The rest of the codes are written without considering japanese-* variants. For example there are codes like (if (eq major-mode 'LaTeX-mode) ...) (if (memq major-mode (nth 4 TeX-command-list)) ...) (assq major-mode ALIST-WITHOUT-JAPANESE-VARIANTS) Of course, we can "fix" these codes to cover japanese-* variants like (if (memq major-mode '(LaTeX-mode japanese-LaTeX-mode) ...)) (let ((mode (if (string-prefix-p (symbol-name major-mode) "japanese-") (intern (substring 9 major-mode)) major-mode))) (memq mode (nth 4 TeX-command-list)) ...) (let ((mode (if (string-prefix-p (symbol-name major-mode) "japanese-") (intern (substring 9 major-mode)) major-mode))) (assq mode ALIST-WITHOUT-JAPANESE-VARIANTS)) However, such treatments don't look good to me. It is true that we could make wrapper function/macro to reduce such complexity. However, practically all third party packages developed by non-Japanese wouldn't notice the necesity of such wrapper for the first place and write simply like (if (eq major-mode 'LaTeX-mode) ...) ; such codes, incompatible with japanse-LaTeX-mode, will continue to spawn on ELPA, MELPA, stackexchange etc. (or even in AUCTeX itself after I cease to participate develop, unless a new Japanese developer joins.) > Also, this seems different from the case of dispatch functions like > `tex--guess-mode' and `TeX-tex-mode' since these may end up choosing > `latex-mode` but they're definitely not "child" of `latex-mode`. Yes, not the same, only a similarity. >> because it doesn't respond to directory local variable entry of the form >> ((japanese-latex-mode >> ...)) >> in that case. > If we make `japanese-latex-mode` a proper child mode, then this problem > disappears, right? Yes, restricting the scope only within the availability of directory local variables. > I'm also thinking that maybe `set-auto-mode` should remember the name > of the "mode function" it called so we could consult this (in addition > to the value of `major-mode`) when applying directory-local vars? If that's possible, it will be a solution, I think. Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine