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.devel Subject: Re: An anonymous IRC user's opinion Date: Sun, 3 Nov 2024 21:24:27 +0200 Message-ID: References: <87plodsjsd.fsf@web.de> <865xq14dwp.fsf@gnu.org> <343c4d04-af53-4da2-9d1c-c616c74821e1@gutov.dev> <86plo8369c.fsf@gnu.org> <63edeeea-1f24-4d3b-abc8-b96b164942e4@gutov.dev> <8634l1zsej.fsf@gnu.org> <9a8b97f8-def3-43ce-b71b-1f09bb05afd4@gutov.dev> <86cyk4vcld.fsf@gnu.org> <86ttdgthg2.fsf@gnu.org> <86ed4kt2ws.fsf@gnu.org> <8e30fb5c-8e1b-4f73-98eb-50c5c396efb0@gutov.dev> <86ldyqsrax.fsf@gnu.org> <10864c02-4bfd-41c3-bb45-6fe1155f9676@gutov.dev> <867ca9shcw.fsf@gnu.org> <7cb15f5c-efd0-4516-8190-a53c0d958eb6@gutov.dev> <86ses8x1po.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27274"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: johan.myreen@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 03 20:25:34 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 1t7gE9-0006vJ-GA for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Nov 2024 20:25:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7gDG-0006fQ-4Q; Sun, 03 Nov 2024 14:24:38 -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 1t7gDE-0006fF-J4 for emacs-devel@gnu.org; Sun, 03 Nov 2024 14:24:36 -0500 Original-Received: from fhigh-b7-smtp.messagingengine.com ([202.12.124.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t7gDC-0004Cl-3g; Sun, 03 Nov 2024 14:24:36 -0500 Original-Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 713662540106; Sun, 3 Nov 2024 14:24:31 -0500 (EST) Original-Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Sun, 03 Nov 2024 14:24:31 -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=fm2; t=1730661871; x=1730748271; bh=sewT6iAtwuD5gfIN/H4872veUtLr2+MHKXGResBbSMU=; b= nyPsGSJOag4hZnhcC4FzK1/z+JPhqJ8Ku+faNbp+wZk+LDngrXqPmllHSeXAdvF1 1gHYHLpuggQxu4pPdxMOEPxgObj0q/guG/IpqjkERDs8uSKKlW/MUsIspFoEMGdI 8+OzRCtAlsOaZlyKrzdEfUBrSDwDsscV/mQZWWk4zgKSEelBT5c5q9BvseosQpjc wBD0w+/GG68TG3HPXTjA5DcCPeg7gr4y/E7lTiGZbVC4mcS3XEPrryjDLYWQqOMx 0GXFXf/mWHGPUMfTlnaam7ijXnlbtEUIrMqHtTzbG+KoiWxf3pLRaw2eVDp5odd1 gFXS6HLrqw9fXlUMJBe8+Q== 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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1730661871; x= 1730748271; bh=sewT6iAtwuD5gfIN/H4872veUtLr2+MHKXGResBbSMU=; b=U VaRpTe0waSwj+U8VzobZwvyAdO4ZUtIVIwvF0NXp53/PC4dQmStKA7Afvt/Iv62y Owhy62BxEsblXX4QuLxUYBHNfrygUZOlgIQEblAA7tJWwVKNFM0oVrMK7C2MjFfu YtaOMWnulfE1xp7vLFESxJcy9wILgAGEOfeyfX/8uQNHOd1TamSc5K9uBAhlxY6l oiVcmqOqh7cKJszx9QeD/wHWhMR5rQqVjnpbsJ3ji8NCwjLer/gCFmMZRC14qfsp VfKp/BhSphiygXfdlyStcoSpPSRXV/mM7lORuUV1vmoe3lf4qHoyPAnC1fE1faY+ tmHKS+9cAY9kX0rkE5uAw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdelgedguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddv jeenucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrd guvghvqeenucggtffrrghtthgvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeu fedtvddtveefhfdvveegudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthht ohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvghlihiisehgnhhurdhorh hgpdhrtghpthhtohepjhhohhgrnhdrmhihrhgvvghnsehgmhgrihhlrdgtohhmpdhrtghp thhtohepvghmrggtshdquggvvhgvlhesghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Nov 2024 14:24:29 -0500 (EST) Content-Language: en-US In-Reply-To: <86ses8x1po.fsf@gnu.org> Received-SPF: pass client-ip=202.12.124.158; envelope-from=dmitry@gutov.dev; helo=fhigh-b7-smtp.messagingengine.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_SBL_A=0.1 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:325067 Archived-At: On 03/11/2024 08:37, Eli Zaretskii wrote: >> Date: Sun, 3 Nov 2024 05:10:26 +0200 >> Cc: johan.myreen@gmail.com, emacs-devel@gnu.org >> From: Dmitry Gutov >> >> I could mention the problems (most of them known), but perhaps we should >> discuss a possible fix instead. >> >> Here's a patch along the lines described in this thread. >> >> Additionally, as mentioned, we could drop some modes from the default >> set (removing toml-ts-mode and maybe dockerfile-ts-mode as well). > > Can we please talk in English, at least in addition to posting the > code and hoping that it explains your ideas clearly enough? Because I > really don't understand the idea. Apologies if the idea is lost in > this discussion that spans many moons. Sure. The general idea is this: As long as Emacs is configured with support for tree-sitter, we enable file associations (using auto-mode-alist) for a certain set of tree-sitter based modes. Chefly those that don't have existing "traditional" modes, but that's debatable. For others (modes that are not enabled by default), we document the way to enable them somewhere - in packages' Commentary, for example. The traditional way to do that has been with us for decades (people need to add an auto-mode-alist entry in their config script) - and now we also have a way to do that using major-mode-remap-alist. Either way, adding a line or two to their .emacs. The overall effect is that the file associations become stable again: set during Emacs's startup and not changing when a package gets loaded, or a major mode function is called. > Is the idea to expect the users to have all the grammar libraries > installed when they use an Emacs which was built with Tree-Sitter? In a way yes, but also no, because they are only needed when the corresponding file is visited. And only for modes that we decide to enable by default. > Because your code seems to only test the latter, or so it seems. If > so, I don't think it's an idea to which I'd agree. E.g., imagine a > user who installed Emacs from some distro which decided to build with > Tree-Sitter, but doesn't provide all the grammar libraries we require, > for whatever reasons. Then, when visiting let's say a Go file (or Rust, or TypeScript) they will right away be greeted by a warning that the grammar is not available, search the docs how to deal with that, and hopefully install it somehow (maybe using M-x treesit-install-language-grammar). If they don't, perhaps they'll disable the file association manually - or live with the warning when visiting such files. Is that better or worse than what we have now? For users that hoped to use tree-sitter modes, seems strictly better. For others, might add an inconvenience - but the amount depends on the set of ts modes that we ultimately decide to enable. To remind, the bug report that made us change our plan previously was about a scenario where the user a) configured their Emacs to build without tree-sitter explicitly, b) visited a .toml file (a config file - where the annoyance of installing the grammar is likely not paid off with the features it provides). > A minor nit: I don't see how c-ts-mode will be invoked under your > proposal. What did I miss? You mean how it will be enabled globally, right? Not just invoked. c-ts-mode has instructions in its Commentary, which currently has 3 options. The patch removes one of them, leaving these two: ;; - Add one or mode of the following to your init file: ;; ;; (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)) ... and ;; - Customize 'auto-mode-alist' to turn one or more of the modes ;; automatically. For example: ;; ;; (add-to-list 'auto-mode-alist ;; '("\\(\\.ii\\|\\.\\(CC?\\|HH?\\)\\|\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\|\\.\\(cc\\|hh\\)\\)\\'" ;; . c++-ts-mode)) BTW, I missed this paragraph after, it will need to be removed too I guess (or limited to just the first sentence): ;; You can also turn on these modes manually in a buffer. Doing so ;; will set up Emacs to use the C/C++ modes defined here for other ;; files, provided that you have the corresponding parser grammar ;; libraries installed. (Because 'M-x c-ts-mode' won't alter file associations for the remainder of the session.) I recommend the major-mode-remap-alist way, personally.