From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Tree sitter support for C-like languages Date: Tue, 15 Nov 2022 23:58:57 -0800 Message-ID: <5C8F6B71-5610-4472-ACE0-7B1AD087FFA5@gmail.com> 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> <83y1scgj0e.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="15717"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, theo@thornhill.no, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 16 08:59:33 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 1ovDKV-0003lK-7P for ged-emacs-devel@m.gmane-mx.org; Wed, 16 Nov 2022 08:59:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovDK5-0006xW-Pw; Wed, 16 Nov 2022 02:59: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 1ovDK3-0006xA-RE for emacs-devel@gnu.org; Wed, 16 Nov 2022 02:59:03 -0500 Original-Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovDK2-00074y-7u; Wed, 16 Nov 2022 02:59:03 -0500 Original-Received: by mail-pg1-x52f.google.com with SMTP id q1so15931794pgl.11; Tue, 15 Nov 2022 23:59:01 -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=GNqGAXFQl3gKj2nC8nKHq6Zku3sp/zSlaLvYI5bPwxg=; b=Gx+1pFqfT0ueQ7MlRC93dKprZZ3GKWX3OmxPDFk5TvITnojXesu/yZceiELeKiL4tI t/bfzNSP/AaPXktx3BsCbxj+7stkV5xI03XxMpJR8KSxUFWvtXAqRWwmCWx+ysAfwi06 Zla5/BhNlnhLn8X5LTtSjTOmISfgY1HJ7NSuNG2j3yCUWboBvZZLYU/BoNk2QINkMpKN qb+3BSvPscrgV/5Qvf7emY1DrmI0nI760tTfg5oPWI6E2bead7vwHMbee50qC+wCY4di CpvJqnQg2jDa/dkOGSLABokhWWmGojzlubixjTc1gDNHLH4Nbf/3jSMR7ORFjhukhrQF z+Ug== 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=GNqGAXFQl3gKj2nC8nKHq6Zku3sp/zSlaLvYI5bPwxg=; b=F15najDs26a5Cv9yy5gz6cyMcTLoLkYg9iVglewikZYujIYhU2yb32YZJ+u+xipiq6 pq4ZWqHSuYXxrqXeRCZUhnPYC2ol6isS/vgxMv3+wxrlfVByNAmd7QtlOUCNGnwnrHAV 5tej2O8cJgIX68MWC6uTbhEY+89VovGjHBVU6+cyVEHDbvtOYkGdRBNxPmcTk/BKQEGz SkZNKlTqUqHdob38Dnxm8fX5P8BxEHymUfohFsRIrT8PQfXEGOIiJI5Z/wcnchcLmDnM WUufXcU49wX1MTLZP0K/5Yx/WHdHGGmOin14CjM58FPbqJKZzftMF5pfXsGgIXrVo+a9 IllQ== X-Gm-Message-State: ANoB5pkYIonAgXcqLA6MPV6/c6PGaaIsIfMIPoqQ+8Hy47dwDd/fbVEd vmJwVOjTsViJNw4kE+zMGpFS5wxOQec= X-Google-Smtp-Source: AA0mqf6oL4vGDT4PvRt5TNeWoJXyY3ZS80/1PvwNCCWmFN7Nfa/w8297dc1DkS+RX628Qpi7nVwlsA== X-Received: by 2002:a63:da0c:0:b0:470:8a45:32a8 with SMTP id c12-20020a63da0c000000b004708a4532a8mr18794949pgh.543.1668585539916; Tue, 15 Nov 2022 23:58:59 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id na4-20020a17090b4c0400b0020c899b11f1sm886641pjb.23.2022.11.15.23.58.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2022 23:58:59 -0800 (PST) In-Reply-To: <83y1scgj0e.fsf@gnu.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=casouri@gmail.com; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:299905 Archived-At: > On Nov 15, 2022, at 10:38 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Tue, 15 Nov 2022 10:18:21 -0800 >> Cc: Stefan Monnier , >> theo@thornhill.no, >> emacs-devel@gnu.org >>=20 >>> 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. >>=20 >> I don=E2=80=99t know how could you improve this in tree-sitter since = macros are literally =E2=80=9Cdefine you own syntax=E2=80=9D. 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: >>=20 >> (add-hook 'c-ts-mode-hook >> (lambda () >> (treesit-font-lock-recompute-features '(emacs-devel)))) >>=20 >> And restart c-ts-mode, and DEFUN=E2=80=99s should look normal now. >=20 > I will try that when I have time, thanks. But if this indeed works > well, why not do something similar to fix more warnings? =20 Truth to be told, I don=E2=80=99t know how to fix errors around = preprocessor directive (#ifdef=E2=80=99s). Our macros shouldn=E2=80=99t = be hard to fix. We can fix them as we encounter them. > And why not > make this the default, instead of asking users to write mode hooks? Because this is Emacs-specific? It specifically fixes highlight for the = DEFUN macro, nothing else. We can add some dir-local config that = automatically enables this. Yuan=