From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Turning on/off tree-sitter modes Date: Sun, 01 Dec 2024 21:58:37 -0500 Message-ID: References: <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> <27a62624-387c-4233-b995-170270e26efd@gutov.dev> <84e8cd47-6606-457e-b122-a639227f67a1@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29134"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 02 03:59: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 1tHweq-0007SW-JM for ged-emacs-devel@m.gmane-mx.org; Mon, 02 Dec 2024 03:59:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHwe5-0001Eh-JP; Sun, 01 Dec 2024 21:58:45 -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 1tHwe3-0001EQ-ML for emacs-devel@gnu.org; Sun, 01 Dec 2024 21:58:43 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHwe1-000394-La for emacs-devel@gnu.org; Sun, 01 Dec 2024 21:58:43 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0BD4D806DE; Sun, 1 Dec 2024 21:58:39 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1733108318; bh=HmlgEAnwLIh4uYCkDXw6faOL5pEWVoPx/FnvFq5yePU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=cdSpMhGyDmGHmRe3k+Sg+hVkjqpj6c2uSIOnQb3u9+ZvzfUl5hf3dWPIPvoxvICCF S4SZJAQ/AcoMd1iEPGGONHaIwG7NM9W7mgwmnVey/A+Tr6z/XBObMonmOQD67nbZUF JD952UcZAiE3fWJFZiLPs3EbSX0K2l5qBLrMXdAHpyQm2hyaxKrxZhZ6QaFAQo3yE2 x9SA5f/XTFTwnOGQMWgM5QUSvJQcZ4jy4Gv8D/sIaE26UohlXRu0GMEspPIDfJ0IBx myl8elchPqkfyF18R6+mZ8hLa9YjAWcZK6j8ZEplpor4sOyJn1+PEielzh5sjc/W66 RX183dYJtzPXg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 19D9880468; Sun, 1 Dec 2024 21:58:38 -0500 (EST) Original-Received: from alfajor (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E209D12023D; Sun, 1 Dec 2024 21:58:37 -0500 (EST) In-Reply-To: <84e8cd47-6606-457e-b122-a639227f67a1@gutov.dev> (Dmitry Gutov's message of "Mon, 2 Dec 2024 04:04:49 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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:325935 Archived-At: >> For the init file, we have things like >> (add-to-list 'major-mode-remap-alist '(foo-mode . bar-mode)) >> so I don't see any need for anything new. > We might need to solve this for go-ts-mode and etc having no "original" to > remap from, though. I think we first need to think about what it is the user needs to do there and what Emacs should do. AFAICT with our current code, emacs -Q foo.go will never open that mode is the intended mode even if the Go grammar is installed, so I think we should first fix that and only once that fixed we can start thinking about what the user may want to do to choose a specific mode. >>>> and its name should not be treesitter-specific either, then. >>> ...But perhaps you have a more general purpose in mind for them. >> cperl-mode/perl-mode, latex-mode/LaTeX-mode, c-mode/sm-c-mode, >> caml-mode/tuareg-mode, ... > So like major-mode-remap-alternatives? Yes, I like that suggestion. >> I'd imagine `treesit-enable-all-modes` could emit a warning about >> modes lacking a grammar when used interactively, and offer (maybe with >> a C-u prefix) to install the grammars? > Sounds reasonable. I was thinking it would be more economical to defer the > checking of grammars until a mode is actually used (so you can enable them > all wholesale, and then gradually install needed grammars), but that's not > critical. Pros and cons either way. Oh, indeed, we could also use `major-mode-remap-alist` to remap all modes which have TS alternative to a function which checks if the grammar is installed and then either calls the "normal" mode or the TS-alternative. > Also, there was a request to exclude some modes from the "enable all" action, > too. I took that to mean that we need a user option. I suspect in 99% of the cases, this can be done by refraining from installing the grammar. And even if not, I can't see why we'd need a new user option. Appropriate entries in `major-mode-remap-alist` seem sufficient to register that kind of user choice. AFAICT all we need is two or three functions/commands to cover those common configuration needs, but they're just functions/commands, so we could just as well provide 50 of them. `major-mode-remap-alternatives` seems good for `change-major-mode` but `treesit-enable-all-modes` would inevitably be TS-specific and would need some info about "TS modes out there" as well as some mapping between modes and their corresponding grammar, and that doesn't fit into the remit of `major-mode-remap-alternatives`. Stefan