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: Status update of tree-sitter features Date: Fri, 30 Dec 2022 03:16:59 -0800 Message-ID: <599B2C6F-C05F-4BB5-9509-2E07D848D573@gmail.com> References: <5d53b299-14e1-6f8b-58b3-7e16842d87a9@yandex.ru> <0f099d93-64c3-59be-9d5d-9b23ca1ecd2e@yandex.ru> 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="12902"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 30 12:17:51 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 1pBDOZ-00039S-0K for ged-emacs-devel@m.gmane-mx.org; Fri, 30 Dec 2022 12:17:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pBDNs-0003NK-O8; Fri, 30 Dec 2022 06:17:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pBDNo-0003Mm-Nk for emacs-devel@gnu.org; Fri, 30 Dec 2022 06:17:07 -0500 Original-Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pBDNm-0007nV-VX for emacs-devel@gnu.org; Fri, 30 Dec 2022 06:17:04 -0500 Original-Received: by mail-pl1-x62d.google.com with SMTP id d3so21520416plr.10 for ; Fri, 30 Dec 2022 03:17:02 -0800 (PST) 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=1CPJuxkHfgh+ZFow2HiHsJZOHsaLhEjRhWG0rH9kMns=; b=nJo9offu6iXEngqGJ98SpdRnIKhF3R0N0sd6XCnLh5KQucVLW+hHPS5DqNKMIgRome 5KUXJwfOm7afF3n+iAaE0dubwX2tyu0X0btc45ND9FAIVBMJ57FOp3yLvFfA59ivQXXF jjwoYEAeyUBj6ZwDYbWQPoFrReMinm/7zRLLwG9QrNk2VB0ThpQLkVVeCZaiR780JmP1 7/dy0PWv9p8o5x4H7Ds2JtL2+DY/YHDayDzOjPce5oK4vNUa8u3VHgtdysAVdqE1CAS4 MP4Qyt61+9Pomaio/SwW6w5NZ1Hrx9VxWDRYVyNQClybEzwODVAYiaM0+eVhNh+Gp4W4 avHg== 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=1CPJuxkHfgh+ZFow2HiHsJZOHsaLhEjRhWG0rH9kMns=; b=x9cjm7DLTS34YBwFQ42jrW6v2rFuvIhNx2ou3bCYuoM3LdRs6XpTxdTwsBpVE3CPSs ojXlhlnLuPB32fG9m4u1KB7/ugZW7Tvq4tgXi9GiywSuG2GXe3IS+FkDGkoxgxamtelg gVNez+Ei0zQCuV/YCH7Jd5NzPPTZ2C1VwjZNNnuddP5qqCgX4g7dLjUO9mMhbLRA6h6n lbKXiuNjIFI+Wy1JZxJ1vWEps+KveowOrEMAjrj3HWKQWxnBwMr1b8r5DmCku5fDbyDQ U7Y88TWJJyoXFbG2oeuhBLRSlduNdJNNBBgGOTdwQ+JDC6ccKp4rOwZj8ZYVj4bVxYLw B0Xg== X-Gm-Message-State: AFqh2kpK+t8U6VCTg418CFP++jR4Bwi8rMTx0YPNb61ab/k52ihYIRqY 6f9XCpEROL7FXbVITQKYEiA= X-Google-Smtp-Source: AMrXdXtTq7GmQyxIM21krJiE7S1A3/qnkczVm2vyFtj1OuHCQo2eG/U9n0iDVltYZa8TqrKKAnDaeg== X-Received: by 2002:a17:902:680e:b0:192:4d1a:c51d with SMTP id h14-20020a170902680e00b001924d1ac51dmr32003478plk.32.1672399021403; Fri, 30 Dec 2022 03:17:01 -0800 (PST) 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 j5-20020a170902da8500b0018b025d9a40sm14628287plx.256.2022.12.30.03.17.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Dec 2022 03:17:00 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=casouri@gmail.com; helo=mail-pl1-x62d.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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302093 Archived-At: > On Dec 29, 2022, at 8:38 AM, Dmitry Gutov wrote: >=20 > On 29/12/2022 11:21, Yuan Fu wrote: >=20 >>>>> If it's only about calls, maybe call this category funcall? >>>> Function, property and variable are for every occurrence of them = (the touted =E2=80=9Cconsistent highlighting=E2=80=9D). So there will be = a bit of overlap between function, variable, and definition. >>>=20 >>> By "overlap", do you mean that font-lock rules should also have = entries for variable/function definitions with category = 'variable'/'function'? >>>=20 >>> In case somebody removes 'definition' from their list of enabled = features but keeps 'variable' and 'function' there? >> Basically, if you enable definition alone, you get highlight for = function/variable/class definition. If you enable function/variable = alone, you get highlight for all occurrence of function/variable = identifiers, which would includ what definition highlights. Definition = can be seen as the union of subsets of function & variable feature. >=20 > Yes, but is that classification useful enough to justify the = duplication in the font-lock rules' definitions? >=20 > FWIW, I "broke" python-ts-mode in 8503b370be1, according to this = definition. Sorry? >=20 > But what do we get by this particular classification? >=20 > The user will be able to disable 'definitions' and still have all = function definitions highlighted? But not, say, variable definitions? >=20 > That doesn't strike me as particularly more useful than e.g. disabling = 'definitions' and having all function references highlighted (but not = definitions). Which we would make possible by limiting 'function' to = non-definitions. Right now you can choose to highlight: 1. Only definition identifiers, be it function, variable, class, etc 2. All function identifiers 3. All variable identifiers There could be better features, but the existing ones still have their = merits. If you want a feature that highlights only funcalls, maybe we = can add them, if there are enough time & interest. >>>>>> variable every variable identifier >>>>>=20 >>>>> 'variable', so far, seems like the least useful. When enabled, it = lights up every bit of text that remained from other matchers -- because = identifier are everywhere. >>>> Yes, but apparently people want it ;-) >>>=20 >>> Well, if they really do. >>>=20 >>> I figured that people who added this maybe haven't tested this = thoroughly. And that maybe they expected the effect of that "local = variables highlights" feature that some editors showcase already. >> The purpose of the standard list is to regulate features, so if a = major mode wants to support a feature in the list, it uses the = definition and name from that list (rather than creating a feature with = same definition but different name, or same name but different = definition). If a major mode really want variable feature, they can add = it, if not, they don=E2=80=99t have to. >=20 > Okay, I also have a different, somewhat related question. >=20 > Certain languages have a special syntax for "variables". >=20 > Ruby has @instance_variable and $global_variable -- the @ and $ are = used both during assignment and for later reference. >=20 > Perl has $var and @array_var. >=20 > PHP has $local_var. >=20 > Up until now we've highlighted those with = font-lock-variable-name-face. Except for @array_var in Perl, which has = separate derived face. Either way, we did highlight them. >=20 > What category should we use for them in ts-based modes? If it's = 'variable', then won't be highlighted by default. >=20 > If 'variable' matchers in other existing ts modes didn't include all = identifiers everywhere, we could put 'variable' into level 3. >=20 > Or we could add a separate category for all those, I guess. If a major mode thinks highlighting all variables is the best default = behavior, it can support the variable feature and put it at level 3. The = standard list is just a guideline. >=20 >>>>> For Emacs 29, though, I would discourage the use of 'variable=E2=80=99= . >>>> It=E2=80=99s on level 4, meaning not enabled by default, so I think = it=E2=80=99s fine. >>>=20 >>> Fair enough. If someone wants function/property but not variable, = they could fine-tune the list. >> Right. All the features in level 4 are pretty over-the-top IMO, so = simply bumping to level 4 and enable everything is probably not the way = to go. >=20 > I actually considered having level 4 enabled. The punctuation faces = look like 'default' without customization anyway, so it doesn't turn = into angry fruit salad right away. One can stop at customizing the = "brackets" face, for example. >=20 > Though I'd probably also want 'function' and 'property' highlights to = use other faces, distinct from 'function-name' and 'variable-name=E2=80=99= . You could use level 4 and remove unwanted features, yes. I guess that = works too :-) Yuan