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: Mon, 10 Oct 2022 09:16:31 +0200 Message-ID: <874jwcf8s0.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> <875ygu91z4.fsf@gmail.com> <9D398D49-0CA3-4CBA-9820-728E4A6C9568@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="39224"; 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 Mon Oct 10 09:24:35 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 1ohn9O-0009z4-SP for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Oct 2022 09:24:34 +0200 Original-Received: from localhost ([::1]:38230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohn9N-0007t3-QK for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Oct 2022 03:24:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohn1w-0002UN-Vs for emacs-devel@gnu.org; Mon, 10 Oct 2022 03:16:53 -0400 Original-Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:43845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohn1l-0007JJ-Dw; Mon, 10 Oct 2022 03:16:51 -0400 Original-Received: by mail-ed1-x52e.google.com with SMTP id z3so13664430edc.10; Mon, 10 Oct 2022 00:16:36 -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=cvj45yYJWofp3Ek7RySf0nWcalZc692PU7G1nlVAbj8=; b=WtkO3nbVkVvbWD6OvLsTuAfn+wK/fbwMQJqKfGNXjZhySuwTjAS7zWhs2InH4MLypr e5TYGPkgWNPd316KqyRN/pGsSaEBn9JtUfhGEySD5sbO+e/xjXA/xFE2VQonUocVBjI/ sM1OmttQ/HXymO2gZ5+7++NNcHhn80rQRaQJh6I19YtpxjpYUtTmenFmrZZ3y14AnNF8 drM2p/fsMVVRkCQqpX2R9PPzOP5EcGAkV/ZuenlQq88zVW7Z48Jgmh5yMD0F4DeDoVD8 1mNQJJJ6AJ/tzJjQguQEyeq1UmXKCNoXZUZmhAt92gfdhCEpllFfMBwLiP8ZDy2ZCUJn EksQ== 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=cvj45yYJWofp3Ek7RySf0nWcalZc692PU7G1nlVAbj8=; b=yn8PJuHrYIRncellvh/FGmEotnCfS5KLpBm8xznit+1et4oo/srL0uKxlxukSlaEzv SJ3nqQ8qm5HaGnmajuUOkpkxevTdXJwM5QiM+HRG6+TNZzfw9qVOG95Ke0XQp8EuPDsO VWgx/BoKsteoj25Tre6KO+lYxmmoML5DdrxPGqEJo4QK0CVqBUvyhngGPerEDX74XeWt oMJpG0uXNwNWlTTXFje4QD0ZSQBs990Ytkieqfsh1hei3KLSra71hme8NSixN8Z65JsB lHoereXU7SZu56Kga/DzgrokJgYz+DDHrHcvmlP1rYLQvTzCqraSgLuRe75AF7pkGytS xVcg== X-Gm-Message-State: ACrzQf0Kp9R6yurnxUJfJph+BSCX3/EUHz76jyidHGZzRzAIhIp6hFgO iXc1n2xUOZdJtP4tN+O6p9rUi27UQJM= X-Google-Smtp-Source: AMsMyM4XKm53srWFzL733bVjD9qAWFKWMYX/qA9wJtfMxhPIiWaR6nbG0MJ0vY41LvkVtsIjyGitKA== X-Received: by 2002:a05:6402:27c6:b0:45c:1f1a:6b85 with SMTP id c6-20020a05640227c600b0045c1f1a6b85mr3275386ede.316.1665386193788; Mon, 10 Oct 2022 00:16:33 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::89aa]) by smtp.gmail.com with ESMTPSA id k8-20020a17090632c800b007030c97ae62sm4871467ejk.191.2022.10.10.00.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 00:16:32 -0700 (PDT) In-Reply-To: <9D398D49-0CA3-4CBA-9820-728E4A6C9568@gmail.com> (Yuan Fu's message of "Sat, 8 Oct 2022 14:06:47 -0700") Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=arstoffel@gmail.com; helo=mail-ed1-x52e.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, 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:297325 Archived-At: On Sat, 8 Oct 2022 at 14:06, Yuan Fu wrote: >> 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 probl= em ;-) Well, I'm complaining now and I think you can solve this :-). >> 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 thi= s, 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)). One suggestion then is to allow attaching some =E2=80=9Cmetadata=E2=80=9D t= o the fontification rules in `treesit-font-lock-rules'. For instance, declare that a rule has :kind function or :level 2.