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 integration in python.el Date: Sat, 8 Oct 2022 14:06:47 -0700 Message-ID: <9D398D49-0CA3-4CBA-9820-728E4A6C9568@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> <875ygu91z4.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="11971"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Matthias Meulien , Eli Zaretskii , emacs-devel@gnu.org To: Augusto Stoffel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Oct 08 23:07:59 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 1ohH39-0002ww-5Y for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Oct 2022 23:07:59 +0200 Original-Received: from localhost ([::1]:49196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohH36-0003km-1O for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Oct 2022 17:07:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohH25-0002Nf-9W for emacs-devel@gnu.org; Sat, 08 Oct 2022 17:06:53 -0400 Original-Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:46896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohH23-0008Ey-Ix; Sat, 08 Oct 2022 17:06:53 -0400 Original-Received: by mail-pg1-x52c.google.com with SMTP id 78so7357642pgb.13; Sat, 08 Oct 2022 14:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=oI3wGm/T2SEYS2nfkkHP9uuyRI7J+v0So+4T4/UuKdY=; b=oFM6MT0NDLOyLLiqZ5i2VDDl+xzwWDQPBhgoxbO0jgNJp0vUUz1OFmYE9IBMs4GNkr fB4+hYhG/37+tQNRKH8x2r/2LufMqPbzFOD4wg6aswQdcjS7NnwvDo5vGT6Vrx+Sp6Wa pbjyj7DZgAztl5Re2x675eR/n+8adEOVGS6aiy6N3GEbFWRmMKoFTb83XmTjXd2dVrSW ZmFGg5YQ/Z6/wXJu3WEBWyee3f7YV8Xr2AvDAjpqP1muPn+ISELcIrakbyrbUwoM3X6s Op8ZnNgx1WJ878fBdaSHIrCIMxv1gBhvJLs3YKHu31oPZAL6isp0cIsjMt83ZFpBRScK 22Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=oI3wGm/T2SEYS2nfkkHP9uuyRI7J+v0So+4T4/UuKdY=; b=CXP8dUAE0DkZZ4D2DC1Ks4LxHWr+5deVD9hNizSfgHvxITBr+qxPGLGTf1IEgzuElO D0jB4I2dil4WsXGE12CRy0EdQIU4UMKdBaY3qV3EMKaJBj1iOxmRzwcaA/+VERp5wt5e bFnSKlQeehceWw/amKWuLmfGu484nH8yX6lD9qNPV7OzZNZ41f6Orw5yQ5PgeZ4zMIeU CW2RbF4RYjkxiyDJsJd5xICbnloZLYeWf2sVfNfTIUwnc7hY2SV2wNMfpQ/43KKdzpvF pcDWh6wkjLpTIPCTdHLyoEFRCgsTu+4l/Xgj7LBNjp0M3mPFNCFPDyzfofb2CPaV2anm Y8Ng== X-Gm-Message-State: ACrzQf0nDy7MPqQ598rStM//FqZUzfZKNbLBpiqYL9M1eZRUc4TlPOMU r5fyGw2fHnanAhTUMjNnx7g= X-Google-Smtp-Source: AMsMyM5OeBytbZVj1j7gOAm45nD4vVe6mwbh8qp5dQ+WmjFqDPimkT4vSvEGDGkBdFuQN49PXUbUWQ== X-Received: by 2002:a65:6bd3:0:b0:42b:9117:b9d1 with SMTP id e19-20020a656bd3000000b0042b9117b9d1mr10110016pgw.238.1665263209749; Sat, 08 Oct 2022 14:06:49 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id b2-20020a170902ed0200b00176d347e9a7sm3690777pld.233.2022.10.08.14.06.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Oct 2022 14:06:49 -0700 (PDT) In-Reply-To: <875ygu91z4.fsf@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=casouri@gmail.com; helo=mail-pg1-x52c.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:297223 Archived-At: > On Oct 8, 2022, at 1:03 AM, Augusto Stoffel = wrote: >=20 > On Fri, 7 Oct 2022 at 15:10, Yuan Fu wrote: >=20 >>> 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). >>=20 >> The complaint for font-lock-maximum-decoration is that it=E2=80=99s = obscure >> and too corse-grained. >=20 > To me, the biggest problem with font-lock-maximum-decoration is that = few > major modes bothered to implement levels. That=E2=80=99s their choice. If no one complains it=E2=80=99s not a = problem ;-) >=20 >> 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. >=20 > 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. It sounds nice, but (1) such generalization breaks down for = not-c-like-general-programming-languages, like html, css, texinfo, etc, = and (2) maybe one wants builtins in C but not in Python. >=20 >> 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 >> Since we are designing a new system, I don=E2=80=99t think we need to = resort >> to the likes of font-lock-ignore. >=20 > 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. >=20 > 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. It=E2=80=99s a nice idea, but in tree-sitter, different languages tag = differently, it could be =E2=80=9Cfunction_definition=E2=80=9D in python = but =E2=80=9Cfunction_declaration=E2=80=9D in C, etc. So it is not = consistent across language. Also, it is often more complicated than a = single tag like =E2=80=9Cfunction_identifier=E2=80=9D, but rather a = nested structure like (function_definition (identifier)). Yuan=