From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: Tree sitter support for C-like languages Date: Sun, 13 Nov 2022 11:13:24 +0100 Message-ID: <963E740B-B9BA-49E3-A64E-501394DFE41A@thornhill.no> 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> <83leofkwjm.fsf@gnu.org> Mime-Version: 1.0 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="33178"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, emacs-devel@gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 13 11:14:59 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 1ouA0w-0008OO-Jp for ged-emacs-devel@m.gmane-mx.org; Sun, 13 Nov 2022 11:14:58 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouA0E-0006D6-4k; Sun, 13 Nov 2022 05:14:14 -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 1ouA06-0006Cd-MS for emacs-devel@gnu.org; Sun, 13 Nov 2022 05:14:06 -0500 Original-Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouA04-0005kg-Kj; Sun, 13 Nov 2022 05:14:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668334438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=98bRd2cGH1cJAcvuKWKu00q7fkH3zf4xcWc1gil3gtA=; b=YjK2gF4a7rU0Lp8xsikwJB4EBKcSBfSxoSt8u4fHtV9+aUHFbso99zGp/2/lGX4aYasb78 cv1/HwxCPJfrh8HXaNX6dcUiCVRDUP7/QKUQeMi1XAbtt/C0JSHpH9v/WMrUrSRMJ5sMlo jrrBvocUW+LdlLh/WYYY5hKSypacbJnxg3M/frK+dmENBn23yH7p5UmBKXYaBcCENT2p2L kU03fpAxBo0/OhwMig/JwxeN7K3Q3pvDMz9e+x9TNGdAWVTdjtZwPr8RGMN/Z0YioqiHN4 SbFNzqSPexzCK2LrCXlNAPVWc9o1WX6aYbFZxaYtBYxCflHQv5JcKqXo5VXjdQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <83leofkwjm.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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:299717 Archived-At: On 13 November 2022 10:56:13 CET, Eli Zaretskii wrote: >> From: Theodor Thornhill >> Cc: casouri@gmail=2Ecom, emacs-devel@gnu=2Eorg, monnier@iro=2Eumontreal= =2Eca >> Date: Sun, 13 Nov 2022 10:40:26 +0100 >>=20 >> > 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 the= n >> > remove that empty line=2E >> > >>=20 >> This is likely due to either treesit or tree-sitter or tree-sitter-c no= t >> dealing properly with the root node=2E Maybe Yuan has some insight her= e? > >This sounds like we don't update tree-sitter under some conditions, >IOW a bug of sorts=2E > >> I think the best solution is just to remove the >>=20 >> ``` >> :language mode >> :override t >> :feature 'error >> '((ERROR) @font-lock-warning-face) >> ``` > >What are the downsides of removing this? what will we lose? > Absolutely nothing=2E Only the yellow color=2E >> > Next, if I type M-;, I get a C++-style comment delimiter "//"=2E 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=2E So I think we should audit what C= C >> > Mode does here and see what else is relevant=2E Alternatively, we co= uld >> > consider c-ts-mode be a minor mode of CC Mode, which only changes the >> > fontification, the indentation, and the navigation parts=2E >> > >>=20 >> I can take a look at that this evening - and see what else I can come u= p >> with=2E I agree with the comment style > >Thanks=2E > >> Your issues are two-fold=2E The warning face is super easy, but the >> indenting of error nodes may need a change of perspective=2E Tree-sitt= er >> works best when syntax is correct, even though it handles errors pretty >> well=2E > >The mode must do something sensible when code is incomplete, and thus >"incorrect"=2E 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=2E Yes=2E By applying that patch we are 98% there=2E I'll tweak it tonight wi= thout auto-closing-brace enabled=2E I use them, so my choices are based on = that=2E Just apply the patch in the meantime, and test some more if your time perm= its :-) Thanks, Theo