GNU bug report logs - #61208
29.0.60; treesit-beginning/end-of-defun problem with macros in c-ts-mode

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: yingchao.yang@HIDDEN; merged with #61209; dated Wed, 1 Feb 2023 09:14:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Forcibly Merged 61208 61209. Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 61208 <at> debbugs.gnu.org:


Received: (at 61208) by debbugs.gnu.org; 2 Feb 2023 18:22:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 02 13:22:41 2023
Received: from localhost ([127.0.0.1]:35791 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNeEK-0004i3-St
	for submit <at> debbugs.gnu.org; Thu, 02 Feb 2023 13:22:41 -0500
Received: from eggs.gnu.org ([209.51.188.92]:54552)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pNeEI-0004hl-8z
 for 61208 <at> debbugs.gnu.org; Thu, 02 Feb 2023 13:22:39 -0500
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 <eliz@HIDDEN>)
 id 1pNeEA-00057D-SH; Thu, 02 Feb 2023 13:22:30 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=TbpUY1l1QJ+7A75SRmhiVZlQtqCB/UIIEtb7Ngf8zX4=; b=ikOpKIdUzLJ/12EnjI6o
 KMb7BmWvQn4HKAojHtvXhgC8r3fessa3MXPL0RHUTAfXSD3Ne0O4tMl8ddFsXhR2wnzWS/QafQFBy
 aXn8UPNxK6T2cKIni7ZzpmmJyU1qR3RhMxwbdB4GWTYJeDmL3IyuVKvC1GL6x7E5yJtBIlr+Lxub+
 7siq4B2NSGJJ18HjUpui8TvFHvHevzVEdojr75VqvH6YHHKdYbCWcfvqqY/j8aGSaokDOeaFRlmT2
 tvNW0TPKugttLbcYdzf+Dh9m+f0a7DEQ+oc0rNstmKlZlJx3/geqD6j4HNAJkS+T4Aji/rVCDoLgS
 KfFFo8Zl2qjHSw==;
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 <eliz@HIDDEN>)
 id 1pNeEA-0006kF-Bd; Thu, 02 Feb 2023 13:22:30 -0500
Date: Thu, 02 Feb 2023 20:22:31 +0200
Message-Id: <83h6w4vsew.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: casouri@HIDDEN
In-Reply-To: <83wn50y0nw.fsf@HIDDEN> (message from Eli Zaretskii on Thu, 02
 Feb 2023 09:41:23 +0200)
Subject: Re: bug#61208: 29.0.60;
 treesit-beginning/end-of-defun problem with macros in c-ts-mode
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 <834js51rf8.fsf@HIDDEN> <963AC74E-57EA-4478-AD4C-8210DBA7EC9C@HIDDEN>
 <83wn50y0nw.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61208
Cc: yingchao.yang@HIDDEN, theo@HIDDEN, 61208 <at> debbugs.gnu.org,
 yang.yingchao@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: yingchao.yang@HIDDEN, 61208 <at> debbugs.gnu.org, theo@HIDDEN,
>  yang.yingchao@HIDDEN
> Date: Thu, 02 Feb 2023 09:41:23 +0200
> From: Eli Zaretskii <eliz@HIDDEN>
> 
> > Treesit-defun-tactic being ’nested isn’t the problem here, at least not the direct cause of the problem. c-ts-mode doesn’t consider switch cases or if-else statements as defuns. It only considers function, struct, enum, union, as defun. So in a preprocessed C source file, C-M-a will move point to the beginning of the function, line E. It does not in this particular file because tree-sitter is thrown off by the SWITCH() and CASE() macro: it can’t tell what they are and parses them as function definitions.
> > 
> > I don’t object setting treesit-defun-tactic to ’top-level in c-ts-mode, though. It can hide problems like this. Just be aware that it merely hides the problem.
> 
> OK, I think I will make that change soon.

Done.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at 61208 <at> debbugs.gnu.org:


Received: (at 61208) by debbugs.gnu.org; 2 Feb 2023 07:41:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 02 02:41:35 2023
Received: from localhost ([127.0.0.1]:60603 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNUDv-0002RX-C6
	for submit <at> debbugs.gnu.org; Thu, 02 Feb 2023 02:41:35 -0500
Received: from eggs.gnu.org ([209.51.188.92]:44766)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pNUDr-0002RH-KH
 for 61208 <at> debbugs.gnu.org; Thu, 02 Feb 2023 02:41:33 -0500
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 <eliz@HIDDEN>)
 id 1pNUDk-0002hl-7J; Thu, 02 Feb 2023 02:41:24 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=1XrsIBM6bWQ/MKvofcw3zaIxduWjnUOVg6jzXCLcQoU=; b=NrtSStRvDQFmByJBkTyQ
 KpPz9+HmQEN5+bsQ3KdEr2qRWfawn6pqqh9zZTddCph7oXLMBVWmPAf8g+RI7isw7JuzODAi7Haex
 I5Y6hkB2XtfJn6Q9lEJxxG3rS7xyAj5+Kurbi/AOZY9jrwlwIgyTVJV/A22Aq1KloxT9/LttAh1aq
 CYup7VnY89An8MCEbMo/HwHqTeeHscOM8UUfkVGyb00BfAKGJeLOTxiUt5cmcNEXGEIDPTX8Sj5rn
 jhtoYsAPpOt1Od8WHQ9AstOrG59TkA49JlwjMdoRm756EliCFihUMq43WThOpfEfQz755w7jx1PLQ
 28YDmRMuT4i4/g==;
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 <eliz@HIDDEN>)
 id 1pNUDj-0000U1-4p; Thu, 02 Feb 2023 02:41:23 -0500
Date: Thu, 02 Feb 2023 09:41:23 +0200
Message-Id: <83wn50y0nw.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <963AC74E-57EA-4478-AD4C-8210DBA7EC9C@HIDDEN> (message from
 Yuan Fu on Wed, 1 Feb 2023 18:32:26 -0800)
Subject: Re: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with
 macros in c-ts-mode
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 <834js51rf8.fsf@HIDDEN> <963AC74E-57EA-4478-AD4C-8210DBA7EC9C@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61208
Cc: yingchao.yang@HIDDEN, 61208 <at> debbugs.gnu.org, theo@HIDDEN,
 yang.yingchao@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Yuan Fu <casouri@HIDDEN>
> Date: Wed, 1 Feb 2023 18:32:26 -0800
> Cc: yingchao.yang@HIDDEN,
>  Theodor Thornhill <theo@HIDDEN>,
>  61208 <at> debbugs.gnu.org,
>  yang.yingchao@HIDDEN
> 
> Treesit-defun-tactic being ’nested isn’t the problem here, at least not the direct cause of the problem. c-ts-mode doesn’t consider switch cases or if-else statements as defuns. It only considers function, struct, enum, union, as defun. So in a preprocessed C source file, C-M-a will move point to the beginning of the function, line E. It does not in this particular file because tree-sitter is thrown off by the SWITCH() and CASE() macro: it can’t tell what they are and parses them as function definitions.
> 
> I don’t object setting treesit-defun-tactic to ’top-level in c-ts-mode, though. It can hide problems like this. Just be aware that it merely hides the problem.

OK, I think I will make that change soon.

> C++ and Java has classes, and when point is in a class, I think people expect to move to the prev/next method rather than the beginning/end of the class. So nested is still a better default IMO.

OK, I see your point, and I think you are right.

Btw, I noticed that C-M-a in c++-ts-mode goes to the BOL of the line
where the function/class/namespace is declared, whereas c++-mode goes
to the first non-whitespace character on that line.  Isn't the
c++-mode way better?  If you agree, we should probably change
c++-ts-mode (and maybe also java-ts-mode?) to behave like CC mode, but
we should also make sure that changing this will not adversely affect
"C-c C-q" and "C-M-q".  WDYT?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at 61208 <at> debbugs.gnu.org:


Received: (at 61208) by debbugs.gnu.org; 2 Feb 2023 07:16:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 02 02:16:51 2023
Received: from localhost ([127.0.0.1]:60584 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNTpz-0001q8-Gs
	for submit <at> debbugs.gnu.org; Thu, 02 Feb 2023 02:16:51 -0500
Received: from eggs.gnu.org ([209.51.188.92]:48228)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pNTpw-0001pu-CQ
 for 61208 <at> debbugs.gnu.org; Thu, 02 Feb 2023 02:16:51 -0500
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 <eliz@HIDDEN>)
 id 1pNTpm-0006R0-Ir; Thu, 02 Feb 2023 02:16:38 -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=pfqyHa2l3eUW1MYqqJJO4kZl6WW9jxkfEMzgU0+aGj8=; b=dOR3J/H7tsCb
 ZDCpfBWyIQ2ojmh9qVMHg5CMCBpftdbWenvSmffcf92tkvwabFte4oYr/oZuIjvArPAdb2fqyM6x0
 kR/lU7hbaCdCjNkQkxEgQMcBNSjWgzk1Isbgo7sVCxZglzKrw6Xvtu1J/sG9on7T2U5l6U+tYVU2N
 5TMOFfTWGCUpGYB7BLYTlFDYQx/VSsoWsKA03OV7uwMzPnlMSeK5Hblq4fnlmKQKTdLmJ0dns2NtG
 HMoQ4J0UGsKEDZWWYvvsiyfbTjpB9vz8/sxOpKSyXMSWvoG0CayTcBUW3s+7zLWLtQzzOAxj9X120
 +H952agtDOoRjBBiKegBGA==;
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 <eliz@HIDDEN>)
 id 1pNTpl-0001Pf-NW; Thu, 02 Feb 2023 02:16:38 -0500
Date: Thu, 02 Feb 2023 09:16:37 +0200
Message-Id: <83zg9wy1t6.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: yingchao.yang@HIDDEN
In-Reply-To: <tencent_E0B22481A7EDAB4288CF1F29DE232B7E7707@HIDDEN> (message
 from Yang Yingchao on Thu, 02 Feb 2023 08:48:55 +0800)
Subject: Re: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with
 macros in c-ts-mode
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 <834js51rf8.fsf@HIDDEN> <877cx11qg7.fsf@HIDDEN>
 <tencent_E0B22481A7EDAB4288CF1F29DE232B7E7707@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61208
Cc: 61208 <at> debbugs.gnu.org, casouri@HIDDEN, theo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Yang Yingchao <yang.yingchao@HIDDEN>
> Cc: Eli Zaretskii <eliz@HIDDEN>, Yuan Fu <casouri@HIDDEN>,
>  61208 <at> debbugs.gnu.org
> Date: Thu, 02 Feb 2023 08:48:55 +0800
> 
> But in the following C++ code, is it possible to make treesit-beginning/end-of-defun behaves the same as c++-mode ?
> 
> ,----
> | class Test       // LINE_D
> | {
> | public:
> |     Test(int i)  // LINE_C
> |     {
> |         SWITCH(i)
> |         {
> |             CASE(A)
> |             {
> |                 ;
> |             }
> |             CASE(B) // LINE_B
> |             {
> |                 ; // LINE_A
> |             }
> |         }
> |     }
> | };
> `----
> 
> 
> When cursor is at LINE_A, if in c++-mode, `C-M-a` moves cursor to LINE_C, which is correct.
> But in c++-ts-mode, behaviour of  `C-M-a` is wrong:
> if treesit-defun-tactic is nested, it moves to line_B, and if treesit-defun-tactic is top-level,
> it moves to LINE_D. Both of them are actually wrong...

I don't necessarily agree that c++-mode is right in this case.  I
think it's sheer luck that it goes to where it goes, and small changes
in the cpp macros could easily defeat its logic.

This is all a consequence of the fact that cpp macros that change the
language syntax could have unexpected influence on what the major mode
does with movement by defuns.  It is not a coincidence that such usage
of cpp macros is discouraged by modern coding conventions and
recommendations.

From my POV, there's no bug here.  There's no requirement that the TS
modes behave the same as their non-TS brethren.  One could argue that
we introduced the TS modes precisely _because_ they behave
differently.  And where cpp macros are involved, all bets are off to
begin with; good support for them is only possible by teaching the
mode about each and every macro.

So I'm okay with closing this bug as wontfix, unless someone has an
easy way of "fixing" it.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at 61208 <at> debbugs.gnu.org:


Received: (at 61208) by debbugs.gnu.org; 2 Feb 2023 06:45:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 02 01:45:40 2023
Received: from localhost ([127.0.0.1]:60452 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNTLi-0000vq-LN
	for submit <at> debbugs.gnu.org; Thu, 02 Feb 2023 01:45:40 -0500
Received: from out162-62-58-211.mail.qq.com ([162.62.58.211]:60605)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yang.yingchao@HIDDEN>) id 1pNNtW-0008WB-5z
 for 61208 <at> debbugs.gnu.org; Wed, 01 Feb 2023 19:56:10 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512;
 t=1675299357; bh=qwFld0HNGVk7RkGK6UtJgUK1BnuGjvLk69DucbFG//Q=;
 h=From:To:Cc:Subject:Date:References:Reply-To:In-reply-to;
 b=cZOzxHydLnVAgqvUCaUIrywwE+2Z8UztnQ5oFXyp7GbeVZ0847bDrd1n1N/dgTH19
 1k13ydonmdCMbRgrQUcY6BbT9Ym9Ex1SmpFKjhP6KKRwK9WyMYLQtS4I1T4swg2N1h
 P0SXyhWOv/HS9266gZShnNkHvpqEEkKN7uEc5nnA=
Received: from tbook ([60.26.148.134])
 by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP
 id DF734A63; Thu, 02 Feb 2023 08:55:55 +0800
X-QQ-mid: xmsmtpt1675299355tm4cupdu2
Message-ID: <tencent_E0B22481A7EDAB4288CF1F29DE232B7E7707@HIDDEN>
X-QQ-XMAILINFO: MgYKvQLNvE4j3Xf1au8/xq9RFkPycpX4UTgFpKjJYQWsNvpgnj6NBI/voofhme
 vUFpI7x2VOQN3iA7JQqS8eDr74EvgooFhrDNB9UEXn+HBKCOKFyd0Rjcqed5gYyGJXQ2y9lfh6BY
 oFzw1cgjodmrre13Db8sPjkyf2mJ/d+7lh57BzI7CXf31qFm3WEFJ+i+IzVTody1BQjDJO2mKRev
 0zE8IpuCmWiRzt7jK8Xsquyk4mOvp80BIFxO9N3p5y6XG9hPtxeiptTmAuQZqc6laLOhFoQmqW77
 PXJhWzKvzQVnnDogjjKH7OJl4lEfCIiy60g4tadEz4LxaCnaNg3glNP/HILXLSUSwG+h50lRE3DY
 9Y0jHaKzAYdbaSqcJoEjA6X9NuIqdctTEC81gE6RWDbd4dEnSeB229x37rOIl/gM2cLuTcWUcrpL
 kC17FPoAq523HZvFCSzHPthhJturLPyrA5GMamsB6orRZ2CIroBDpW4GDq3AMHPf2s3+Z1eOBM2Z
 fkmvyvwAy41lcVMFKMKLGcPpk2z12f/Q0vZZc0ONrS7b7sp4g/td2Y5GuP4HfJXq77G3aBdwXTXn
 sLDWwvBAcZvVAoqT2ZWPSyjtZo0jl3oMq2VNFPDta6lG1Jf2HdPF65N6QRhLpqyRvnXE91DKr5FL
 13DjQA1VA3R/bpw1ca5nv8NcmTqmuBYgiioeXGUndEIax7SwWKJugaa4QZuzKDme0yHOFT22sC31
 HnUag1kKwmwpX850X3pAO1QH8TJA4+utPALV7DG0r00+QrXg952OFiaEu2q8Gxxw0/U0n0vSN4mU
 24p/TsWqLvr/Ks8G4JOUKch0YHBLEOzS/wrM8x4LMZn28mGAISaSNIxMzgK7aL1XTltcxdzAik6E
 JLn0QXUe4np4jbMxepuMFeA/g6H6gT8G7lri1jnEXt2G2hIfs0YpUmLr8L1PZ4hk9iUJAqS90Bvc
 K4vHIzRnMnZPBp0vor0g==
From: Yang Yingchao <yang.yingchao@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
Subject: Re: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with
 macros in c-ts-mode
Date: Thu, 02 Feb 2023 08:48:55 +0800
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 <834js51rf8.fsf@HIDDEN> <877cx11qg7.fsf@HIDDEN>
User-agent: mu4e 1.8.13; emacs 29.0.60
In-reply-to: <877cx11qg7.fsf@HIDDEN>
Message-ID: <875yckubqb.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 3.6 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  On Wed, Feb 01 2023, Theodor Thornhill <theo@HIDDEN>
 wrote: > Eli Zaretskii <eliz@HIDDEN> writes: > >>> Cc: yang.yingchao@HIDDEN
 >>> Date: Wed, 01 Feb 2023 14:33:24 +0800 >>> From: Yang Yingchao via "Bug
 reports for GNU Emacs, >>> the Swiss army knife of text [...] 
 Content analysis details:   (3.6 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (yang.yingchao[at]qq.com)
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [162.62.58.211 listed in list.dnswl.org]
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.4 RDNS_DYNAMIC           Delivered to internal network by host with
 dynamic-looking rDNS
 3.2 HELO_DYNAMIC_IPADDR    Relay HELO'd using suspicious hostname (IP
 addr 1)
X-Debbugs-Envelope-To: 61208
X-Mailman-Approved-At: Thu, 02 Feb 2023 01:45:33 -0500
Cc: Eli Zaretskii <eliz@HIDDEN>, 61208 <at> debbugs.gnu.org,
 Yuan Fu <casouri@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: yingchao.yang@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.6 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Wed, Feb 01 2023, Theodor Thornhill <theo@HIDDEN>
    wrote: > Eli Zaretskii <eliz@HIDDEN> writes: > >>> Cc: yang.yingchao@HIDDEN
    >>> Date: Wed, 01 Feb 2023 14:33:24 +0800 >>> From: Yang Yingchao via "Bug
    reports for GNU Emacs, >>> the Swiss army knife of text [...] 
 
 Content analysis details:   (2.6 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (yang.yingchao[at]qq.com)
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [162.62.58.211 listed in list.dnswl.org]
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.4 RDNS_DYNAMIC           Delivered to internal network by host with
                             dynamic-looking rDNS
  3.2 HELO_DYNAMIC_IPADDR    Relay HELO'd using suspicious hostname (IP
                             addr 1)
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

--=-=-=
Content-Type: text/plain
Content-Disposition: inline

On Wed, Feb 01 2023, Theodor Thornhill <theo@HIDDEN> wrote:

> Eli Zaretskii <eliz@HIDDEN> writes:
>
>>> Cc: yang.yingchao@HIDDEN
>>> Date: Wed, 01 Feb 2023 14:33:24 +0800
>>> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>>>
>>>
>>> #define SWITCH()
>>> #define CASE(name)		case name:
>>>
>>> void func(int i)        // LINE_E
>>> {
>>>     SWITCH(i)           // LINE_D
>>>     {
>>>         CASE(A)         // LINE_C
>>>         {
>>>             ;
>>>         }
>>>         CASE(B)         // LINE_B
>>>         {
>>>             ;           // LINE_A
>>>         }
>>>     }
>>> }
>>>
>>> When cursor is at LINE_A, and stoke `C-M-a`, cursor will go to LINE_B;
>>> then `C-M-a` again, cursor goes to LINE_C, then `C-M-a` again, LINE_D,
>>> and `C-M-a` again, finally to LINE_E...
>>
>> Set treesit-defun-tactic to 'top-level, and your problem is solved.
>>
>> Yuan, Theo: do we want to have that set by default in ts-c-mode?  C
>> doesn't have nested functions, so it should be a better default, what
>> with all the cpp madness that the C grammar doesn't grok.
>>
>> Maybe also in C++ and Java -- AFAIU they don't have nested functions
>> either.
>>
>> WDYT?
>
> I'm fine with that change, I think.  Other, "smaller" constructs can be
> found as sentences or sexps anyway, I think.
>
> Theo

Thanks for the help.

But in the following C++ code, is it possible to make treesit-beginning/end-of-defun behaves the same as c++-mode ?

,----
| class Test       // LINE_D
| {
| public:
|     Test(int i)  // LINE_C
|     {
|         SWITCH(i)
|         {
|             CASE(A)
|             {
|                 ;
|             }
|             CASE(B) // LINE_B
|             {
|                 ; // LINE_A
|             }
|         }
|     }
| };
`----


When cursor is at LINE_A, if in c++-mode, `C-M-a` moves cursor to LINE_C, which is correct.
But in c++-ts-mode, behaviour of  `C-M-a` is wrong:
if treesit-defun-tactic is nested, it moves to line_B, and if treesit-defun-tactic is top-level,
it moves to LINE_D. Both of them are actually wrong...


-- 
Yang Yingchao
Yang Yingchao

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Feb 2023 06:45:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 02 01:45:44 2023
Received: from localhost ([127.0.0.1]:60454 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNTLo-0000vz-3s
	for submit <at> debbugs.gnu.org; Thu, 02 Feb 2023 01:45:44 -0500
Received: from lists.gnu.org ([209.51.188.17]:44836)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yang.yingchao@HIDDEN>) id 1pNOlv-0001Sn-5v
 for submit <at> debbugs.gnu.org; Wed, 01 Feb 2023 20:52:22 -0500
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 <yang.yingchao@HIDDEN>)
 id 1pNOlu-0003Hz-0T
 for bug-gnu-emacs@HIDDEN; Wed, 01 Feb 2023 20:52:18 -0500
Received: from out203-205-221-173.mail.qq.com ([203.205.221.173])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yang.yingchao@HIDDEN>)
 id 1pNOlq-00077F-Rc
 for bug-gnu-emacs@HIDDEN; Wed, 01 Feb 2023 20:52:17 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512;
 t=1675302730; bh=AMuK648lsB7iH2+aaX/wybI3LWiQeOyBDxtdDqR+ZSw=;
 h=From:To:Subject:Date:References:Reply-To;
 b=ceX7GfaMWPr1qIGB3VGETVLMfG3g21bA6BBnN/oXw67YZpquoLz2yaAgmWyiiHKqx
 ZH0o6Z2c5AyvSapwyLfEMtTlSxJS613YfEDlnGpoD2cdpaJttJuoagHeL+44gmMbZe
 fLvL1R25NSOZCrlKErSaDIvtA/PenDDjY+TMKvV4=
Received: from tbook ([60.26.148.134])
 by newxmesmtplogicsvrszc5-0.qq.com (NewEsmtp) with SMTP
 id CC3AA467; Thu, 02 Feb 2023 09:51:03 +0800
X-QQ-mid: xmsmtpt1675302663tzyy51cco
Message-ID: <tencent_0B94CF51357F1219A000EF364C21DAE7A206@HIDDEN>
X-QQ-XMAILINFO: OLnGMPzD2sDVtPkeBIbM96ifYUihayq2Zyo9Io8rcmNT3EfT2kObfD1gbV+rxz
 1kH+o0Ork17UC0rwDaozMIy8W0dhlS4qEGfdhP7I1VPboHTuwZlQLJsSgGpLKLL3Vn1GXCP9T+Wi
 Qi3uCI7zsefuCRybDm04EYq4E2CAxFgiwAgm93mdK92YDQwJtuJuAGKejDewms5mJ7mvUrIRUTdD
 NegBQF+6kGW6aZ7vtgoXDT4IiKEBIrp4TCCfjYJfHzQxZx6/uF8815F0aUvMfAnaF/wrKmhsBeCY
 TiQWvUPFDQsWXdzgXfoMI+QZVCDtssVW/wqSbgbWRInvP19yTChKiUHQIPacyepqTW+GHuf3JTel
 59VnmRTbclqiqDLax0lrwiCpdHV4dCvSz+9HHl/6J5IFHG7pvkQS4WWRhXhUjT+cZ7vIdUAIZlOz
 EBk987gm0LrauXF/bOh192pUroK0L3wzRWMLA/4BgK43tdD5agVSiEYAApEctkNXJy4VrvMDGMPr
 jCqQdcAo9130P8lGy3xAawl2ECpYHY4OIgZAAn2kiQLUW3Kmsx4AgFtMXrQDsga20ImhTV7FD1DX
 w8KIZXzsq98uNK4kNHMjqDNv1A4WDgDHLdDZrJPK8fYVEtkGiYy+FdVQGJ/dpm+SIQHwvrZD/xzA
 CVvlTCf9AhHPsdnghEMWN7Xrpvk/DXpguzjcsRl8wjVJuCa9JPkHqYmCy1Whj2JZesfEaE30voZV
 FTV4vqLd4pyh9twlR9HbAkfXvCm1Q/tdV3jRCr0KFxNUgYRKKsfHdX2JLOE6mCalViJNblXZEqRC
 peMlgPxTXkc9SoW3QGo7LxnetTYHct9ntr/r6f9bDtrng5aPX6+bnUMyBavE+XfsJ2abof0Rx6+3
 zyZC0+lJrvRMsB2TGmqIZH0WjiW5a/jixEFfVBCMqSzfyP+MHf0Wv57Eh2S4jevW5a+5sblMHeDO
 cPObrnGr7HG/OclGF0G35iPvKvf3lh9DkFXyQ0LGc=
From: Yang Yingchao <yang.yingchao@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Re: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with
 macros in c-ts-mode
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Date: Thu, 02 Feb 2023 09:48:19 +0800
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 <834js51rf8.fsf@HIDDEN> <877cx11qg7.fsf@HIDDEN>
 <875yckubqb.fsf@HIDDEN>
User-agent: mu4e 1.8.13; emacs 29.0.60
Message-ID: <875yckesxj.fsf@HIDDEN>
Received-SPF: pass client-ip=203.205.221.173;
 envelope-from=yang.yingchao@HIDDEN; helo=out203-205-221-173.mail.qq.com
X-Spam_score_int: 22
X-Spam_score: 2.2
X-Spam_bar: ++
X-Spam_report: (2.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
 DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HDRS_MISSP=1.398,
 HELO_DYNAMIC_IPADDR=1.951, RCVD_IN_DNSWL_NONE=-0.0001,
 RCVD_IN_MSPIKE_H2=-0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 02 Feb 2023 01:45:33 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: yingchao.yang@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain
Content-Disposition: inline

On Thu, Feb 02 2023, Yang Yingchao <yang.yingchao@HIDDEN> wrote:

> On Wed, Feb 01 2023, Theodor Thornhill <theo@HIDDEN> wrote:
>
>> Eli Zaretskii <eliz@HIDDEN> writes:
>>
>>>> Cc: yang.yingchao@HIDDEN
>>>> Date: Wed, 01 Feb 2023 14:33:24 +0800
>>>> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>>>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>>>>
>>>>
>>>> #define SWITCH()
>>>> #define CASE(name)		case name:
>>>>
>>>> void func(int i)        // LINE_E
>>>> {
>>>>     SWITCH(i)           // LINE_D
>>>>     {
>>>>         CASE(A)         // LINE_C
>>>>         {
>>>>             ;
>>>>         }
>>>>         CASE(B)         // LINE_B
>>>>         {
>>>>             ;           // LINE_A
>>>>         }
>>>>     }
>>>> }
>>>>
>>>> When cursor is at LINE_A, and stoke `C-M-a`, cursor will go to LINE_B;
>>>> then `C-M-a` again, cursor goes to LINE_C, then `C-M-a` again, LINE_D,
>>>> and `C-M-a` again, finally to LINE_E...
>>>
>>> Set treesit-defun-tactic to 'top-level, and your problem is solved.
>>>
>>> Yuan, Theo: do we want to have that set by default in ts-c-mode?  C
>>> doesn't have nested functions, so it should be a better default, what
>>> with all the cpp madness that the C grammar doesn't grok.
>>>
>>> Maybe also in C++ and Java -- AFAIU they don't have nested functions
>>> either.
>>>
>>> WDYT?
>>
>> I'm fine with that change, I think.  Other, "smaller" constructs can be
>> found as sentences or sexps anyway, I think.
>>
>> Theo
>

Thanks for the help.

But in the following C++ code, is it possible to make treesit-beginning/end-of-defun behaves the same as c++-mode ?

,----
| class Test       // LINE_D
| {
| public:
|     Test(int i)  // LINE_C
|     {
|         SWITCH(i)
|         {
|             CASE(A)
|             {
|                 ;
|             }
|             CASE(B) // LINE_B
|             {
|                 ; // LINE_A
|             }
|         }
|     }
| };
`----

When cursor is at LINE_A, if in c++-mode, `C-M-a` moves cursor to LINE_C, which is correct.
But in c++-ts-mode, behaviour of  `C-M-a` is wrong:
if treesit-defun-tactic is nested, it moves to line_B, and if treesit-defun-tactic is top-level,
it moves to LINE_D. Both of them are actually wrong...


--
Yang Yingchao
Yang Yingchao

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at 61208 <at> debbugs.gnu.org:


Received: (at 61208) by debbugs.gnu.org; 2 Feb 2023 02:32:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 01 21:32:45 2023
Received: from localhost ([127.0.0.1]:60259 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNPP3-0002Zz-Er
	for submit <at> debbugs.gnu.org; Wed, 01 Feb 2023 21:32:45 -0500
Received: from mail-pl1-f173.google.com ([209.85.214.173]:41939)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1pNPP1-0002Zm-GN
 for 61208 <at> debbugs.gnu.org; Wed, 01 Feb 2023 21:32:44 -0500
Received: by mail-pl1-f173.google.com with SMTP id jh15so469971plb.8
 for <61208 <at> debbugs.gnu.org>; Wed, 01 Feb 2023 18:32:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:references:message-id:content-transfer-encoding:cc:date
 :in-reply-to:from:subject:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=yprmDwQyh++haqqqeDO30uFvkJc6OGoT5AVciEW4ZB0=;
 b=WVv3dfEwemT/SE5krdkgJSlj8dpX9ru1TFe8kuwSLr8Z9MIeSTDtqDj7ULvEbPo3Rm
 AA4P5yTNmEpJsvyjegmlHsI3mkKsnkuMnqijBBbrFT8mhgwkWE1fwC7xu9/p9DEueUUH
 GogeSDvhCbImGSm7SuBs2nSEOWedrgGG6XC9B4isJ5y8eJmuMehzEQmj0jZz5K2uh+0K
 idSFIZU8qt24LaeKQB3EEMf45ArH3kpjy8iCiv1i8vxRNTi23W+HxB3XnlyGzC/5WyT3
 QtmosbB0jdAO5mFvLGeEX2xWyUG3NJMGjRJ9ef1y4j70VAcA8VHXWOE5Q5SDo2iOyukn
 dMuA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:references:message-id:content-transfer-encoding:cc:date
 :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=yprmDwQyh++haqqqeDO30uFvkJc6OGoT5AVciEW4ZB0=;
 b=kmXOT57XsarlSMKbhX4GqFkIvt049+qCi81M9xT4n/UP7rxH1Nav5p5kauzZNDLOBZ
 jiw2VNNfiqSpOpIOvv5dSfjQrdlFij2oqBsE/G0RyZpT6YaCmDxsToyR66Igg0cIUz4x
 oot9K5hD1h0Z+vOuVw1UCXEKJIxThxdxe7Vz7VJtu5k+gj/SXZ15G7JQlnxED4rX0G8c
 Ltmod9VnTtArL1puCguvhYpP32yjZkjB0DT6/lCEcSoTPUtDeL4DRMdYYlLyUYKkMVZm
 i6P28hWzcH2HJKhMX/AHoujML4YK2VIruRC72gslET5i1VVwjZLf3UJUJg3EO65CMUos
 O14w==
X-Gm-Message-State: AO0yUKXmtYgMEmFuDBtzocUgb8h/tBJZm0sWds8ykAYxW4BUgLBbzSxu
 MPcOu60nKzz+qHlfV1kQ0m4=
X-Google-Smtp-Source: AK7set+quIckpprQbK32NIjn4JLMoJ00trWJWXFDQM1swb8Z12dDBonBWHBymrmWpzH77GXdUOdMew==
X-Received: by 2002:a05:6a20:8b08:b0:b8:5881:5c3b with SMTP id
 l8-20020a056a208b0800b000b858815c3bmr4491136pzh.58.1675305157546; 
 Wed, 01 Feb 2023 18:32:37 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 z28-20020a63b91c000000b004785a63b44bsm11336331pge.43.2023.02.01.18.32.36
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 01 Feb 2023 18:32:37 -0800 (PST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\))
Subject: Re: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with
 macros in c-ts-mode
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <834js51rf8.fsf@HIDDEN>
Date: Wed, 1 Feb 2023 18:32:26 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <963AC74E-57EA-4478-AD4C-8210DBA7EC9C@HIDDEN>
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 <834js51rf8.fsf@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
X-Mailer: Apple Mail (2.3731.300.101.1.3)
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 61208
Cc: yingchao.yang@HIDDEN, 61208 <at> debbugs.gnu.org,
 Theodor Thornhill <theo@HIDDEN>, yang.yingchao@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



> On Feb 1, 2023, at 4:49 AM, Eli Zaretskii <eliz@HIDDEN> wrote:
>=20
>> Cc: yang.yingchao@HIDDEN
>> Date: Wed, 01 Feb 2023 14:33:24 +0800
>> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>>=20
>>=20
>> #define SWITCH()
>> #define CASE(name) case name:
>>=20
>> void func(int i)        // LINE_E
>> {
>>    SWITCH(i)           // LINE_D
>>    {
>>        CASE(A)         // LINE_C
>>        {
>>            ;
>>        }
>>        CASE(B)         // LINE_B
>>        {
>>            ;           // LINE_A
>>        }
>>    }
>> }
>>=20
>> When cursor is at LINE_A, and stoke `C-M-a`, cursor will go to =
LINE_B;
>> then `C-M-a` again, cursor goes to LINE_C, then `C-M-a` again, =
LINE_D,
>> and `C-M-a` again, finally to LINE_E...
>=20
> Set treesit-defun-tactic to 'top-level, and your problem is solved.
>=20
> Yuan, Theo: do we want to have that set by default in ts-c-mode?  C
> doesn't have nested functions, so it should be a better default, what
> with all the cpp madness that the C grammar doesn't grok.
>=20
> Maybe also in C++ and Java -- AFAIU they don't have nested functions
> either.

Treesit-defun-tactic being =E2=80=99nested isn=E2=80=99t the problem =
here, at least not the direct cause of the problem. c-ts-mode doesn=E2=80=99=
t consider switch cases or if-else statements as defuns. It only =
considers function, struct, enum, union, as defun. So in a preprocessed =
C source file, C-M-a will move point to the beginning of the function, =
line E. It does not in this particular file because tree-sitter is =
thrown off by the SWITCH() and CASE() macro: it can=E2=80=99t tell what =
they are and parses them as function definitions.

I don=E2=80=99t object setting treesit-defun-tactic to =E2=80=99top-level =
in c-ts-mode, though. It can hide problems like this. Just be aware that =
it merely hides the problem.

C++ and Java has classes, and when point is in a class, I think people =
expect to move to the prev/next method rather than the beginning/end of =
the class. So nested is still a better default IMO.

Yuan=




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at 61208 <at> debbugs.gnu.org:


Received: (at 61208) by debbugs.gnu.org; 1 Feb 2023 13:10:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 01 08:10:55 2023
Received: from localhost ([127.0.0.1]:56825 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNCt5-0005jm-9m
	for submit <at> debbugs.gnu.org; Wed, 01 Feb 2023 08:10:55 -0500
Received: from out-169.mta1.migadu.com ([95.215.58.169]:44859)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pNCt1-0005jQ-IX
 for 61208 <at> debbugs.gnu.org; Wed, 01 Feb 2023 08:10:53 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1675257050;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=p4SzuwynSu5MBvWuydrqS5pQW67Za6S+VywL9KfTkEs=;
 b=bdwGiS5f99JqFZMb9yG4NOb4Cfx8Bs8iqckVt9VhhQK+j+3iL+RFuJC4vyBeGhxp3Aw99h
 6CdrsZzGO7dbKa9y8L/aVA7VpmKe6GENVImR6LF8X6tGP3mbm2XP2rcjbOohDQRWrK1j3h
 4udDmmjV7FZlWnkZe2I46Mmieau9sW0nqfn+YN58T4qm8sy7ciAP+QtFhcU82HsmrRfmNC
 /hpYqWDgWyHvSHz7Ak/t/mMGAKTsKS/xQ+WrrZ0l7wm9H15KEAIGMc4St+vUnGKLdx1mM6
 ot/N9K63j19U3fseOZkIsjAIGmzzyR0r1KehMfOOmjOKIC9JL3Clsojhlv2HXw==
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>, yingchao.yang@HIDDEN, Yuan Fu
 <casouri@HIDDEN>
Subject: Re: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with
 macros in c-ts-mode
In-Reply-To: <834js51rf8.fsf@HIDDEN>
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 <834js51rf8.fsf@HIDDEN>
Date: Wed, 01 Feb 2023 14:10:48 +0100
Message-ID: <877cx11qg7.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61208
Cc: yang.yingchao@HIDDEN, 61208 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Cc: yang.yingchao@HIDDEN
>> Date: Wed, 01 Feb 2023 14:33:24 +0800
>> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>> 
>> 
>> #define SWITCH()
>> #define CASE(name)		case name:
>> 
>> void func(int i)        // LINE_E
>> {
>>     SWITCH(i)           // LINE_D
>>     {
>>         CASE(A)         // LINE_C
>>         {
>>             ;
>>         }
>>         CASE(B)         // LINE_B
>>         {
>>             ;           // LINE_A
>>         }
>>     }
>> }
>> 
>> When cursor is at LINE_A, and stoke `C-M-a`, cursor will go to LINE_B;
>> then `C-M-a` again, cursor goes to LINE_C, then `C-M-a` again, LINE_D,
>> and `C-M-a` again, finally to LINE_E...
>
> Set treesit-defun-tactic to 'top-level, and your problem is solved.
>
> Yuan, Theo: do we want to have that set by default in ts-c-mode?  C
> doesn't have nested functions, so it should be a better default, what
> with all the cpp madness that the C grammar doesn't grok.
>
> Maybe also in C++ and Java -- AFAIU they don't have nested functions
> either.
>
> WDYT?

I'm fine with that change, I think.  Other, "smaller" constructs can be
found as sentences or sexps anyway, I think.

Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at 61208 <at> debbugs.gnu.org:


Received: (at 61208) by debbugs.gnu.org; 1 Feb 2023 12:50:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 01 07:50:05 2023
Received: from localhost ([127.0.0.1]:56805 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pNCYv-0005F6-AG
	for submit <at> debbugs.gnu.org; Wed, 01 Feb 2023 07:50:05 -0500
Received: from eggs.gnu.org ([209.51.188.92]:56776)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pNCYq-0005EU-Gy
 for 61208 <at> debbugs.gnu.org; Wed, 01 Feb 2023 07:50:04 -0500
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 <eliz@HIDDEN>)
 id 1pNCYh-0003kR-GZ; Wed, 01 Feb 2023 07:49:51 -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=kpyLKJmo6WjBIs1dwKrPT/EWyRbw3Pn0ItNpCOetXlg=; b=Ea6/793cZXhA
 5zQiEJGmlDomkMq2efBatOKmh1UHjnazm0mVVTHuldeX1glVqhcsGuTxc/8Dul+vE+KhZMwTtDo/k
 7fl4jIl6gT/LoqXkVFAzhgGrXofOYUel5ombHljVPFGe4FLDKjt2cI780d/dAstlZMtosl9M/Gblz
 BKzjUfpSDV1jy/4AG6F8kTztyYrIJq6NwW+sc8ZKFcHUVibYxT97nR4hP1bsp/WICguw9CqtWm9z8
 /NkF8S2KU17+kyxoxlqMhE2MUtV9PmnyJ8Jgb9q/fwOb9iNwxHM/zW/g3k26mNkAeIm490NDUW4W9
 BcAwDq3awmdVxY67tczw2Q==;
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 <eliz@HIDDEN>)
 id 1pNCYf-0005je-Bh; Wed, 01 Feb 2023 07:49:50 -0500
Date: Wed, 01 Feb 2023 14:49:47 +0200
Message-Id: <834js51rf8.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: yingchao.yang@HIDDEN, Yuan Fu <casouri@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
 (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#61208: 29.0.60;
 treesit-beginning/end-of-defun problem with macros in c-ts-mode
References: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61208
Cc: yang.yingchao@HIDDEN, 61208 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: yang.yingchao@HIDDEN
> Date: Wed, 01 Feb 2023 14:33:24 +0800
> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> 
> #define SWITCH()
> #define CASE(name)		case name:
> 
> void func(int i)        // LINE_E
> {
>     SWITCH(i)           // LINE_D
>     {
>         CASE(A)         // LINE_C
>         {
>             ;
>         }
>         CASE(B)         // LINE_B
>         {
>             ;           // LINE_A
>         }
>     }
> }
> 
> When cursor is at LINE_A, and stoke `C-M-a`, cursor will go to LINE_B;
> then `C-M-a` again, cursor goes to LINE_C, then `C-M-a` again, LINE_D,
> and `C-M-a` again, finally to LINE_E...

Set treesit-defun-tactic to 'top-level, and your problem is solved.

Yuan, Theo: do we want to have that set by default in ts-c-mode?  C
doesn't have nested functions, so it should be a better default, what
with all the cpp madness that the C grammar doesn't grok.

Maybe also in C++ and Java -- AFAIU they don't have nested functions
either.

WDYT?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Feb 2023 09:13:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 01 04:13:16 2023
Received: from localhost ([127.0.0.1]:56445 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pN9B0-0005Yr-GX
	for submit <at> debbugs.gnu.org; Wed, 01 Feb 2023 04:13:16 -0500
Received: from lists.gnu.org ([209.51.188.17]:39102)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yang.yingchao@HIDDEN>) id 1pN6hy-0006YB-Qs
 for submit <at> debbugs.gnu.org; Wed, 01 Feb 2023 01:35:04 -0500
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 <yang.yingchao@HIDDEN>)
 id 1pN6hy-0006tK-Eg
 for bug-gnu-emacs@HIDDEN; Wed, 01 Feb 2023 01:35:02 -0500
Received: from out203-205-221-155.mail.qq.com ([203.205.221.155])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yang.yingchao@HIDDEN>)
 id 1pN6hp-0006pN-Ak
 for bug-gnu-emacs@HIDDEN; Wed, 01 Feb 2023 01:34:58 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512;
 t=1675233289; bh=tSdfXirZYrb/vBXzV3k3H7H4c30P8FDY+6GJ2RaLewE=;
 h=From:Reply-To:To:Cc:Subject:Date:In-reply-to;
 b=w+vcm5EmOm6JdxjuF8ucKdtvinNAy2nycSQlY8jrxY9nOeb7zIhmIzUnhLgiZwhDl
 J/nizcQfPMpXjE+2DtJ4olW6fB6CQK5HlAKV7CiAU8yAQg88g9NcSNBh1P2o+OO2NS
 uT2Ylm+FAzLMKMTvRjcFxXqkLmbsm+eZ3q2mqmjc=
Received: from tbook ([60.26.148.134])
 by newxmesmtplogicsvrszb6-0.qq.com (NewEsmtp) with SMTP
 id 8B08C0CA; Wed, 01 Feb 2023 14:34:48 +0800
X-QQ-mid: xmsmtpt1675233288t1ky4p9hp
Message-ID: <tencent_911881A0ED8B42D8CF38A994235BFE02B207@HIDDEN>
X-QQ-XMAILINFO: NvKyM24IHTKSmw8/uQqCtGQBcH3MzXne2IxHka9kTF7Ch6qUX1SEt7rZwXm0mX
 wYLQdxfkq2mLxTOm8e60bANJx+JvOi6wOlUrssyKLUqzbTMVdFyfHvorTkwBagy2d83NeCMTegUm
 6WFHF4AfDkDTzxHn/RSFkU/SGcjppifMLlzuoIXzxsPAFIYCpSv7i3zUzDJNERS/otOloIdnZ30k
 5BspjV/FZ4yglCNfw6BGSZOnT1tb8/66bp+WqJzt92+MTZFCT+UoN8K00WXOwK4mCoiITfim9cSA
 q9X7bX7iXFga7eF4q9xjYVf2Pry9atNz6ITuZic3M4AFXyTvxhK9oMHQrc3E3sWR2FjU2q7ORtUB
 ctYh5LHOO6D7YGbnJHTy9myrWLsbZPy29ES04QtOqznEa8HjOYGAKlbyZ6QIRBg7YvyhncehmTWI
 hHYgFAR5jghPRtu2PoYmVyRiQkVGSAwwrBElnzKgYiTXMUJCl5M4i45hWcbEss3gUZ/agFf8Ftqb
 OPWJg/0DdgfdIzGP9qRRXVq4EB8LOIqMK4OpxkzEjyAXbBqQDY/D7AsC+OcluGsXw0WV3/lQukZn
 2Us3Db7Wwe4/InXU89OWaZlfa5WPAHUpjlzDJwccyvP+91IBBwmnW7rClX1QvDJxHt7KlIrSkzwQ
 +7y4bgt4Nk5I8/+TMvPGStcF33RvNf9EoF/X19J4s2yErvscfZ1UBEqmPq41+Hmw7IEqvGWMvRKE
 roFb7OGXEbdB2JrV4yqWVKwpp4S0B5epPN3bbNdahTSxuCb1L8+z1WDKRZMVzueGoDCQ8/83W6yi
 8J3pDoJewvvQUgYpYBUcndl67Rkb6A2m8egg12ls33jXFmc+Ant9IF0O8pAYp0fcScmaMkoN7CTG
 LnBcsAL9iM8NugVqZehbs/tIoEAUGSaZgVFY0DezktdSkw6zjvX8zBJhCO0Fl1UjQmXf3cGAcu3G
 QkvVdWHjG+zmnorSKCAa3nsXl//rMXLPczc/92YjsZ66ebmq48lwI75C6mJ5Hwara9MKCNBCUECU
 lqM+fcIQ==
X-OQ-MSGID: <87o7qd99md.fsf@HIDDEN>
From: Yang Yingchao <yang.yingchao@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Re: 29.0.60;
 treesit-beginning/end-of-defun problem with macros in c-ts-mode
Date: Wed, 01 Feb 2023 14:33:24 +0800
In-reply-to: <fc907ec5049baaaff04d38dd4ed5ab996500a50b6d723604fff453aad543dc86@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=203.205.221.155;
 envelope-from=yang.yingchao@HIDDEN; helo=out203-205-221-155.mail.qq.com
X-Spam_score_int: 8
X-Spam_score: 0.8
X-Spam_bar: /
X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
 DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HELO_DYNAMIC_IPADDR=1.951, RCVD_IN_DNSWL_NONE=-0.0001,
 RCVD_IN_MSPIKE_H2=-0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 01 Feb 2023 04:13:09 -0500
Cc: yang.yingchao@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: yingchao.yang@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


#define SWITCH()
#define CASE(name)		case name:

void func(int i)        // LINE_E
{
    SWITCH(i)           // LINE_D
    {
        CASE(A)         // LINE_C
        {
            ;
        }
        CASE(B)         // LINE_B
        {
            ;           // LINE_A
        }
    }
}

When cursor is at LINE_A, and stoke `C-M-a`, cursor will go to LINE_B;
then `C-M-a` again, cursor goes to LINE_C, then `C-M-a` again, LINE_D,
and `C-M-a` again, finally to LINE_E...


On Wed, Feb 01 2023, Yang Yingchao <yang.yingchao@HIDDEN> wrote:

> Forgive me the mess...
>
>
> src
>
>
> On Wed, Feb 01 2023, Yang Yingchao <yang.yingchao@HIDDEN> wrote:
>
>> Hi **,
>>
>> From: Yang Yingchao <yang.yingchao@HIDDEN> Reply-To: yang.yingchao@HIDDEN
>> Date: Wed, 01 Feb 2023 14:19:30 +0800 Cc: yang.yingchao@HIDDEN To:
>> bug-gnu-emacs@HIDDEN Subject: 29.0.60; treesit-beginning/end-of-defun problem
>> with macros in c-ts-mode –text follows this line–
>>
>> treesit-beginning/end-of-defun in c-ts-mode not work correctly with macros.
>>
>> For example, in the following codes:
>>
>> #define SWITCH() #define CASE(name) case name:
>>
>> void func(int i) / LINE_E { SWITCH(i) / LINE_D { CASE(A) / LINE_C { ; } CASE
>> (B) / LINE_B { ; // LINE_A } } }
>>
>> When cursor is at LINE_A, and stoke `C-M-a`, cursor will go to LINE_B; then
>> `C-M-a` again, cursor goes to LINE_C, then `C-M-a` again, LINE_D, and `C-M-a`
>> again, finally to LINE_E…
>>
>> Regards…
>>
>> In GNU Emacs 29.0.60 (build 15, x86_64-pc-linux-gnu, GTK+ Version 3.24.35,
>> cairo version 1.17.6) of 2023-02-01 built on tbook Repository revision:
>> c345ec43995051e3fb412cfb8f24d0e931b7de5e Repository branch: yc-hacking System
>> Description: Gentoo Linux
>>
>> Configured using: 'configure 'CFLAGS=-O2 -march=native -pipe -g' LDFLAGS= –
>> with-native-compilation –without-pop –without-imagemagick –with-xml2 –
>> with-json –with-modules –with-pgtk'
>>
>> Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS
>> HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
>> PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
>> TREE_SITTER WEBP XIM GTK3 ZLIB
>>
>> Important settings: value of $LANG: zh_CN.UTF8 value of $XMODIFIERS: @im=fcitx
>> locale-coding-system: utf-8-unix
>>
>> Major mode: C
>>
>> Minor modes in effect: tooltip-mode: t global-eldoc-mode: t show-paren-mode: t
>> electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t
>> file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t
>> blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t
>> transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t
>> auto-compression-mode: t
>>
>> Load-path shadows: None found.
>>
>> Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny
>> dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
>> epg-config gnus-util text-property-search time-date mm-decode mm-bodies
>> mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
>> rfc2045 ietf-drums mm-util mail-prsvr mail-utils c-ts-mode c-ts-common treesit
>> pp cl-print byte-opt thingatpt help-fns radix-tree cc-mode cc-fonts cc-guess
>> cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs comp
>> comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode
>> bytecomp byte-compile cl-lib china-util rmc iso-transl tooltip cconv eldoc
>> paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
>> term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset image
>> regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
>> prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer
>> select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
>> frame minibuffer nadvice seq simple cl-generic indonesian philippine cham
>> georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
>> japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic
>> indian cyrillic chinese composite emoji-zwj charscript charprop case-table
>> epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
>> loaddefs theme-loaddefs faces cus-face macroexp files window text-properties
>> overlay sha1 md5 base64 format env code-pages mule custom widget keymap
>> hashtable-print-readable backquote threads dbusbind inotify dynamic-setting
>> system-font-setting font-render-setting cairo gtk pgtk lcms2 multi-tty
>> make-network-process native-compile emacs)
>>
>> Memory information: ((conses 16 116552 13400) (symbols 48 9439 0) (strings 32
>> 29132 1837) (string-bytes 1 934955) (vectors 16 19030) (vector-slots 8 379928
>> 16623) (floats 8 36 34) (intervals 56 432 0) (buffers 984 14))
>>
>> – Yang Yingchao Yang Yingchao



Yang Yingchao




Acknowledgement sent to yingchao.yang@HIDDEN:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#61208; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 10 Sep 2023 17:30:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.