From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter integration in python.el Date: Sat, 08 Oct 2022 10:03:11 +0200 Message-ID: <875ygu91z4.fsf@gmail.com> 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> 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="27389"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Matthias Meulien , Eli Zaretskii , emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Oct 08 10:06:55 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 1oh4rG-0006zo-Rf for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Oct 2022 10:06:54 +0200 Original-Received: from localhost ([::1]:55202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oh4rF-0002Sk-Ed for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Oct 2022 04:06:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oh4no-0000es-OQ for emacs-devel@gnu.org; Sat, 08 Oct 2022 04:03:20 -0400 Original-Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:34352) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oh4nk-0007LN-Of; Sat, 08 Oct 2022 04:03:20 -0400 Original-Received: by mail-ej1-x62f.google.com with SMTP id ot12so15621136ejb.1; Sat, 08 Oct 2022 01:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OOci9MdDqea3N+vBVvdD5XXBVfBIStanBMU7Swyo4sM=; b=dG5+H5LUZlbKnvx37kts3v9K0owvJxoctN3ppfQdxYrcuXOVneeCo1IcdKxxtDISOn D7VvmIsb9aoP/voeKaU/d9jKOdEXqTS+Nyxx6CbwRVmtC8vZSm9vjspskNA1+zw8BudF UstnaoPPbbTxnMxWXDA7PFyvT0rDjiT4Q/d+HmaK4QuUkqD7sn3xr9AGdOynfIzVhdMh 0TfI4R/7KW8uh/Pif+75O2yEccCkrWi2ROVxkeiATru+cmwNrv7Qg0IaGRHlEWYvAm0s 71l+9RIXJG8+elj8h6xr7mbN29u1Vcz6yelZpZbh/9K0Fs/SvCxU7/jeFY1GvgeBcLsI UNOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OOci9MdDqea3N+vBVvdD5XXBVfBIStanBMU7Swyo4sM=; b=UHivVMQUUCQs+HDhVDAVTNakVUfF2xOf3vyyOH55UEN4IsgHEdExzRdEhnQIip+5t4 u2ZvrB8XrdPctesD0QI9Jn1ZvDNpRmoRB/RFyrMKQFuqtqH/d4qoF4YpELPNuXhdUfLk Be/OTnD1mLNONyQ8DRZuQJPY1s4IGEVPJyinFFBb0XyzjyxKlYfSp01T6jhZxEs+fIuc fvgQ33nj6zdnpZJW1ofd0ul26QhX0xYtR/RlvX+Y3hocCelKySBPmnf78dpOF1jw+XPU BGB1+QJUZPR2xHvfKJo1nW5KHNJoSObppsSX+4o6td95AdvamveM5PHsVgevaV5yG7Y2 6YnA== X-Gm-Message-State: ACrzQf0x+u+02ixDgPl9ZeoV+vSowvT7YbEdFPHMfRzPV54dNL8x5bJl rCT/RjKBncTfSswQQ/CAgaF+PBPSg1g= X-Google-Smtp-Source: AMsMyM6+95vmtXo7i4Kg7vw1KJrTWtWhSxOVWXRMeV/FqNCKJhksoRlHcDpQz8/1+gjq9Piqll1lMw== X-Received: by 2002:a17:906:401:b0:73d:af73:b78 with SMTP id d1-20020a170906040100b0073daf730b78mr7111559eja.122.1665216194245; Sat, 08 Oct 2022 01:03:14 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::89aa]) by smtp.gmail.com with ESMTPSA id w24-20020a056402071800b00458e73fe1c1sm3033864edx.8.2022.10.08.01.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 01:03:13 -0700 (PDT) In-Reply-To: (Yuan Fu's message of "Fri, 7 Oct 2022 15:10:10 -0700") Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=arstoffel@gmail.com; helo=mail-ej1-x62f.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" Xref: news.gmane.io gmane.emacs.devel:297196 Archived-At: On Fri, 7 Oct 2022 at 15:10, Yuan Fu wrote: >> On Oct 7, 2022, at 3:03 AM, Augusto Stoffel wrote: >>=20 >> On Fri, 7 Oct 2022 at 01:25, Yuan Fu wrote: >>=20 >>> Yeah, with tree-sitter, fortifying types is trivial. In fact all types >>> should be fortified already. (I tested with some simple examples.) >>> Should we provide some variables to toggle fontification for different >>> things? Like python-fontify-type/f-string/assignment/built-in/etc. >>=20 >> Looking at the screenshots posted a few messages back, which are VERY >> busy, I would really appreciate an option to disable a few fontification >> rules or, conversely, disable all but a few of them. Ideally, this >> should be done through a generic mechanism that works across major >> modes. >>=20 >> Have you seen the new `font-lock-ignore' option? Tree-sitter could >> provide something similar (and much better/less hacky). > > The complaint for font-lock-maximum-decoration is that it=E2=80=99s obscu= re > and too corse-grained. To me, the biggest problem with font-lock-maximum-decoration is that few major modes bothered to implement levels. > 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. Given the lack of success of font-lock-maximum-decoration, I don't see this being implemented by many major modes. Also, if the idea does take traction, it will lead to a proliferation of user options that is hard to use effectively -- if someone doesn't want to fontify built-ins in Python, they probably don't want it in other languages either, so they need to set a similar option for N languages. > 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. > > Since we are designing a new system, I don=E2=80=99t think we need to res= ort > to the likes of font-lock-ignore. It's exactly the opposite: since you are designing a new systems, you can create a much nicer customization mechanism on the lines of font-lock-ignore. For instance, one could select fontification rules based on the affected node type. The =E2=80=9Cdecoration levels=E2=80=9D feature can then build up on this, = with the advantage that it would be consistent across languages and require no extra effort from the major mode developer.