From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Make all tree-sitter modes optional Date: Tue, 17 Jan 2023 19:30:16 +0200 Organization: LINKOV.NET Message-ID: <868ri140sr.fsf@mail.linkov.net> References: <84973.1672843723@hassadar.pretzelnet.org> <83wn62xi3k.fsf@gnu.org> <83o7rexe2n.fsf@gnu.org> <83h6x5xym7.fsf@gnu.org> <83h6wr6gmz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39015"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: casouri@gmail.com, monnier@iro.umontreal.ca, larsi@gnus.org, theo@thornhill.no, jostein@secure.kjonigsen.net, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 17 18:35:12 2023 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 1pHprb-0009uE-HX for ged-emacs-devel@m.gmane-mx.org; Tue, 17 Jan 2023 18:35:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHprL-0005fB-5L; Tue, 17 Jan 2023 12:34:55 -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 1pHprB-0005dQ-Oi for emacs-devel@gnu.org; Tue, 17 Jan 2023 12:34:53 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHpr6-0008Fi-9a; Tue, 17 Jan 2023 12:34:45 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id E9DD01C0009; Tue, 17 Jan 2023 17:34:32 +0000 (UTC) In-Reply-To: <83h6wr6gmz.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 15 Jan 2023 16:01:40 +0200") Received-SPF: pass client-ip=217.70.183.197; envelope-from=juri@linkov.net; helo=relay5-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:302484 Archived-At: >> This came out of the discussion in bug#60559 and other related discussions > > I addressed that in the discussion on emacs-devel, see > https://lists.gnu.org/archive/html/emacs-devel/2023-01/msg00278.html > (I suggest to discuss this there, not here.) Ok, moving to emacs-devel from bug#60176. >> >> >> >> (defcustom treesit-enable-modes nil >> >> >> >> :type '(repeat >> >> >> >> (choice (function-item c-ts-mode) >> >> >> >> (function-item c++-ts-mode) >> >> >> >> (function-item c-or-c++-ts-mode) >> >> >> >> ... >> >> >> >> ('c-ts-mode >> >> >> >> (when (treesit-ready-p 'c t) >> >> >> >> (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) >> >> >> > >> >> >> > And this bit is completely unacceptable, from where I stand: it >> >> >> > basically means that the user activated a certain major mode he/she >> >> >> > wanted to use, but the result could be that an entirely different mode >> >> >> > was silently activated instead. What kind of UX is that, and for a >> >> >> > shining new feature at that?? >> >> >> >> >> >> It could update 'auto-mode-alist' instead of 'major-mode-remap-alist'. >> >> >> From the user's point of view this would be more manageable than >> >> >> what you proposed on emacs-devel with some obscure logic of activating >> >> >> ts modes when the package is loaded or when the mode is enabled first time. >> >> > >> >> > I don't understand the "obscure" part: the logic was exactly as above: >> >> > test that treesit-ready-p returns non-nil for the mode's language. >> >> > >> >> > Other than that, my proposal does exactly what you say here: it >> >> > updates auto-mode-alist. So it sounds like we are in violent agreement. >> >> >> >> The difference is that an explicit option is more controllable by the user. >> >> When the user needs to use some ts-mode then it's easier just to customize >> >> the option instead of tweaking 'auto-mode-alist' when the user want to >> >> start using that mode without first loading its package or calling it >> >> the first time that modifies 'auto-mode-alist' as the side effect. >> > >> > With the changes I proposed, there's no need to tweak >> > auto-mode-alist. A simple load or require of the mode will install >> > the mode in auto-mode-alist. What can be easier and simpler? >> >> This doesn't address the problems mentioned above and below. > > Which parts "above" were not addressed? > > As for below: > >> >> Or when the user wants to remove the mode from 'auto-mode-alist' after >> >> accidentally loading the corresponding ts package. It fails for many scenarios: 1. The user needs to use e.g. js-ts-mode. Your patch requires that users first visit a js file in js-mode, then they need to type M-x js-ts-mode RET then for the rest of the session they can use js-ts-mode. But for a new session they need to repeat the same again. 2. For other ts modes adding something like (require 'c-ts-mode) to the user's init file is not a clean way to enable such modes. Also takes additional space even when users don't intend to use them in the current session, thus negating the benefits of autoloading. 3. There is no simple way to disable a ts mode after loading the corresponding ts file.