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: Sat, 30 Nov 2024 09:38:46 +0200 Message-ID: <861pytb27t.fsf@gnu.org> References: <556779b3-9308-4fd3-9050-bf9c49658cd1@gutov.dev> <864j43t8t9.fsf@gnu.org> <4cc676e8-cac5-4348-99b0-243baf74687e@gutov.dev> <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> <27a62624-387c-4233-b995-170270e26efd@gutov.dev> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39889"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 30 08:39:38 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 1tHI4o-000ADo-EE for ged-emacs-devel@m.gmane-mx.org; Sat, 30 Nov 2024 08:39:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHI4K-0000JD-GH; Sat, 30 Nov 2024 02:39:09 -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 1tHI4F-0000Iy-Ps for emacs-devel@gnu.org; Sat, 30 Nov 2024 02:39:04 -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 1tHI4E-0002oh-6V; Sat, 30 Nov 2024 02:39:03 -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=/qRLZUYLn97ypSBMViGs46ONGbtTLL77akb2QsLl7rI=; b=hKJZ3nZhgwIc iwjXES9nC08KwHys5litUCee0WvRqCKffzmYEaJvFgqrZX/DdnQDQcBEwMAPuRkOqL8pYl3715Crh 2WLkSQFiVPoydGWMUIzm0Nx2EPkjYqM8oa4QxebpYDCJhm03NJ4OdCn2fEXf4KnZUv2IUX2GfoO3V ABUeCPatdkd9PIYF4K6Snqn03IPZ5w/sb5JOLL14nSHnCsAlBXUvnK8nuCd9LINV0vzHX+jM0LjDu SNUduF3WV3JK1DDfur9Souv+VAYlgWjX+k7zOZktU9pSevRGhP2kYDqny1um+fgsunKtoInrgBKS3 YWafq1LL4/03bbKLpCt8FA==; In-Reply-To: <27a62624-387c-4233-b995-170270e26efd@gutov.dev> (message from Dmitry Gutov on Sat, 30 Nov 2024 05:26:35 +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:325868 Archived-At: > Date: Sat, 30 Nov 2024 05:26:35 +0200 > From: Dmitry Gutov > > On 29/11/2024 20:09, Stefan Monnier via Emacs development discussions. > wrote: > > > In any case I was thinking of a UI that's not specific to tree-sitter > > that works as follows: > > > > (defun change-major-mode (newmode) > > (interactive (list (read-the-new-mode))) > > (cond > > ((eq major-mode (the-mode-normally-selected-by-auto-mode-alist)) > > (setf (alist-get major-mode major-mode-remap-alist) newmode) > > (when (called-interactively-p) > > (customize-mark-as-set 'major-mode-remap-alist))) > > (t > > (let ((regexp (guess-regexp buffer-file-name))) > > (add-to-list 'auto-mode-alist (cons regexp newmode)) > > (when (called-interactively-p) > > ...somehow convince Custom to do the above `add-to-list`...)))) > > (funcall newmode)) > > That sounds interesting, especially the 'guess-regexp' part. I think it > would make it ineligible for calling from the init script, though, which > could be a preference for many. We could have both. We don't have to choose only one. > > `read-the-new-mode` could use a variable like Dmitry's > > `treesit--mode-associations` to provide good defaults. > > > > BTW, this var shouldn't be set like in his patch, IMO but via > > > > ###;;;autoload > > (add-to-list 'treesit--mode-associations (javascript-mode . js-ts-mode)) > > TBF one of my goals for the later patches was to avoid adding new public > "registry" variables, like treesit-auto-mode-alist, > treesit-major-mode-remap-alist, treesit-interpreter-mode-alist, etc. It > seems like having more of them can be a source of confusion, and it's > not obvious that using them in 3rd party modes would be a benefit. I tend to agree that adding such variables adds complexity, which is perhaps unnecessary.