From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Tree sitter support for C-like languages Date: Tue, 15 Nov 2022 20:38:57 +0200 Message-ID: <83y1scgj0e.fsf@gnu.org> References: <87tu36em9t.fsf@thornhill.no> <871qq8hsj1.fsf@thornhill.no> <83iljklzmo.fsf@gnu.org> <87v8nkgcqj.fsf@thornhill.no> <87sfiogcbm.fsf@thornhill.no> <83pmdrkyj7.fsf@gnu.org> <87v8njw5th.fsf@thornhill.no> <83leofkwjm.fsf@gnu.org> <9E9244D3-2EFB-4621-91E0-FC8B8C1C2D52@gmail.com> <186915C1-1C47-43DC-A386-B447A2E7528D@gmail.com> <83h6z1k6z8.fsf@gnu.org> <52D18BA8-C9A8-4E9A-9DDA-76E48744DDC9@gmail.com> <837czxjrxu.fsf@gnu.org> <8BEF109A-A5B3-4CF4-AE07-AEB9388B0A07@gmail.com> <83zgcti9gh.fsf@gnu.org> <83y1scj3s8.fsf@gnu.org> <7082237A-2BD6-4A1C-8BEC-4D470B0D204F@gmail.com> <83a64si7jo.fsf@gnu.org> <835yfgi26h.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40906"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, theo@thornhill.no, emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 15 19:39:23 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 1ov0qA-000APD-UV for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Nov 2022 19:39:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ov0pc-0005KF-2b; Tue, 15 Nov 2022 13:38:48 -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 1ov0pY-0005Jx-Po for emacs-devel@gnu.org; Tue, 15 Nov 2022 13:38:44 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ov0pY-0006GA-0B; Tue, 15 Nov 2022 13:38:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=U742GR9HcE6ghpRCzo7cUZXmNSiK+0XUJpwOk4lfmr0=; b=gTWgv7eLfaFNBwfbGKFI GLxf3BVDZ/YVBWYNSxpSx0id8nBtKkReWpwWapezkkfDPZh5XQ1dEsgMZR60M9GHcvqP9D1UUrVAD m6RlBLEqKgM3L3YYBv8oYb1FO8T18ELmaOBsXGSeoAO+ioPgkpZu5QcTbTICuPfto3HIHcVXt08Np 8eMZ37hr0tr7Mjo6gd7s0wzztARto1qG/6K4fNo3S6fWNKOczDZglbohT9ZVXi0xH2Ebimq/pRGWe TtcK4974j74x8QhF04cJ0naEKEwrJKo7zUw0H0aFb/mvbPhWjgAZgbPjVYhPtSSlKbGISrTy6xN1m 0P45zZGkqIKhFg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ov0pX-0003gT-EM; Tue, 15 Nov 2022 13:38:43 -0500 In-Reply-To: (message from Yuan Fu on Tue, 15 Nov 2022 10:18:21 -0800) 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:299869 Archived-At: > From: Yuan Fu > Date: Tue, 15 Nov 2022 10:18:21 -0800 > Cc: Stefan Monnier , > theo@thornhill.no, > emacs-devel@gnu.org > > > Maybe we should grow some augmentations for tree-sitter, at least > > given enough time. Or maybe it's possible to identify the parts where > > this happens by some tree-sitter indications, and tweak the faces in > > those regions in some way. > > I don’t know how could you improve this in tree-sitter since macros are literally “define you own syntax”. We can reasonably fix the highlighting for some of our macros like DEFUN. As a demonstration I added some emacs-devel-specific rules (that are disabled by default). Run this: > > (add-hook 'c-ts-mode-hook > (lambda () > (treesit-font-lock-recompute-features '(emacs-devel)))) > > And restart c-ts-mode, and DEFUN’s should look normal now. I will try that when I have time, thanks. But if this indeed works well, why not do something similar to fix more warnings? And why not make this the default, instead of asking users to write mode hooks?