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: Sun, 13 Nov 2022 11:56:13 +0200 Message-ID: <83leofkwjm.fsf@gnu.org> References: <87tu36em9t.fsf@thornhill.no> <45FD2F78-F15B-488B-9348-A8E298D8AD35@gmail.com> <87v8nmyqqp.fsf@thornhill.no> <834jv4nz2g.fsf@gnu.org> <871qq8hsj1.fsf@thornhill.no> <83iljklzmo.fsf@gnu.org> <87v8nkgcqj.fsf@thornhill.no> <87sfiogcbm.fsf@thornhill.no> <83pmdrkyj7.fsf@gnu.org> <87v8njw5th.fsf@thornhill.no> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28483"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, emacs-devel@gnu.org, monnier@iro.umontreal.ca To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 13 10:56:48 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 1ou9jL-0007Dc-Mk for ged-emacs-devel@m.gmane-mx.org; Sun, 13 Nov 2022 10:56:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ou9in-0001AT-N3; Sun, 13 Nov 2022 04:56:13 -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 1ou9ih-0001AD-HN for emacs-devel@gnu.org; Sun, 13 Nov 2022 04:56:07 -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 1ou9ig-0002yB-1X; Sun, 13 Nov 2022 04:56:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=KEw7Z3XTDxm98A5Wr+I5FGjtHxsY4twEiDbeh5EhFng=; b=jHp/m5l5R30E AB7/AM9JXhVS+i9NigCRgGhxnNmo5fFnIudRY0HyJGmw0uoiEC0wLCrY4QiAEiBcj6UIHNv8+g8DQ 9fgrjzaIDWHi4Rkxud7NPFaO/NC2rCAbHgVH8WovTRZoJD+eaEh9h4h/Hwy3eCLQuFJu1CS4ZeTSe 6nLjZMNQ8hYgwZVnT+4OM5aGdqHSvF2n7XUyZANjmNwWEGOJ+N4cJJKQFYADmVgftf8rE9wX32W/3 BpEFhHtOhfVRLyXIhfH24tFn94pwupC12B36jg0kg1Jtu5kfH9d/1v2arFSvyp4IMn8U5CqyGbmBQ fwD4Mafat2KJKLXIlWMClg==; 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 1ou9ie-0002rY-K2; Sun, 13 Nov 2022 04:56:05 -0500 In-Reply-To: <87v8njw5th.fsf@thornhill.no> (message from Theodor Thornhill on Sun, 13 Nov 2022 10:40:26 +0100) 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:299716 Archived-At: > From: Theodor Thornhill > Cc: casouri@gmail.com, emacs-devel@gnu.org, monnier@iro.umontreal.ca > Date: Sun, 13 Nov 2022 10:40:26 +0100 > > > But if I add an empty line at BOB, the fontification becomes as > > expected, and doesn't go back to font-lock-warning-face even if I then > > remove that empty line. > > > > This is likely due to either treesit or tree-sitter or tree-sitter-c not > dealing properly with the root node. Maybe Yuan has some insight here? This sounds like we don't update tree-sitter under some conditions, IOW a bug of sorts. > I think the best solution is just to remove the > > ``` > :language mode > :override t > :feature 'error > '((ERROR) @font-lock-warning-face) > ``` What are the downsides of removing this? what will we lose? > > Next, if I type M-;, I get a C++-style comment delimiter "//". It > > sounds like this is the only style of comments supported? More > > generally, if I compare c-basic-common-init and c-common-init from CC > > Mode with c-ts-mode, I see that the former has much more > > initializations than the latter. So I think we should audit what CC > > Mode does here and see what else is relevant. Alternatively, we could > > consider c-ts-mode be a minor mode of CC Mode, which only changes the > > fontification, the indentation, and the navigation parts. > > > > I can take a look at that this evening - and see what else I can come up > with. I agree with the comment style Thanks. > Your issues are two-fold. The warning face is super easy, but the > indenting of error nodes may need a change of perspective. Tree-sitter > works best when syntax is correct, even though it handles errors pretty > well. The mode must do something sensible when code is incomplete, and thus "incorrect". At the very least the fontification and indentation should become fixed once the code becomes complete/correct, and that is not what happens as things are now.