Subject: bug#65182: 29.1.50; c-ts-mode wants to outdent brace

From: Eli Zaretskii <[email-masked]>
Date: Wed, 09 Aug 2023 19:34:12 +0300

> From: Robert Pluim <[email-masked]>
> Cc: Yuan Fu <[email-masked]>,  [email-masked]
> Date: Wed, 09 Aug 2023 18:30:44 +0200
> 
> >>>>> On Wed, 09 Aug 2023 19:26:10 +0300, Eli Zaretskii <[email-masked]> said:
> 
>     >> From: Robert Pluim <[email-masked]>
>     >> Date: Wed, 09 Aug 2023 17:24:44 +0200
>     >> 
>     >> 
>     >> >From an emacs-29 checkout:
>     >> 
>     >> src/emacs -Q src/process.c
>     >> M-g g 6025 RET
>     >> TAB ; nothing happens
>     >> M-x c-ts-mode
>     >> TAB ; the '{' moves left two spaces
>     >> 
>     >> The code around there looks like this:
>     >> 
>     >> #ifdef HAVE_GNUTLS
>     >> /* If we have an incompletely set up TLS connection,
>     >> then defer the sentinel signaling until
>     >> later. */
>     >> if (NILP (p->gnutls_boot_parameters)
>     >> && !p->gnutls_p)
>     >> #endif
>     >> { <= line 6025
>     >> pset_status (p, Qrun);
>     >> /* Execute the sentinel here.  If we had relied on
>     >> status_notify to do it later, it will read input
>     >> from the process before calling the sentinel.  */
>     >> exec_sentinel (proc, build_string ("open\n"));
>     >> }
>     >> 
>     >> Iʼd tell you what my libtree-sitter-c version was if I knew how to get
>     >> that information. I installed it on July 28th
>     >> 
>     >> (I donʼt think this is a duplicate of bug#65006, the patch there does
>     >> not affect this behaviour)
> 
>     Eli> It's most probably because of the preprocessor mess around the line.
> 
> Maybe, but c-mode works fine.

Sure.  The problem with c-ts-mode is because the tree-sitter C parser
doesn't really grok cpp directives, since they are not part of the C
language grammar.  We have some workarounds in some cases, but I'll
let Yuan chime in about this particular one.