From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#61205: 'function' in 3rd element of treesit-font-lock-feature-list Date: Thu, 2 Feb 2023 13:11:30 +0200 Message-ID: <064e85bd-704e-8def-577f-b30fed449e21@yandex.ru> References: <62bd269c-85bc-7689-cad1-d705ea9350cc@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32700"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: 61205@debbugs.gnu.org, yuan fu To: Randy Taylor Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 02 12:12:17 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pNXVp-0008Ib-KC for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Feb 2023 12:12:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNXVc-0004zA-18; Thu, 02 Feb 2023 06:12:04 -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 1pNXVa-0004yN-D6 for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 06:12:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNXVa-0002Iw-4c for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 06:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNXVZ-0001xp-P7 for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 06:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Feb 2023 11:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61205 X-GNU-PR-Package: emacs Original-Received: via spool by 61205-submit@debbugs.gnu.org id=B61205.16753363037523 (code B ref 61205); Thu, 02 Feb 2023 11:12:01 +0000 Original-Received: (at 61205) by debbugs.gnu.org; 2 Feb 2023 11:11:43 +0000 Original-Received: from localhost ([127.0.0.1]:60918 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNXVH-0001xG-2h for submit@debbugs.gnu.org; Thu, 02 Feb 2023 06:11:43 -0500 Original-Received: from mail-wm1-f44.google.com ([209.85.128.44]:43890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNXVC-0001wu-N5 for 61205@debbugs.gnu.org; Thu, 02 Feb 2023 06:11:42 -0500 Original-Received: by mail-wm1-f44.google.com with SMTP id d4-20020a05600c3ac400b003db1de2aef0so1090118wms.2 for <61205@debbugs.gnu.org>; Thu, 02 Feb 2023 03:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=9JrLTMjtd3+WYhtLYRzT2NrEEPol4uL24Tv1LYczK3o=; b=BMwajRHuDKOAHY6/zUI5f+0a5Crghi1Q0menFTaAOZGuULBIhned9P1SR6h7Ypp4P4 fpbuEXjB5tsdobKXVZzfhk/k3L7gP2wFsOjDVpFfAsXYxekEbfUGevcUQ+vfQHczr9aQ OyNKqi7mO2oAuD184RVSRAdSNFkNgEnvduX66ywsF9sjLdw6wpvsZme0Ab+3KCudTtNT SHIiAM11ejYvmuO1rLwPKDsVenQzmY5sVsUMArP4B9cXlVcu80A5zS3WtXTbn49CTo3u EtCov8lnsGfZiDhu24WXav/6+p495ALGTUrmFDbtv4YAIJv8HpohLxH92D6dItcIPF8A 8a8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9JrLTMjtd3+WYhtLYRzT2NrEEPol4uL24Tv1LYczK3o=; b=VGiQAzIhcaS0vlrr/yiA/3/lIXvx7QnlmvVAPsXyK1fUflonnjAL8j4YbhW2aTP+0f hKPXYmljibdW0feNO+qJJWA9gCriyXf/1DpaOQzQZBi03RngOYTR9J6QL6v02jovbhdL fYtMU4szsP5EjOnWRsB/Wt0UTg1W6uT9ORaBRpEVmJyfkfnk0HRtHo6/4my958By6KwW gAR2MzlGlW0jat/U5JGti0Tx0hCaMApef2Wacrp3gwEdRsrdYmqHL775ahdGfXus3ziW 6NYYq/1qJcKZoFwfd/mzlVPzzNPBhszjnDIPeByNVRtj90EKJamkIwYGLoOCCTTlUipK 8E/A== X-Gm-Message-State: AO0yUKUIbNJHQRZY3QNy0oqikVOgjUR+X+Tv6a7DzoCmq4+8i6u9ixUh SoNEV91RTq9+CavBk7dKIzA= X-Google-Smtp-Source: AK7set/ED5gNGdZT9eBDjei74QjOhBmnJDw7/azHJF5BCLv7mHKNev5wj4X7nZpL3El/Wp+Pv+fTVQ== X-Received: by 2002:a05:600c:19d1:b0:3dc:3f1b:6757 with SMTP id u17-20020a05600c19d100b003dc3f1b6757mr5510316wmq.15.1675336292718; Thu, 02 Feb 2023 03:11:32 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id y10-20020a05600c364a00b003daf7721bb3sm4297685wmq.12.2023.02.02.03.11.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Feb 2023 03:11:32 -0800 (PST) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254646 Archived-At: On 02/02/2023 05:29, Randy Taylor wrote: > On Wednesday, February 1st, 2023 at 21:44, Dmitry Gutov wrote: >> On 02/02/2023 04:34, Randy Taylor wrote: >> >>> On Tuesday, January 31st, 2023 at 21:08, Dmitry Gutovdgutov@yandex.ru wrote: >>> >>>> X-Debbugs-Cc: Yuan Fucasouri@gmail.com, Randy Taylordev@rjt.dev >>>> >>>> Some new built-in modes has 'function' feature highlighting thus enabled >>>> by default. >>>> >>>> rust-ts-mode, go-ts-mode, cmake-mode >>>> >>>> Should we move it to 4 for consistency with the rest? >>>> >>>> Previously, we talked about that and concluded that function calls are >>>> usually everywhere and are easy to notice without additional highlighting. >>>> If that's what folks decided on then we should keep everything consistent. >>> >>> Personally, I find it odd that out of the box default highlighting wouldn't highlight function calls. >> >> >> I think that's more useful in some languages, and less in others. > > Sure, and people will have different opinions on it too. But I still think out of the box we should be highlighting most things like other editors do. Perhaps we should have an extra level between 3 (highlight sparingly like other Emacs modes do) and 4 (highlight everything including stuff that doesn't always look great). > It's easy enough to take out what you don't like. Note that in this case "taking out" some things uncovered that the highlighting really isn't great in a different configuration. >> I guess we settled on this particular convention to be more consistent >> with existing major modes in Emacs. But I can see how it can be >> appealing, especially in languages with more complex syntax such as Rust. >> >> Same for 'property'. >> >> The one feature that I'm fairly certain is currently useless is >> 'variable', because we don't have any variable scope tracking (yet), and >> the grammars don't do it for us. So too many tokens get highlighted with >> font-lock-variable-name-face. Try the current rust-ts-mode, for example: >> almost everything ends up with that face. > > If anything that isn't a variable is getting highlighted, then that's a bug. Anything it's catching that isn't a variable can probably be dealt with similar to how token_tree is dealt with. With a list of exceptions? I hadn't thought about that. But it sounds like it might be a fair amount of work. Depends on the specific grammar, of course. Note that you'd also need to add such rules for every "feature" that might be disabled by the user, for its identifier tokens not to start being highlighted as a variable (if the user kept 'variable' in the features list). That's the current design we're working off. And tree-sitter has a recommended mechanism for highlighting locals. We just haven't implemented it yet.