From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter central configuration variable Date: Fri, 29 Nov 2024 00:42:34 -0800 Message-ID: <94819650-70B5-4BCA-83A4-055B75929A24@gmail.com> References: <4929184.OV4Wx5bFTl@3-191.divsi.unimi.it> <861pznqp9m.fsf@gnu.org> <2730223.lGaqSPkdTl@3-191.divsi.unimi.it> <39CF8919-E0A5-44D7-AA7E-ECD7465620A1@gmail.com> <86a5e8okhx.fsf@gnu.org> <868qtam99v.fsf@gnu.org> <137AE507-F467-4FB2-83DB-EC621F868C60@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27364"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Vincenzo Pupillo , Emacs Devel , Stefan Kangas , Stefan Monnier , Dmitry Gutov To: Eshel Yaron Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 29 09:43: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 1tGwbB-0006vi-CO for ged-emacs-devel@m.gmane-mx.org; Fri, 29 Nov 2024 09:43:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGwaR-0000sc-IF; Fri, 29 Nov 2024 03:42: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 1tGwaP-0000sU-O5 for emacs-devel@gnu.org; Fri, 29 Nov 2024 03:42:49 -0500 Original-Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tGwaO-0001mN-8F; Fri, 29 Nov 2024 03:42:49 -0500 Original-Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-7253bc4d25eso1086769b3a.0; Fri, 29 Nov 2024 00:42:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732869766; x=1733474566; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EGaxnZRFvXzYtV8+mAxjxfhDIBNNXTpTnyjlgmnDqRI=; b=QRbNiSg/untp2/yFBHai/grFCiyndMdsawZgxcRzTl6zuNzXBCvRClLvmt4PWTz7om sVwHIxJD6/LG2sr/SSjXotNFOVYwr7UBtru80dINTUMj404SNrqHEEZc0onlpeIONtTJ cABe2mcAi9fFMzT32gqvbuZ11Jd2gM9lErrzbjgHvWhatwv2E7sRq2K7WyILaiVFqf+3 UbwjDxRBaNgi7WGq1L5cpb48Xe2ExJ3LUBJdKy250I6u9YwyiKlBpqV0Ddzb6U65hsPI g+NHUWVky5+FSEWc9btTji+6JPoI0t8hmYfBdbufBFiVy0K9oYHe551AeppklrnNfYP3 vxdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732869766; x=1733474566; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EGaxnZRFvXzYtV8+mAxjxfhDIBNNXTpTnyjlgmnDqRI=; b=rdlHevQkbvV/3n57DejOkIPh6TlqFmNadDUjbCl1e5nTVN5ZUNORwpN/CyCaw2RN/v Cuel+1878jGU4YTZVuJmmMwY0SMDqvk1+7ZYaNGv+W/X6zjdLp5aG7zQlY6isO/Wy1Us m1wPIKo/Zzkdyzb+qCwPgnKdBErUqvhD9vY5uQL5+cC6zXRm3K2f2Eih/FRjJ9Zlm0nA 4MIyomdQcX1mvUmT9rq1wkMWLWDnSWyvP0y9Ct6cluZimQRGMuI+78+bDpTf2cnkbqSI OrDLWZyxKhA/QOWm+odCZJS/YxjFsA+fHpoVVO+5glFv1XbYI1ze6zoRmOlzv2/+7rd8 yMCw== X-Forwarded-Encrypted: i=1; AJvYcCUYPPdhlKeAidtcg08RtrCyxpv/7LcSwGkSpWkwNzp88HoawtGgPoo6EMB2tMzT0E2SiZgGeTK2dEduig==@gnu.org X-Gm-Message-State: AOJu0Yyv5339CIQ1fAtJ0BIt02NtMnLC0pVFPbxQEHachOuhEnp9KA6v +TA0xELuv0+QDVxQktii+50MZ3cHcoPr6u7nJv/cAzK38qgTAJEt X-Gm-Gg: ASbGncuxBb16yX41W+TPZvmaZmGFYY0K4LH74Fjj9hrGxo8Sk9Q5jpbr4ZTJI7ruZLH qBtXd4ucPw9+d9YDi5k5edf50JQa5ndMsrZfbic7xbAIvp/TFUunrYyyxG/6dFDqNzgZak6sOEW nBMj5BV5U6nrSI/HM+/QBR567CwjOOuiN4OskBuwSIQqbPOGRcyZv8sxw37+5bxYMC+bC9r9eVU q5eZHspRSZ/+gQ9E5B5y0rpUgwxkGYuVyBRzcnXdtbJYRNQmzWJ6rB8767kzByUbsrszU5Vpg== X-Google-Smtp-Source: AGHT+IEQe/+YbjigLEBvNxyQydruh8z0Gsp1vVG/8n1CkIT5UrPzJD2UsUr3427qy1js9Qjc9n5XNg== X-Received: by 2002:a05:6a00:c82:b0:724:bfca:e265 with SMTP id d2e1a72fcca58-7253f31df73mr10598354b3a.5.1732869766406; Fri, 29 Nov 2024 00:42:46 -0800 (PST) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:c885:af5e:9679:e419]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725417614f5sm2940516b3a.7.2024.11.29.00.42.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2024 00:42:45 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3776.700.51) Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=casouri@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:325850 Archived-At: > On Nov 28, 2024, at 11:12=E2=80=AFPM, Eshel Yaron = wrote: >=20 > Hi, >=20 > Yuan Fu writes: >=20 >> Actually, I want to expand this to something that allows users to >> configure tree-sitter modes and toggle on/off tree-sitter features. >>=20 > [...] >>=20 >> What do you guys think about something like this: >>=20 >> (setq treesit-global-configuration >> '((c-ts-mode >> ;; Set treesit-font-lock-level to 4 >> (font-lock-level . 4) > [...] >> ))) >>=20 >=20 > FWIW, I think tree-sitter should be treated as an implementation = detail, > not a user-facing concept. Tree-sitter empowers major mode = developers, > but users shouldn't have to know or care about tree-sitter to benefit > from it. So a TS-specific configuration user option is not the best > approach IMO. (For the same reason, I'm not a big fan of the "powered > by tree-sitter" that we have today in the docstring of various modes.) I principle, I agree, and that=E2=80=99s what we=E2=80=99ve been doing: = we expose tree-sitter as a mechanism for major modes to build on. = However, the reality is, something like this just aren=E2=80=99t going = to be transparent=E2=80=94users know it=E2=80=99s powered by = tree-sitter, they=E2=80=99ll need to have tree-sitter knowledge for = non-trivial customizations (eg, add a font-lock rule or indent rule), = and the major mode is tied-in with tree-sitter, implementing the major = mode with another parser library would require creating a new major = mode. Once you accept that these modes are tied with tree-sitter, a = TS-specific configuration starts to seem pretty reasonable. Also, think = of the advantage of using a single set of configuration: no need to read = the manual and learn the variables etc for each individual major modes; = as long as the mode uses tree-sitter features, you learn the = configuration framework once and use it on every mode. > Instead, when it comes to settings that apply across major modes, I > think we should focus on knobs that make sense whether or not a mode = is > TS-based, and have the TS-based modes respect such universal settings. Perhaps you mean something that configures things like font-lock, imenu, = etc? (I can=E2=80=99t really think of a third example). That=E2=80=99s a = bit ambitious, the return is unclear to me, and gods bless whoever wants = to fight through emacs-devel for it :-) OTOH, a tree-sitter = configuration variable is pretty concrete, I know people want it, and = more or less noncontroversial (I hope). Yuan=