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.devel Subject: Re: c-ts-mode: (eq treesit-font-lock-level 2) doesn't fontify parameter names. Date: Sat, 4 Feb 2023 19:32:11 +0200 Message-ID: <85fc0396-bf75-c059-3871-80a5cae8ab94@yandex.ru> References: 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="26338"; 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 To: Alan Mackenzie , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 04 18:33:12 2023 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 1pOMPX-0006fP-LH for ged-emacs-devel@m.gmane-mx.org; Sat, 04 Feb 2023 18:33:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOMOm-0006oJ-5T; Sat, 04 Feb 2023 12:32:24 -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 1pOMOh-0006o9-1g for emacs-devel@gnu.org; Sat, 04 Feb 2023 12:32:21 -0500 Original-Received: from mail-ej1-x62d.google.com ([2a00:1450: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 1pOMOd-0003xc-Om for emacs-devel@gnu.org; Sat, 04 Feb 2023 12:32:18 -0500 Original-Received: by mail-ej1-x62d.google.com with SMTP id k4so23550745eje.1 for ; Sat, 04 Feb 2023 09:32:14 -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:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=YOtRCAg9yJ7gqZd5OA7Y137Fa5cz9UuQfHDYPRxslqM=; b=JW7FnVlZ1m0Qkh1g9WFQ91Fdpycj+9c/+0hpfT2MEs8oNnXF+qGRKn1koEtO1zTiuH Hq/k7wUsk+h3PcqFopwtY+tzJYYOfpjU5de/ekUL3jNj+uIPq4K1RV4i+OtK3X04aGP5 /bhXLmO8E6n9WLqMEVdfC/VjRmqSNg7oMRiD01uk5TPbzUA1IBelLtnxa8tTBR5TbLpc u9lntcBF0qZoQpuTLZOveLboq6X0ll4Dal+I+a9A2PBVI21P8Smnt10rK0kfdac9F1/k jzHk+NV6noDhUD4YdMFegsj9NjBwKPF125sbmYA/FN78pz5X8ir7lLzZCp2SxWfKRRah BYog== 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: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=YOtRCAg9yJ7gqZd5OA7Y137Fa5cz9UuQfHDYPRxslqM=; b=Iepmo0rGIERlR09MEe+txdsdtqVHy5/glPoH641U+C7qaBTT7wBV4epyhfpIbCXS7p 941IIkcAjf8qXfo5eeiVVLY0pAp6ndcayZf1VBDURu5QNum5gbVjCcK74gYVpK8bwc2H M3gRrvBjvX1SuwIxrEkslwn7Xs49O8rA6x6Dc3XX9MPy1ha+oPPh1ggHLlLjTeUJ+Jt1 ENg7geqmlXebfKFnNCl3ESLfn4z4JUWCYzW05KzADHfhIpUliDah59KkFs9DWIa4gGf6 HN4Ob0Xudxc9v2id99yLQOexVLJhG43J6gtx/gGyxQTFi/LkY2oeZxIglUpverDbEEhj SrEA== X-Gm-Message-State: AO0yUKWjq1Scfd8HPXBipfztnMr6Mbj+t45EXo2L8h3tG50nbOw7eJWL fRLAIoS99GQGin4S5fpTO6A= X-Google-Smtp-Source: AK7set8R/KiSlJNTijV8dghaB9KweXeBSl5DnX1iMefGhulYMmnOrlYdDPvUcUp4gctduxdvL2wgCg== X-Received: by 2002:a17:906:31cc:b0:884:3707:bd83 with SMTP id f12-20020a17090631cc00b008843707bd83mr14487368ejf.69.1675531933290; Sat, 04 Feb 2023 09:32:13 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id u7-20020a170906408700b0081bfc79beaesm3036224ejj.75.2023.02.04.09.32.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 04 Feb 2023 09:32:12 -0800 (PST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=raaahh@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.09, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:302969 Archived-At: On 04/02/2023 16:49, Alan Mackenzie wrote: > Setting treesit-font-lock-level to 2 for c-ts-mode fontifies variable > definitions, but not parameter definitions. The patch below seems to fix that (the functionality was basically implemented already). I suggest we install it on emacs-29, for consistency with other modes, among other things. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 390f67a8e8c..7300074e5c6 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -440,11 +440,10 @@ c-ts-mode--font-lock-settings declarator: (_) @c-ts-mode--fontify-declarator) (function_definition - declarator: (_) @c-ts-mode--fontify-declarator)) + declarator: (_) @c-ts-mode--fontify-declarator) - ;; Should we highlight identifiers in the parameter list? - ;; (parameter_declaration - ;; declarator: (_) @c-ts-mode--fontify-declarator)) + (parameter_declaration + declarator: (_) @c-ts-mode--fontify-declarator)) :language mode :feature 'assignment @@ -552,9 +551,10 @@ c-ts-mode--fontify-declarator identifier))) ("function_declarator" 'font-lock-function-name-face) (_ 'font-lock-variable-name-face)))) - (treesit-fontify-with-override - (treesit-node-start identifier) (treesit-node-end identifier) - face override start end))) + (when identifier + (treesit-fontify-with-override + (treesit-node-start identifier) (treesit-node-end identifier) + face override start end)))) (defun c-ts-mode--fontify-variable (node override start end &rest _) "Fontify an identifier node if it is a variable.