Eli Zaretskii writes: >> 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. > Thanks! >> 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. > Yeah - my slipup. > 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. > Sure - adopted. >> +(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? > Doesn't seem like it does, no. >> +(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? > I added a few more. Some were missing, that's true. >> +(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. Same answer here :) See below patch. Please note that I now have merged C and C++ into one file, and both inherit from a new parent mode: 'c-ts-mode--base-mode'. I simplified some of the indentation rules as well. Unless some of you have any strong objections I think applying them to feature/tree-sitter now is a good time, to allow other people to more easily giving them a testrun. What do you think? Theo