unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 65182@debbugs.gnu.org, Robert Pluim <rpluim@gmail.com>
Subject: bug#65182: 29.1.50; c-ts-mode wants to outdent brace
Date: Thu, 10 Aug 2023 14:55:52 -0700	[thread overview]
Message-ID: <7F726A8D-8EE9-4F7B-87F9-EBC0D41A11D9@gmail.com> (raw)
In-Reply-To: <835y5okwe3.fsf@gnu.org>



> On Aug 9, 2023, at 9:34 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Robert Pluim <rpluim@gmail.com>
>> Cc: Yuan Fu <casouri@gmail.com>,  65182@debbugs.gnu.org
>> Date: Wed, 09 Aug 2023 18:30:44 +0200
>> 
>>>>>>> On Wed, 09 Aug 2023 19:26:10 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> 
>>>> From: Robert Pluim <rpluim@gmail.com>
>>>> 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.

It’s the same problem: tree-sitter grammar can’t meaningfully parse directives. Whatever in the directives are severed from the main parse tree. And to give you guys an explanation, the bracket is outdented because the if part isn’t taken into consideration, and the bracket is outdented against bracket one level higher.

	      else
		{            <--------- outdented against 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) <---- the if is ignored
		      && !p->gnutls_p)
#endif
		    {       <------------- outdented
		      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"));
		    }

Yuan 




  reply	other threads:[~2023-08-10 21:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 15:24 bug#65182: 29.1.50; c-ts-mode wants to outdent brace Robert Pluim
2023-08-09 16:26 ` Eli Zaretskii
2023-08-09 16:30   ` Robert Pluim
2023-08-09 16:34     ` Eli Zaretskii
2023-08-10 21:55       ` Yuan Fu [this message]
2023-08-12  7:22         ` Eli Zaretskii
2023-09-01 21:08           ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7F726A8D-8EE9-4F7B-87F9-EBC0D41A11D9@gmail.com \
    --to=casouri@gmail.com \
    --cc=65182@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).