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:03:48 +0800 Message-ID: References: <871qf4doit.fsf@qq.com> <83h6nzpoeg.fsf@gnu.org> 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="34942"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.6; emacs 29.1.50 Cc: 65885@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 13 02:14:24 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 1qgDWQ-0008rG-P5 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Sep 2023 02:14:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgDW4-0000G4-SD; Tue, 12 Sep 2023 20:14:00 -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 1qgDW1-0000FZ-NU for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 20:13: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 1qgDW1-0002Pf-Dd for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 20:13:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgDW5-0002DV-TW for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 20:14:01 -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:14:01 +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.16945640108477 (code B ref 65885); Wed, 13 Sep 2023 00:14:01 +0000 Original-Received: (at 65885) by debbugs.gnu.org; 13 Sep 2023 00:13:30 +0000 Original-Received: from localhost ([127.0.0.1]:60317 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgDVZ-0002Cf-Tn for submit@debbugs.gnu.org; Tue, 12 Sep 2023 20:13:30 -0400 Original-Received: from out162-62-57-87.mail.qq.com ([162.62.57.87]:53925) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgDVV-0002CO-GH for 65885@debbugs.gnu.org; Tue, 12 Sep 2023 20:13:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1694563984; bh=HI0vhiTKy8mQ9EA4UpCAYmpnfrQOos6hkrHmMJm0epI=; h=From:To:Cc:Subject:Date:References:Reply-To:In-reply-to; b=YBNb8hqtGhFcVGBjYENSGwF1Ohf9hCNrfKTrNxrImSL0ade+BB/4+HTXSFw3FWRfJ A1OTwMfrgivfELFC4DkNaKrlkfaBcCKlOWbH50/L7Q/A0z20kveGRocrYiW1agO0mZ 4tKIMraPBFm0E1TXg91C9vWoEFsqikvHnqh+1M70= Original-Received: from tdesk ([60.26.149.220]) by newxmesmtplogicsvrszc2-0.qq.com (NewEsmtp) with SMTP id 34299823; Wed, 13 Sep 2023 08:13:02 +0800 X-QQ-mid: xmsmtpt1694563982tgvfb4q7r X-QQ-XMAILINFO: N9lasXYeZMXWD6wnEFrb3VW8IdQeB443bMgyDKTh5zzx4OqytSYubuziGwKfZ/ 6F6J6eRBioGeJzWdI2iS6K7ABVVhD3hEYwrYkUt39WlV0qtxuAkxb8h34RtT1MEw2JFOyKrhBWDL OPd9AIeNXuAWykD/huJXUpfWMEph7IdVGom1DFoIikXEYkMmAywPzOaxQ3s9aVQ9c8DLJvRJqMA1 Z1skKZXHaNyoNaplz2t1hV9F2r1OYPV32ndypxqhRVPGSZvJD3zYWtwmsG19jTESWTa5xTHgn9lu 0T3dheDA7kqH0NeHZr1iAnkfoqGbw438exYeQrDw9JJzm0gDFPV4KQEfTcQntdxLttgMgtWAKDX0 ZXfETWtB/OI1x2a7MnXK3XrL5ETPDKJ58v7bsim1zycna1Zjo9VhuQcp1W7He8/TNhd0rbofoAnY gXRCbBKUClcMU0HBFePJqWDnIWYOX5qLxpSgvJczbYyJrKjThtITwWQkyy8dAZMmq3VcyzATOxZv kVeM/eomHLnNXaqeUbtaq46cdVgSHItiGY1Mb5x0rjYuaMc+eZzOnwPMDIb263qWBTDOodEd9AdM 9SwxwYJX6WLR9blsJpiHwzIMAUXaWLoR84qDlfWXksGmMeFNiwpiA2NKrp9AB1OT09z/59LAKXHl IoXVTRCbiUwMdvOW1pQiPiEnfSsvERqW9NEA50LgF40r/owpoa3DUYKKoBQ/kySkbXHM0hZiAaa1 N+uwyX7r5pH0+tlwXKxFnMwLQ3wZnQNfjac0SRiU0sFxUUuNqQtWibb8AfXPA38/nrILnyavq2iy WfZ2IFzNyjBUqgKxTI1ObCrIG7waN1ppHwh0nhQA X-QQ-XMRINFO: OD9hHCdaPRBwq3WW+NvGbIU= In-reply-to: <83h6nzpoeg.fsf@gnu.org> Original-Message-ID: <87wmwv9bhu.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:270233 --=-=-= 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. --=-=-=--