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: Mon, 10 Oct 2022 08:10:32 -0700 Message-ID: <3DA867E4-2C37-400C-8BB3-3E72D6C8F8A9@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> <9D398D49-0CA3-4CBA-9820-728E4A6C9568@gmail.com> <874jwcf8s0.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="26502"; 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 Mon Oct 10 17:16:03 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 1ohuVb-0006da-FK for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Oct 2022 17:15:59 +0200 Original-Received: from localhost ([::1]:33994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohuVa-0003vd-FX for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Oct 2022 11:15:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohuQS-0003d9-4X for emacs-devel@gnu.org; Mon, 10 Oct 2022 11:10:40 -0400 Original-Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:46787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohuQQ-0003l6-2I; Mon, 10 Oct 2022 11:10:39 -0400 Original-Received: by mail-pg1-x52a.google.com with SMTP id 78so10468932pgb.13; Mon, 10 Oct 2022 08:10:36 -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=z0CKW87rUO1B4Sx/y1nv2dYSCQIBhinoqfwc4xw2+EA=; b=SvpNK6JbQs4XVyDYA22GH5MUgAGEFe6tVvuPQla1VdcURjPrvGGR68U6zSZwGgfpgg Ar4FWybb8M+Srf0RKFxJQWLUE3IKp7EvNIUpX9WdGC2L8ROYw7S1wf0JzYYkQA072DHu 4P4JztYNriN5crNrM1dNpxYaQUZvYG1U1zLhRLcL8yx0CepNPa+gCwJtXlqgOyNc7lTY bgx53kL4xLO/5E0imY1cJocD2Lc7puohR3b23qaze2dHTon7H0C9rLaU4qDjBz7YQGJG V65f7/CtMCXQ+5k+UR7pddcF/KIWxSkZEhAU5Quv71SCeWeJOX2t9NJJW1IBI2TioYmr Yz3A== 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=z0CKW87rUO1B4Sx/y1nv2dYSCQIBhinoqfwc4xw2+EA=; b=JGt7K4m7zKcsVb+KOvL2n9MHVY4wMln+PdLqLsawVwxmJhoqNUl+96jLGurFPKm/PI PF1zz6QH0yvuIWShsrFcjSBlkvkV6XaCHagqkhPeJa6TT2wLiA3OtZY1Zfry/Gwl8IVk 3al8HWyxAOTJkJbY76Z0/vGUiGVqdKwOV08wCMD7dYskNBUEInRt7C8cuWtIOaZnGZNC qdxQZxvJke8WK+HS5Drwa8pDgfbcGsUDqV0hcDkzm5Eoqc98nj25aDwmHAUdQCl6G3fZ t+9VgbXxIMQkN5uDirHARBM4HX1lbSEvtNDQfUbe4uDe12khz6zsBaD09o2YL98/P8TE caJg== X-Gm-Message-State: ACrzQf2/v0MjES/0ervnxs/OxQ86/ku8I6LBPbo43wo5w1FopOjMQBMB /tp/iQf1275tsEKqmf13CMk= X-Google-Smtp-Source: AMsMyM4t7wfvmQsqUKIitaepoZyHJb/Eb2VOhsG6jIgIFnSXuMZCT8ddh5Fzph81n9fzuKXj6iUMUA== X-Received: by 2002:a63:4e18:0:b0:43c:2fc7:2eea with SMTP id c24-20020a634e18000000b0043c2fc72eeamr17667627pgb.119.1665414634919; Mon, 10 Oct 2022 08:10:34 -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 v30-20020aa799de000000b005639a80af7bsm473388pfi.75.2022.10.10.08.10.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2022 08:10:34 -0700 (PDT) In-Reply-To: <874jwcf8s0.fsf@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=casouri@gmail.com; helo=mail-pg1-x52a.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:297369 Archived-At: > On Oct 10, 2022, at 12:16 AM, Augusto Stoffel = wrote: >=20 > On Sat, 8 Oct 2022 at 14:06, Yuan Fu wrote: >=20 >>> To me, the biggest problem with font-lock-maximum-decoration is that = few >>> major modes bothered to implement levels. >>=20 >> That=E2=80=99s their choice. If no one complains it=E2=80=99s not a = problem ;-) >=20 > Well, I'm complaining now and I think you can solve this :-). Of course, within my reach I try to stratify font-lock into levels. I = meant major modes not in core.=20 >=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. >>=20 >> 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)). >=20 > One suggestion then is to allow attaching some =E2=80=9Cmetadata=E2=80=9D= to the > fontification rules in `treesit-font-lock-rules'. For instance, > declare that a rule has :kind function or :level 2. I=E2=80=99ve added support for :level in treesit-font-lock-rules, yes = ;-) Yuan