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:13:16 +0200 Message-ID: <83pmdrkyj7.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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30352"; 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:14:01 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 1ou93w-0007Xd-6R for ged-emacs-devel@m.gmane-mx.org; Sun, 13 Nov 2022 10:14:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ou93A-0007AJ-G1; Sun, 13 Nov 2022 04:13:12 -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 1ou938-0007A1-H6 for emacs-devel@gnu.org; Sun, 13 Nov 2022 04:13:10 -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 1ou937-00050p-Nz; Sun, 13 Nov 2022 04:13:09 -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=Zm1fHqQBm/tpDDn/Y+E6vhtrdgZ8b7gIudTN5lNWd4E=; b=goWoIoP3oaLH F3vmyWexvGuCe4iUN35sWXVaayHK056uh+NLaffsWRw1+drAd9DDarJuG62l42nYjiY2Jl2lF0cBO w45iHv3suJJjY5aUh9KbDCofQBWwvMe30aFd1y8zSS1wCODL0fatI7IFSTrMrH0mTfe6rCX0THk9t +yKi7OaL8tHe5Xw4Y6Ppe4MDlLTJnRO9YaOfjbSa+TalDSOsv0x2rUC1DqFobG5odsFmDBBjWkf8g og6CwBBEEQTW1bgEJYlxWDi/VeOZ/89W41DNBHqw6bmybjBsR96gAvXbnGa3KvTtEE7+WI5Cbjg7Z tcf1VB69/f9Gr3YcuaW/sA==; 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 1ou937-0001g0-6g; Sun, 13 Nov 2022 04:13:09 -0500 In-Reply-To: <87sfiogcbm.fsf@thornhill.no> (message from Theodor Thornhill on Sat, 12 Nov 2022 21:14:21 +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:299714 Archived-At: > From: Theodor Thornhill > Cc: Eli Zaretskii , emacs-devel@gnu.org, monnier@iro.umontreal.ca > Date: Sat, 12 Nov 2022 21:14:21 +0100 > > Yuan Fu writes: > > >> See new patch here - following Stefans keen eye ;-) > > > > Applied and pushed, thanks ;-) > > Great news! Thanks, all! Thanks. The new C mode looks good, but I have a couple of issues with it. First, something strange is going on when I type new code. Here's a recipe: emacs -Q C-x C-f newfile.c RET M-x c-ts-mode RET Type: int foo (void) { At this point, "int" is in font-lock-warning-face -- why? Next, with point after the brace, type RET -- this doesn't indent 2 spaces, as I'd expect -- why? Typing TAB to indent doesn't help, either. I then type "int bar = 0;". Typing RET after that doesn't indent, either. 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. Type } to close the function. I now have this: int foo (void) { int bar = 0; } But "int" is still in font-lock-warning-face -- why? Next, I type this: struct foo { int bar; }; The result is that all of the struct, except the closing brace, is in font-lock-warning-face -- why? Again, adding an empty line before that fixes fontifications, and the fontification stays correct even after removing that empty line. If I type struct bar { int foo; }; then the opening brace and "int foo;" are in font-lock-warning-face. 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. Thanks. P.S. If these problems are non-trivial, it might be best to file a bug report for each one. But the last issue, the one about doing more stuff like CC Mode does, is something we should discuss here, I think, since this is basic design, and similar issues could exist for other modes whose *-ts-mode variants were installed on the branch.