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: Tree-sitter integration in python.el Date: Tue, 11 Oct 2022 18:15:22 -0400 Message-ID: References: <3A68545C-2E40-4BB4-8563-8041A5452634@gmail.com> <87y1twlr0v.fsf@gmail.com> <83czb8ycpo.fsf@gnu.org> <87tu4klfcw.fsf@gmail.com> <87ill0le20.fsf@gmail.com> <87y1ttfmj8.fsf@gmail.com> <19950F30-F4DB-4CE4-9257-24DA39594669@gmail.com> <87czb47jya.fsf@gmail.com> <87wn9c7xxd.fsf@gmail.com> <83wn9altdu.fsf@gnu.org> Mime-Version: 1.0 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="31558"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Eli Zaretskii , arstoffel@gmail.com, orontee@gmail.com, emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 12 00:23:27 2022 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 1oiNep-00081m-FY for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Oct 2022 00:23:27 +0200 Original-Received: from localhost ([::1]:45132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiNeo-0003YG-ED for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Oct 2022 18:23:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiNXB-0001KY-Ux for emacs-devel@gnu.org; Tue, 11 Oct 2022 18:15:37 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47153) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiNX8-0006Il-PJ; Tue, 11 Oct 2022 18:15:32 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A4E6B804AB; Tue, 11 Oct 2022 18:15:25 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0A1DC80091; Tue, 11 Oct 2022 18:15:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1665526524; bh=+kHj7dp3zefDocH9HFnk1ZP8tcqXjR3e6YmVO1Rsmbc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=bRVxlcH7UkCnOpNZkfCli+mN+LOhKpBltObsgrWHRVVaxNqlmbcwPxNEldh1P2uHm e99KZx6Tmd8y79IJwrMipbrDz3RmlVsGliQvzWTgVhVguTKmJmib9qWH6KxnLDbmC9 PrwlFH6ckwU/qp7Do1YIQygKdUfax1Sx6EUgs73gDUKn7r3Vr9DiGaWqcjMvESDKS5 ptVgBK0xZJv/pONn0oTH7gWqmXM1TLqZyL52P+LWjxxhEo88JJkpErmNfMqTpyNtJc F757hGDjUmgV+TOZwwWFNScg9SJuW2gU5FXPJByd/6vne0fv9N7nc8hte1I4FddlFa DxDG4wwLddCcQ== Original-Received: from alfajor (modemcable047.72-202-24.mc.videotron.ca [24.202.72.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BB2B3120DA7; Tue, 11 Oct 2022 18:15:23 -0400 (EDT) In-Reply-To: (Yuan Fu's message of "Sat, 8 Oct 2022 13:57:19 -0700") 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, 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" Xref: news.gmane.io gmane.emacs.devel:297558 Archived-At: >>> The complaint for font-lock-maximum-decoration is that it=E2=80=99s obs= cure and >>> too corse-grained. So my idea is for each major mode to provide >>> fined-grained controls like >>> python-fontify-type/f-string/assignment/built-in/etc. And tree-sitter >>> makes it easy to implement this kind of toggle. But I guess a global >>> control is also nice, I can make tree-sitter respect >>> font-lock-maximum-decoration, in addition to the fined grained >>> local-control. >>=20 >> I think having tree-sitter respect font-lock-maximum-decoration would >> be good, because it allows a major-mode agnostic way of controlling >> fontifications. With tree-sitter in mind, we'd need to agree on what >> kind of syntactic entities are included in each level (which is also a >> Good Thing, because currently what is level N of font-lock is entirely >> up to the major-mode, AFAIU). > > I think it is difficult to define syntactic entities for each level such > that it is generally enough to include all kinds of major mode out there, > and specific enough to be useful. It is easy for common programming > languages, but hard for others like html, css, prolog, etc. How 'bout: - Major modes provide a list of available fontification "features" in a buffer-local variable like `treesit-font-lock-features` e.g. `(type f-string assignment built-in ...)`. - the list of features is *ordered* so that the user can control the fontification via a Customizable `treesit-font-lock-level` that can be set between 0 and 100 to select the corresponding proportion of features. - Users can additionally enable/disable those features individually via some `treesit-font-lock-control` variable. Stefan