From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68246: 30.0.50; Add non-TS mode as extra parent of TS modes Date: Fri, 05 Jan 2024 23:08:40 -0500 Message-ID: References: <83edeww73j.fsf@gnu.org> <83o7dzvrmf.fsf@gnu.org> <838r53vlo5.fsf@gnu.org> <831qavvcbo.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33821"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68246@debbugs.gnu.org, Eli Zaretskii , casouri@gmail.com To: =?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 05:09:13 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 1rLxzl-0008ae-2W for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jan 2024 05:09:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLxzW-00015x-Nv; Fri, 05 Jan 2024 23:08:58 -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 1rLxzV-00015m-7q for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 23:08:57 -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 1rLxzU-0004FO-Vi for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 23:08:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLxzZ-0006Ul-KA for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 23:09:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jan 2024 04:09:01 +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.170451413624956 (code B ref 68246); Sat, 06 Jan 2024 04:09:01 +0000 Original-Received: (at 68246) by debbugs.gnu.org; 6 Jan 2024 04:08:56 +0000 Original-Received: from localhost ([127.0.0.1]:58267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLxzU-0006US-6i for submit@debbugs.gnu.org; Fri, 05 Jan 2024 23:08:56 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:59998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLxzR-0006UA-Hs for 68246@debbugs.gnu.org; Fri, 05 Jan 2024 23:08:54 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 63CF180A64; Fri, 5 Jan 2024 23:08:43 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1704514122; bh=MqB3zMAktUgq3tQ05DFlqxQkkiaqEA2g27MszrBBIjw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mOFOd3K3n2C22BbNxM6zk+LnxR7mGKRr46Zhio/y4v3tALFMCitEpikmk7WznIkh5 I/VXf4//s2cJdb4YJRP5loWdMgUwjcdBExJjkYDvSfVjuPP58qovl59FTFTckkOna2 3cb4QVW3o0BlUHE2LyFiQyUkWOAK7ksrXOA6UlC8SoCa2SG8p8p3cz1wZirUIJwXMD 8R1ZK6Ba4j4Aob2El0shtywuCZfxcPrqkrTXbvleeinoeKS7lqfbzGq1Nw9aE1NZcK ROd5vQhiwDTatd0PGS4NAPeA/2qqiOmL+XT2Wm6OrSmNmMouaCIWzaVdrYfJv7ixhI Y3mezqQo2CuoA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 181A3802DA; Fri, 5 Jan 2024 23:08:42 -0500 (EST) Original-Received: from milanesa (65-110-221-238.cpe.pppoe.ca [65.110.221.238]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D154C12023B; Fri, 5 Jan 2024 23:08:41 -0500 (EST) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sat, 6 Jan 2024 00:16:02 +0000") 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:277427 Archived-At: > OK, so "kind". So you seem to want to FOO-mode designates a family > of modes for FOO. That's reasonable but it has the confusing property > that the name of the family coincides with the name of one of the > members of the family. It's actually very common. Take "Lisp" as an example. Similarly, `tex-mode` is both the parent of several derived modes and the entry point that dispatches to the appropriate derived mode. > Using inheritance for that just seems a bit off, like a hack. `derived-mode-add-parents` is not inheritance: there's no reuse of code involved (tho it doesn't preclude it, of course). > Really what we wanted is a new variable called 'mode-family' > and test against that. I don't think that's necessary. This is a common programming design decision: should we have different "types" for the various stages of a pipeline, or is it preferable to keep the same type across various stages? When the stages of the pipeline often do nothing at all, it can be a good choice to keep the type unchanged. E.g. in Lisp, macroexpansion returns something of the same "type" as its input: it's OK to pass the output of `macroexpand(-all)` back to `macroexpand(-all)`. Scheme made a different design decision on this one (for hygiene reasons). Other example: keys as they go through `keyboard-coding-system`, `input-decode-map`, `function-key-map`, `key-translation-map`. Here we decided to keep the type the same. > In Yasnippet, if I remember correctly (it was a long time ago), the > snippet directory could either be renamed foo-base-mode or something > in a .yas-parents inside that directory can be added containing > "foo-base-mode". AFAIK adding a `.yas-parent` containing "FOO-base-mode" just means "oh, and also include the snippets defined for FOO-base-mode", which is redundant with the fact that `FOO-ts-mode` already derived from `FOO-base-mode`. So that won't do it. We'd need (like I recently mentioned in https://github.com/joaotavora/yasnippet/issues/1169) something like a new `.yas-children` (or `.yas-siblings`) which tells YASnippet to use the current directory also for those additional modes. >> That's why in my patch I add `python-mode` as an extra parent of >> `python-ts-mode` even though they both share `python-base-mode` as >> their parent. > > Right, that's what sounds hacky to me. They're siblings, but now > one also is the parent of the other. Maybe it works, but is > definitely odd. `python-mode` from `python.el`, `python-mode` from `python-mode.el`, and `python-ts-mode`, are three implementation of the `python-mode` functionality, yes. The fact that we use the same namespace for actual major modes and for conceptual functionalities saves us from having to do: (derived-mode-add-parents 'python-mode '(python-mode)) :-) The same happens with Debian package names and Debian package features: package `emacs` implicitly provides the feature `emacs`. > That said, if it works, I'm not really opposed to it. What > other packages do you know like Eglot and Yasnippet which use > major-mode in this way. I'm not sure which modes might be affected (beside Eglot, YASnippet, and CEDET). I presume many others outside of Emacs are, since `derived-mode-p` is used very often out there. Stefan