From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Turning on/off tree-sitter modes Date: Sun, 24 Nov 2024 10:06:33 +0200 Message-ID: <86plmljbsm.fsf@gnu.org> References: <8634jnt5e3.fsf@gnu.org> <4864104c-cb23-4356-ad89-2fea111db66c@gutov.dev> <86ttc2rrh8.fsf@gnu.org> <86cyipsp94.fsf@gnu.org> <9cd17f8b-f88c-49f6-9024-0b6d297e18ac@gutov.dev> <867c8xsmri.fsf@gnu.org> <566ac897-ea5e-4141-bcb3-306d43c9118a@gutov.dev> <865xohrvfa.fsf@gnu.org> <86wmgwnyle.fsf@gnu.org> <178dfc7f-bc2d-4e3b-8417-a616ccc0eef3@gutov.dev> <86v7wgnxlz.fsf@gnu.org> <01d83ec8-c02b-4806-8764-38dc89a89125@gutov.dev> <86ttbzojho.fsf@gnu.org> <930f5c8e-1481-43a5-8f1d-2c13a98df74f@gutov.dev> <86r072krq5.fsf@gnu.org> <8b907a41-aa08-4b61-bced-7d4d3fcef4b2@gutov.dev> <87frnhsvp3.fsf@mail.linkov.net> <0d1e2770-0889-4862-8105-8a5f4631b11c@gutov.dev> <87ed31gku5.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3916"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, johan.myreen@gmail.com, emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 24 09:07:37 2024 Return-path: Envelope-to: ged-emacs-devel@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 1tF7ea-0000qR-Cv for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Nov 2024 09:07:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tF7dr-0004Ss-3m; Sun, 24 Nov 2024 03:06:51 -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 1tF7dq-0004SY-0P for emacs-devel@gnu.org; Sun, 24 Nov 2024 03:06:50 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tF7do-000415-TP; Sun, 24 Nov 2024 03:06:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=rOujOLrTa6oBgT8hF3oZKirJvxsVc3j/sUy0yv1LJPA=; b=jpkXjcY//NNc YPHmPhLbDv5EaSSCxeCurd+D5Um2nJxYJ6pBd7wg7ycu9kelEl0bcIAvewnUsuRo8eR8Qfx7l6OSd efHA6iI8xS7Nsb3Kb2D7RPydqMkbMlCx8k2JNOmPOEjma5t2fHcejitcxJJwrXmmN0dypUe80zQc/ BmFHSSTju00q+31BzxHjsVrYJ5DGWYt5H778QYL9JiLfBVeT6U5acSgP3DFyCHk2PFP4yskT5xIye E6TJZdbLcuqqN+A86hthbr6pCFMChRfpsbBlDskoiF3JwyOjQWgOdGniWsCA5lY9/1j/YcSKPnQ+o mNePNe77yJLvUb3tzlB0ZQ==; In-Reply-To: <87ed31gku5.fsf@mail.linkov.net> (message from Juri Linkov on Sun, 24 Nov 2024 09:29:30 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325649 Archived-At: > From: Juri Linkov > Cc: Eli Zaretskii , johan.myreen@gmail.com, emacs-devel@gnu.org > Date: Sun, 24 Nov 2024 09:29:30 +0200 > > > - Where does the second argument come from? Do we read the first argument > > from the user as well? > > The answer depends on the purpose of the 'treesit-add-enabled-mode' > command that I still don't understand. Is it supposed to be used > in user configs as > > (treesit-add-enabled-mode 'ruby-mode 'ruby-ts-mode) > > to be another way to do the same as > > (add-to-list 'major-mode-remap-alist '(ruby-mode . ruby-ts-mode)) > > Or maybe we want to simplify this setting. Then we need > not a command, but a new option 'treesit-enable-modes': > > (add-to-list 'treesit-enable-modes 'ruby-ts-mode) When you suggest such ways of implementing user preferences, please always consider two factors: (a) the complexity from the users' POV, and (b) the way to undo the preference. Using alists or lists for customization requires that users understand the basics of lists in Emacs, and have good command of the relevant primitives. As the experience of default-frame-alist suggests, that is not a trivial thing to master (IMO, default-frame-alist survives only because most users don't customize it directly, but via higher-level APIs like set-frame-font etc.). Undoing the preferences is also not easy when lists/alists are used, because there could be more than one element in the list, and it's easy to forget to remove all of them. > > If we want to have an option like treesit-enable-modes (allowing the user > > to turn on all built-in ts modes), it doesn't seem like we could do that > > without maintaining this database in some form. Only for built-in modes, > > though. > > Actually, there is already such a database in files.el: > the default value of 'auto-mode-alist' is the database > of file associations. What we have in files.el is incomplete. Some modes modify auto-mode-alist and some have autoload cookies which do that. > So for ts-modes that don't have a corresponding non-ts mode in core > we need to add their file associations to 'auto-mode-alist'. > However, not directly, but via a non-ts mode. So, for example, > 'auto-mode-alist' should contain '("\\.go\\'" . go-mode)', > then 'major-mode-remap-defaults' should contain a mapping > from 'go-mode' to 'go-ts-mode'. This is something we need to agree to first. Keep in mind that for Alan Mackenzie this was the proverbial straw that broke the camel's back, so maybe there are others who think that way. > This will help to remove the requirement to load a ts-mode file > to change file associations, that currently causes problems > such as: Removing the effect of loading the package should be the main outcome of whatever we decide to do here, yes. > > Not 100% sure though - because that plan would delete the vast majority of > > the uses of the latter from the core (except for TeX's mappings, it seems). > > Agreed, 'major-mode-remap-defaults' could be removed when loading a ts-mode file > will not modify file associations anymore. I don't think we can or should remove it, because it's useful for the cases like the TeX/LaTeX mode (for which we set it up now by default). I do agree that modes should probably not modify major-mode-remap-defaults, but I'm not so sure about the commands we are discussing here -- I see no problem for them to modify that alist, since that will leave the last word to the users, via major-mode-remap-alist.