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: Sat, 12 Nov 2022 14:21:11 +0200 Message-ID: <834jv4nz2g.fsf@gnu.org> References: <87tu36em9t.fsf@thornhill.no> <45FD2F78-F15B-488B-9348-A8E298D8AD35@gmail.com> <87v8nmyqqp.fsf@thornhill.no> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26937"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, emacs-devel@gnu.org To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 12 13:22:07 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 1otpWR-0006sG-Uq for ged-emacs-devel@m.gmane-mx.org; Sat, 12 Nov 2022 13:22:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otpVV-0003sX-Cb; Sat, 12 Nov 2022 07:21:09 -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 1otpVT-0003sK-E0 for emacs-devel@gnu.org; Sat, 12 Nov 2022 07:21: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 1otpVS-0001yn-RZ; Sat, 12 Nov 2022 07:21: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=pqiY03i39DfXmF5ezm6vb3Ql/pEFTLYM0czsx6T9Nv4=; b=I0lCK7QaN8L9 q8xZisHVm/KEkyAMgUVkSKhiLDDEFV/ZUQo0fsE01hmz7AvNxUTwT8ZlGz8MZwbbjm5EP6i4kb2F/ mmCqMESZu13RKBGb0QPwoxpmulCGdoGsQS7A4CxscYWwApqZz/ohlCO9VXmCzpFzNmQxn4+59MnyN mab1xRWWOQpd+IDxrEqGfFIqq12Sg+UxTVFpYznv8kYr4UFwOCmu0tcv89HOJRAFLdXojSjGpW5qX UzWThhMQR9okirE1aCumTUpqmfDheKq61q433F4Zr3JGeS6xWaPlWoE3DnZd4qyBsE7L+sZV5lMzv ymcQlTSD6ZmCoNl+y1qbzA==; 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 1otpVR-0001m6-NZ; Sat, 12 Nov 2022 07:21:06 -0500 In-Reply-To: <87v8nmyqqp.fsf@thornhill.no> (emacs-devel@gnu.org) 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:299640 Archived-At: > Cc: emacs-devel@gnu.org > Date: Fri, 11 Nov 2022 07:01:02 +0100 > From: Theodor Thornhill via "Emacs development discussions." > > See below patch. The struct issue was an ordering problem when I > extracted the styles. Should be good now Thanks, a few minor comments below. > diff --git a/etc/NEWS b/etc/NEWS > index 9ed78bc6b3..3ce9810ece 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -2786,8 +2786,32 @@ when visiting JSON files. > ** New mode ts-mode'. > Support is added for TypeScript, based on the new integration with > Tree-Sitter. There's support for font-locking, indentation and > -navigation. Tree-Sitter is required for this mode to function, but if > -it is not available, we will default to use 'js-mode'. > +navigation. Tree-Sitter is required for this mode to function. > + > +** New mode c-ts-mode'. > +Support is added for C, based on the new integration with > +Tree-Sitter. There's support for font-locking, indentation and > +navigation. Tree-Sitter is required for this mode to function. First, please use 2 spaces between sentences. Next, I suggest a slightly different boilerplate for these items: ** New mode FOO-ts-mode. A major mode based on the Tree-sitter library for editing programs in the FOO language. It includes support for font-locking, indentation, and navigation. > +(defvar c++-ts-mode--preproc-keywords > + '("#define" "#if" "#ifdef" "#ifndef" "#else" "#elif" "#endif" "#include") > + "C++ keywords for tree-sitter font-locking.") This list seems to be incomplete: what about the following? #error #warning #include_next #line #pragma Doesn't Tree-sitter's C++ grammar support those? > +(defvar c-ts-mode--keywords > + '("const" "default" "enum" "extern" "inline" "static" > + "struct" "typedef" "union" "volatile" "goto" "register" > + "sizeof" "return" > + "while" "for" "do" "continue" "break" > + "if" "else" "case" "switch") > + "C keywords for tree-sitter font-locking.") Are these all the keywords in C? Or is it just what Tree-sitter's C parser support for now? > +(defvar c-ts-mode--preproc-keywords > + '("#define" "#if" "#ifdef" "#ifndef" "#else" "#elif" "#endif" > + "#include") > + "C keywords for tree-sitter font-locking.") Same comment here about additional preprocessor directives.