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#61655: [Tree sitter] [Feature Request] font-lock function calls, definitions, separately Date: Sat, 25 Feb 2023 04:28:11 +0200 Message-ID: References: <8DA1B548-B8D2-4EC1-B9F8-F7654003AC89@gmail.com> <56C0998E-3053-49F3-BAE3-46D6432B16F5@gmail.com> <87abbcaf-e60b-f975-b589-5e61f2d7866e@yandex.ru> <83bklkp7tj.fsf@gnu.org> <97710356-24c1-d79c-4796-3e51fd4809e3@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="11049"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Cc: 61655@debbugs.gnu.org, Eli Zaretskii , Theodor Thornhill , casouri@gmail.com, jacob.fai@gmail.com To: Randy Taylor Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 25 03:29:20 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 1pVkJL-0002jF-VX for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Feb 2023 03:29:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVkJ7-0003hH-2z; Fri, 24 Feb 2023 21:29:05 -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 1pVkJ5-0003h8-KU for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 21:29:03 -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 1pVkJ4-0000O8-Hm for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 21:29:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVkJ4-0004YX-D6 for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 21:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Feb 2023 02:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61655 X-GNU-PR-Package: emacs Original-Received: via spool by 61655-submit@debbugs.gnu.org id=B61655.167729210217458 (code B ref 61655); Sat, 25 Feb 2023 02:29:02 +0000 Original-Received: (at 61655) by debbugs.gnu.org; 25 Feb 2023 02:28:22 +0000 Original-Received: from localhost ([127.0.0.1]:38674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVkIP-0004XV-Ga for submit@debbugs.gnu.org; Fri, 24 Feb 2023 21:28:21 -0500 Original-Received: from mail-ed1-f42.google.com ([209.85.208.42]:33308) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVkIN-0004XH-VN for 61655@debbugs.gnu.org; Fri, 24 Feb 2023 21:28:20 -0500 Original-Received: by mail-ed1-f42.google.com with SMTP id ck15so4823012edb.0 for <61655@debbugs.gnu.org>; Fri, 24 Feb 2023 18:28:19 -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=6QiKV/dzJmGPu6LkzhX99D+diLyxLqJRoHvIQYqAeWo=; b=o6kYEB8H2PLgQDakR7XAyRam3y40p51DSyxe7IDCSYALlbF3yvtuiJzWPVgxUKBFFt f5sQdUQCicX6wDXUioJqAxFvrWcxjxf14iMjVhMI7ZZPag2eDIA0EB03b8Tdcmo4eOfc 3dzHneLkfvKxbV7etQ8QnlOBwCbhyPEOQSvTOzDI4gdYf+1GRZ52HeJc30jmX++CJPVp uGX8Xo7iQORePe3MEpCDHGstX5iCJp4ZW3Lh1DyDpmAEq99vc5viKBwPFWO4wzajAdJv 06R+u9Gka6ktJIe90A4JBqgZj7reOEfmunO2WtKmAEYalHhf1YC9laZWleDuQB5E/WnI kHHw== 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=6QiKV/dzJmGPu6LkzhX99D+diLyxLqJRoHvIQYqAeWo=; b=ORayWKLbwH+5RXkCCK7T8CRhqmQ84/uQXHOV2NFogy75XEJU8plQsLsGLtlixgQAzP opDqVcY0jhHO/pwyPzQWwOHsH1PpCG/ID4Jab1TK3Qbv6JJVmhT2vHxwQ0YPW5HnBAAO Zyjn8Pont1TfiMhcDBChhCZD1YPr/QG8B7YjutNG0psm20UFIF2h/fgRA8z4WXVjg10u idJ98RiIybBZW4DMJoBuRjLH23Fq5d1PZRy0Cd1NPp9lBVI5lAZYvQsc5Co4sIlFSKut I/w+U7vV+iBOlsyk0P4UCAeH3wmT4EQ7dSssrKGmeJIbxLpioun2oOoOPqsoMpioG6Pr aIbA== X-Gm-Message-State: AO0yUKXpcL8W0xHAlfGIpneFibhdKMLfOCcgHTz4TaoaXy0ec0TuHByH wHlUyBR1HRvm3wHXMb1IhoQ= X-Google-Smtp-Source: AK7set/glyoy6ZPH1Yw8gSyQ7rvCV+57p/sjHtTaeR6kZORXCGNpmoMQmErO5gXGopcFv/N9InCpcQ== X-Received: by 2002:a17:906:af85:b0:888:db6b:5fa9 with SMTP id mj5-20020a170906af8500b00888db6b5fa9mr22284007ejb.67.1677292093601; Fri, 24 Feb 2023 18:28:13 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id v22-20020a1709063bd600b008dd6bf721c2sm278374ejf.106.2023.02.24.18.28.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Feb 2023 18:28:12 -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:256674 Archived-At: Hi Randy, Thanks for the reply. On 25/02/2023 03:06, Randy Taylor wrote: >> Here's the patch which adds the faces and their uses in all ts modes. >> >> Comments welcome from all the interested parties. The patch is mostly >> straightforward, but there are some changes added as well, where it was >> needed to differentiate between declarations and references. >> >> The important question here, I think, is whether we want to split >> font-lock-property-faces in two, like I did here. >> >> By analogy with the other faces, I think it's going to be useful to >> differentiate between property definitions and property references. Not >> many of the languages modes used font-lock-property-face for >> property/attribute definitions, but some did. > > I'm not sure about the naming of font-lock-variable-ref-face. It's confusing for languages that support actual references like C++ and Rust. But even there "variable reference" is probably a suitable term for any occurrence of a variable other than its definition. While the references you're talking about are "value references". > Maybe the opposite direction is better: font-lock-variable-def-face (or something similar) for definitions (or whatnot), and font-lock-variable-name-face to refer to uses (same goes for property). Or font-lock-variable-use-face. I don't know, naming is hard :). I, uh, pushed the change before I noticed your email. ^^; But perhaps we could refine, if there is enough support. Indeed, I was slightly uneasy about the -ref- names, if only because they might seem a little cryptic. Using the name -def-face is something I thought about too, but it sounded a bit like the name of a macro. A bigger problem, though, is that existing themes customize font-lock-variable-name-face. So we'd have to create inheritance the other way around (for the themes to continue working unchanged). Or we'd have to create face alias and use a yet different name for "variable references" (or "uses", or whatever we'd call them). Inheritance "the other way around" would break the usage scenario 1 below for users of existing themes. Or at least make it more difficult. > Personally, I don't really see the value in differentiating these for variables. I can understand it a little more for properties. But I guess it doesn't hurt to add if folks want it. I see two potential uses: 1. Customize treesit-font-lock-level to 4 but font-lock-variable-ref-face to copy 'default' (or close to it), to skip variable reference highlighting or make it less noticeable. 2. Pattern matching or comparably complex syntax which at a first glance may look like variable reference, but actually creates new bindings (or vice versa, creates new binding when one wanted to refer to an existing value). Emphasizing the difference can help people, beginners especially [in a particular language].