From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#68246: 30.0.50; Add non-TS mode as extra parent of TS modes Date: Sat, 6 Jan 2024 05:36:09 +0200 Message-ID: <7575dc49-d08e-4dd9-aa10-3ea61357e350@gutov.dev> References: <83edeww73j.fsf@gnu.org> <83o7dzvrmf.fsf@gnu.org> <82856630-162E-4A90-A74C-568B53A8F2EF@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10481"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 68246@debbugs.gnu.org, Eli Zaretskii , monnier@iro.umontreal.ca To: Yuan Fu , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 06 04:37:12 2024 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 1rLxUl-0002Ys-Bu for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jan 2024 04:37:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLxUZ-0005UY-P3; Fri, 05 Jan 2024 22:36:59 -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 1rLxUY-0005UB-7f for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 22:36:58 -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 1rLxUX-0002Jf-W4 for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 22:36:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLxUc-0000Jt-Jb for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 22:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jan 2024 03:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68246 X-GNU-PR-Package: emacs Original-Received: via spool by 68246-submit@debbugs.gnu.org id=B68246.17045121891177 (code B ref 68246); Sat, 06 Jan 2024 03:37:02 +0000 Original-Received: (at 68246) by debbugs.gnu.org; 6 Jan 2024 03:36:29 +0000 Original-Received: from localhost ([127.0.0.1]:58246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLxU4-0000Iu-OM for submit@debbugs.gnu.org; Fri, 05 Jan 2024 22:36:29 -0500 Original-Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:36221) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLxU2-0000IY-7B for 68246@debbugs.gnu.org; Fri, 05 Jan 2024 22:36:27 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 3FB773200AAA; Fri, 5 Jan 2024 22:36:15 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 05 Jan 2024 22:36:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1704512174; x=1704598574; bh=f3HgSTkNGzycmG1GkjHsBXYdKj3Mcvj+TM2LAjJJQbw=; b= opj4RCAe1f/qbc0b+ereeZel+h/aw16xB4G3ECnmWm7zKyeGj/+9Mrofr1zhZm8M 58kNDiJ2zlYm/P39Qvd6wbJIFT4MIhro0XsfsPWA7QdX/7vlab+BsQvJwaV6Ro6j d95+JH2uxuIAdVcFan73RwTrlabvGCka9KD+5VbhxC1arVLF7KyKt/uQCPbVVthL jzscPacxmujBkRjiOArj9wEImoQ5STajuRjQQF4XcJe7VB6dDaDsM1XvIShU/aGI RTBk/Gyirdfm8fu+cPOTRq9fhgqEKNklYzxVbwVuXGz4j1GmNv6fCm4nHH2qQTm+ O2k/P2Xw1fCY6wzmICeIAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1704512174; x= 1704598574; bh=f3HgSTkNGzycmG1GkjHsBXYdKj3Mcvj+TM2LAjJJQbw=; b=y zUKkFlF6MIaFZhZmV1BKkQU8P9+9SNTg1NYYBuB6MhSA+y31Ju9p95nB6e6bl0o4 DIbKk7CLRzA8qRKXrwKErSYws5pKYDPUjgFSUv5GpHUhTBSJ5dSagxiPiZogWUUR jJJOdqy4z6h4F+EynBsZ0YgnlxwxAHuO3GcCETLiJzTT6dSOKpp7LKbf38XX2o9m r4pm4GIbKbL7Wifc4Ll2NWNcasDp8SaKdH1YiKcN3DfKFPAIqeOs1tiWmiTyHnpj vGEd3E2tLo+YJq75+5MYChXKOz0vP+FgIlHJ/dEbYF2VKkxL/jIZVPsd2iEqCioI xQIWp9aGUmHwCvG6KAYyg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdehtddgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepgeelfeetkefghfdvhfdtgeevveevteetgeetveegtedthefhudekteehffeu keeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jan 2024 22:36:12 -0500 (EST) Content-Language: en-US In-Reply-To: <82856630-162E-4A90-A74C-568B53A8F2EF@gmail.com> 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:277426 Archived-At: On 06/01/2024 05:19, Yuan Fu wrote: > The good thing about derived-mode-add-parents is that it doesn’t need major mode author’s cooperation. Even a normal user can do it themselves. True. > Then there is the problem Eli pointed out, base-mode hooks runs before child major mode body does. It’s probably fine for most of the things, but if you want to change some buffer local variable that the major mode sets, base-mode hook can’t help. (Arguable a niche use-case, but my point is base-mode hooks have their limits.) This is the same for all other case of mode inheritance (e.g. js2-mode inheriting from js-mode, or python-ts-mode inheriting from python-mode). It would be odd if some inheriters would have this inconvenience, and others not. > Obviously derived-mode-add-parents can’t help with hooks. But adding the config to two hooks doesn’t seem to be too bad. Plus I haven’t come up with good solution. So I’m not too eager to solve that inconvenience. I was thinking some "proper" language registry is the way to go. Like a custom structure tracking the correspondence between file names and languages, and a separate association list for lang->major-mode. But it would require more changes indeed. > As for adding xxx-mode to xxx-ts-mode’s parent, I think it’s fine? Like others in the thread, I couldn’t think of a scenarios where this will be problematic. I thought about adding xxx-lang as the parent of both xxx-mode and xxx-ts-mode, but that’s probably not very helpful, since the goal is to make things work for ts-mode without needing to change the existing code, and using xxx-lang still requires modifying existing code. OTOH, the required changes could be made fairly minimal (aside those in the user's config): add a new keyword to define-derived-mode which would add (run-hooks 'xyz-lang-hook) at the end.