emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree sitter support for C-like languages


From: Eli Zaretskii
Subject: Re: Tree sitter support for C-like languages
Date: Sun, 13 Nov 2022 11:13:16 +0200

> From: Theodor Thornhill <theo@thornhill.no>
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org, 
> monnier@iro.umontreal.ca
> Date: Sat, 12 Nov 2022 21:14:21 +0100
> 
> Yuan Fu <casouri@gmail.com> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]