From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yang Yingchao via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65885: Acknowledgement (29.1.50; wrong behaviour of treesit-beginning-of-defun in c++-ts-mode) Date: Wed, 13 Sep 2023 08:41:27 +0800 Message-ID: References: <871qf4doit.fsf@qq.com> <83h6nzpoeg.fsf@gnu.org> <87wmwv9bhu.fsf@qq.com> Reply-To: yang.yingchao@qq.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39917"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.6; emacs 29.1.50 To: Eli Zaretskii , 65885@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 13 02:49:22 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qgE4I-000ABw-5X for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Sep 2023 02:49:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgE3x-0000ZV-Ax; Tue, 12 Sep 2023 20:49:01 -0400 Original-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 ) id 1qgE3u-0000ZI-Be for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 20:48:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgE3u-0007zn-3X for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 20:48:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgE3y-00036i-8W for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 20:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yang Yingchao Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Sep 2023 00:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65885 X-GNU-PR-Package: emacs Original-Received: via spool by 65885-submit@debbugs.gnu.org id=B65885.169456610811843 (code B ref 65885); Wed, 13 Sep 2023 00:49:02 +0000 Original-Received: (at 65885) by debbugs.gnu.org; 13 Sep 2023 00:48:28 +0000 Original-Received: from localhost ([127.0.0.1]:60325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgE3Q-00034u-3I for submit@debbugs.gnu.org; Tue, 12 Sep 2023 20:48:28 -0400 Original-Received: from out162-62-57-87.mail.qq.com ([162.62.57.87]:54327) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgE3J-00033U-BH for 65885@debbugs.gnu.org; Tue, 12 Sep 2023 20:48:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1694566082; bh=E9E+CzVmeZ+ENpGFfXacTR8m4AFmK632mA8ONvQciio=; h=From:To:Subject:Date:References:Reply-To:In-reply-to; b=RaXptm+cVriRyf0726Db7IvGycgKhM4eIGu0IPN41SHhHY2kQCIiQvHfj2C/aejsf Ag2Z+P39dCXr6eAKBT+NsMoBm1DUmqiDnzVe00Ef/RLlTpuMrU0kvZjUVGopwzqIPQ orOidoNhyf8FwpCTMh68EV4uwMQ7DoumYsOGRHCo= Original-Received: from tdesk ([60.26.149.220]) by newxmesmtplogicsvrszc5-0.qq.com (NewEsmtp) with SMTP id C00ADE84; Wed, 13 Sep 2023 08:48:00 +0800 X-QQ-mid: xmsmtpt1694566080tq8jszb4s X-QQ-XMAILINFO: OVFdYp27KdlJCLXy1OvRdJ3wh3IOdv5s1yigTwgrEKNaOm4rCwCn6RdIqI0YZ6 Ge3W8MMB0xqgOpndaXi9JNPvv3Ges5FmUfg3Ka8sUXBnLMgNAJAJTC0+3zUxYtxHJII4TzxyZMth 2FzPsjep34tqiddgd3+uJVVvOIsJf9OMv/efg2O463hxmIKswtSEoHuR3KvL/yDrCHsTcIhSm5IU TfcN6NeKE1b1VSbLssdkAnqximy0+MlrUWxsiHOvxifjau8fgx3bDDjPDbhx1LFhzUce/1f6HZly rnxFobiq3+qt6nb6JufFWTJ1/HNQdTu+uBPQeOfvc+iR33am7Oip4tvvS+ZeJs3BqDJ7PGv+xTQ6 eFUlo8oRvaIcKHeKal7yNRVsaM82rwTRbi4exGrhdHIUXeXChv7aCAgqOcs0pXW9ZDELm+vEoBhG aJbHkMwZeY37wo+PVDhC1kq77e1IX1cLe20PU7FyyAAFJ1mJ44/ZVCaROmufmvuXb+hUaeyo9hko EMdnznPPE8o12xupLVEByZa4AYGTV5wHkwWHfObdoxxRJXnQjdzVFNYUUbYCD0YFpeWRo8YAsVMG ApkF+W2jcvQ+k7e5u5nPvwcRY2jffTKP8rgEc/EO03WjtPm1GYOWEOsQCTwXg0Pto6zvCg/xluHj 5iw/QaLUpi+g5JinUyI5NSQZAdWo3Q7bekBp9CioYqGkD95o4v3fuHZe5snzWhJp9CmE9NgQYiBN ederUY+iNzDd2SE+wzbzAr9EX08DGvY1Zxa/qXdOCHlDNIk4+Je3cjKXcZizrv7A91oqSzu3cvy3 wAm3MdUlquBtO8EUv0cjvyuiMYGi4Q9czmmhLeWs X-QQ-XMRINFO: MPJ6Tf5t3I/ycC2BItcBVIA= In-reply-to: <87wmwv9bhu.fsf@qq.com> Original-Message-ID: <87v8ceaofz.fsf@qq.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-ACL-Warn: , Yang Yingchao Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270234 --=-=-= Content-Type: text/plain Content-Disposition: inline >>> Date: Tue, 12 Sep 2023 12:41:32 +0800 >>> From: Yang Yingchao via "Bug reports for GNU Emacs, >>> the Swiss army knife of text editors" >>> >>> It seams that there is an issue with the behavior of `treesit-beginning-of-defun` function in >>> `c++-ts-mode` when there are static variables present in the source code. For instance, in the >>> provided code snippet, if the cursor is initially placed on the line containing `int b`, and the >>> "C-M-a" is pressed, the cursor is positioned on line 4 instead of line 1 where the beginning of >>> the function is located. >>> >>> ,---- >>> | void func // c-ts-mode: treesit-beginning-of-defun stops in this line, RIGHT >>> | { >>> | char * msg; >>> | static int a; // c++-ts-mode: treesit-beginning-of-defun stops in this line, WRONG >>> | int b; // PUT CUSOR HERE >>> | } >>> `---- >>> >>> it works in c-ts-mode works normally. >> >> If you want c++-ts-mode to work like c-ts-mode, set >> treesit-defun-tactic to 'top-level'. By default, we try to support >> nested defuns in C++, but not in C. > > > I apologize, but I realized that I have already asked this question before. > > However, setting 'treesit-defun-tactic' to 'top-level' could cause other > issues, as seen in the following snippets: > > > ,---- > | class Name { > | public: > | Name() > | { > | // cursor here > | } > | > | void func() > | { > | static int a; > | } > | > | }; > `---- > > Suppose the cursor is in line 5, and "C-M-a" is pressed: > > - In 'c++-mode', the cursor will be moved to the start of the function 'Name()', which is the expected behavior. > - In 'c++-ts-mode': > - With 'treesit-defun-tactic' set to 'nested', it behaves the same as in 'c++-mode'. > - With 'treesit-defun-tactic' set to 'top-level', the cursor is moved to the beginning of the class, i.e., line 1. > > Is it possible to make 'c++-ts-mode' behave the same as in 'c++-mode'? > > Regards. Maybe I'm wrong, but I would like to suggest reconsidering the solution to the 'begging-of-defun' issue related to the static *variable*. It feels strange to me to fix this issue by changing the 'treesit-defun-tactic', which is meant to apply to a *function* literally... --=-=-=--