From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jacob Faibussowitsch Newsgroups: gmane.emacs.bugs Subject: bug#61655: [Tree sitter] [Feature Request] font-lock function calls, definitions, separately Date: Tue, 21 Feb 2023 10:31:17 -0500 Message-ID: <56C0998E-3053-49F3-BAE3-46D6432B16F5@gmail.com> References: <8DA1B548-B8D2-4EC1-B9F8-F7654003AC89@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) 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="22240"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , 61655@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 21 16:32:41 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 1pUUdE-0005cc-RT for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Feb 2023 16:32:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUUcz-0004Pc-G4; Tue, 21 Feb 2023 10:32:26 -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 1pUUcd-00040O-Dy for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2023 10:32:14 -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 1pUUcc-0000rD-72 for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2023 10:32:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pUUcb-0005ao-L5 for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2023 10:32:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jacob Faibussowitsch Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Feb 2023 15:32:01 +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.167699348921458 (code B ref 61655); Tue, 21 Feb 2023 15:32:01 +0000 Original-Received: (at 61655) by debbugs.gnu.org; 21 Feb 2023 15:31:29 +0000 Original-Received: from localhost ([127.0.0.1]:57062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pUUc5-0005a1-7k for submit@debbugs.gnu.org; Tue, 21 Feb 2023 10:31:29 -0500 Original-Received: from mail-qt1-f175.google.com ([209.85.160.175]:39636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pUUc0-0005Zh-VM for 61655@debbugs.gnu.org; Tue, 21 Feb 2023 10:31:27 -0500 Original-Received: by mail-qt1-f175.google.com with SMTP id w23so4681217qtn.6 for <61655@debbugs.gnu.org>; Tue, 21 Feb 2023 07:31:24 -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=8f7/Q8hIHUN9XARlh7zuEIt+JoeetpULBXx3sAS78OQ=; b=o60QfgFYVq734Ie8iO6KVB/Mnj5fkd58xG9dMwHQzCPSFuMwqN3CLk5LU1WlyvsGov BvNsv25nVyyEua7wAxGvPVeFiC5ljM40GEQXLvipkAurUGopYHJkBSN2LkwGkLdXjafy NLAPNgVoROhyOQS5cLQFCWTZdhhEaq22h3lwbJ9MCJupHZIeGmkwX4CeH3xSrFooryGF Uhf8eYSJaarV7sxi+n0s0YlpzJrdRgTWJHeh/7ER4RSBgV6RBamKmnIx5v4vP7gX+Jm6 yZUD+nIKsHwdBqu8TWt82w7jRKvDX7yLQDrH6G/FhnWIwsnboiLsSXEytHMpvsxtK+YI i7lQ== 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=8f7/Q8hIHUN9XARlh7zuEIt+JoeetpULBXx3sAS78OQ=; b=kyDPyi7rUaMQjTjpv/2rcUWB777oa33miqmm3RbTewF8NJgb0XKjErr9a9MYnq2c5I fgdRrHPZuaZ4brauvbAS3Yq0eJwXCy31lDCyzV3sfYn/fy1KU9FYQa2rwNCvxjbRkm90 t/QmKYIlmJmB5nxa0qHTLlw7qQD359PL+JjOgU1LW/1XsVU5O54/uWCjp27vyQQ8wFw9 kUsSy/aCRq1KnYfhtyoC00fb+4ZI0XBl+27wfNb6IeBtsA05pYHAl5utPFhyBuLT6Ezl e6PACdGhdxbVDzZ2FTvLLpqUzBzhxxMQXWuiUfITXWTJcMbIlYXZOcNhulWFm/WhGikf XF3w== X-Gm-Message-State: AO0yUKVCxgKwrDmpEHyRaTIuPgIKbRIqP/9WGoscW8SbgX8Lbhz/6pp2 rsxuLDqaqSKOZPan26eWyjA= X-Google-Smtp-Source: AK7set/EQ/wDRv44nA0++7JY4GuAMC5O7dzsZDB0MWJFlUbtbXXvEv2fH80pnY0jge3Ns+mEk/CPow== X-Received: by 2002:ac8:5d88:0:b0:3b8:29f6:8ac6 with SMTP id d8-20020ac85d88000000b003b829f68ac6mr19255010qtx.12.1676993479319; Tue, 21 Feb 2023 07:31:19 -0800 (PST) Original-Received: from smtpclient.apple (pool-108-21-63-133.nycmny.fios.verizon.net. [108.21.63.133]) by smtp.gmail.com with ESMTPSA id 26-20020ac8209a000000b003bd16200d6esm2116819qtd.46.2023.02.21.07.31.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2023 07:31:18 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.2) 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:256287 Archived-At: > but it's a relatively small change, Indeed, after playing around with the syntax queries a bit more, all = that is needed to implement this change is the following patch. Note for the new faces that I populated the `:foreground` fields to = match the colors for the example I showed in my first email, but maybe a = better default is to leave these faces totally blank and just purely = `:inherit` from `font-lock-function-name-face`. diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 9e944fe188a..d170123c2ca 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -2026,6 +2026,16 @@ font-lock-function-name-face "Font Lock mode face used to highlight function names." :group 'font-lock-faces) =20 +(defface font-lock-function-call-face + '((t :inherit font-lock-function-name-face :foreground "royalblue1")) + "Font Lock mode face used to highlight function calls." + :group 'font-lock-faces) + +(defface font-lock-member-function-call-face + '((t :inherit font-lock-function-name-face :foreground "brightred")) + "Font Lock mode face used to highlight member function calls." + :group 'font-lock-faces) + (defface font-lock-variable-name-face '((((class grayscale) (background light)) :foreground "Gray90" :weight bold :slant italic) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index b7a487687a8..51a65aa6545 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -529,8 +529,8 @@ c-ts-mode--font-lock-settings :feature 'function '((call_expression function: - [(identifier) @font-lock-function-name-face - (field_expression field: (field_identifier) = @font-lock-function-name-face)])) + [(identifier) @font-lock-function-call-face + (field_expression field: (field_identifier) = @font-lock-member-function-call-face)])) =20 :language mode :feature 'variable Best regards, Jacob Faibussowitsch (Jacob Fai - booss - oh - vitch) > On Feb 21, 2023, at 04:55, Dmitry Gutov wrote: >=20 > On 21/02/2023 10:28, Yuan Fu wrote: >> Hmmm, yeah. The builtin tree-sitter maps syntax queries directly into >> faces, where the third-party tree-sitter maps syntax queries to some >> syntax types, then maps types to faces. So it would be a bit harder = to >> do fine-grained control like in the builtin tree-sitter, comparing to >> the third-party one. >> I=E2=80=99ve thought of this idea before but didn=E2=80=99t pursue it = further: Right now >> we allow capture names to be face names and functions, eg >> (commment) @font-lock-comment-face >> or >> (comment) @xxx-moode-fortify-comment >> Maybe we can add a third type, arbitrary symbols, like >> (comment) @comment >> and add a variables treesit-font-lock-mapping which maps symbols to >> faces or functions: >> ((comment . font-lock-comment-face)) >> or >> ((comment . xxx-mode-fontify-comment)) >> Then we can easily support differentiating between function call and >> function definition. >=20 > Before we do any of that, don't we need actual different faces to use = for e.g. function definitions and function calls? >=20 > Same for variables. >=20 > And if we have those, we might not need the indirection, at least not = right away. >=20 > I figured we'd add them in Emacs 30, but it's a relatively small = change, if people are interested.