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#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 Message-ID: References: <834js51rf8.fsf@gnu.org> <877cx11qg7.fsf@thornhill.no> Reply-To: yingchao.yang@seaboxdata.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="16204"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.13; emacs 29.0.60 Cc: Eli Zaretskii , 61208@debbugs.gnu.org, Yuan Fu To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 02 07:46:32 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 1pNTMe-00044F-GP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Feb 2023 07:46:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNTMK-0003zH-Vr; Thu, 02 Feb 2023 01:46:13 -0500 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 1pNTMB-0003yO-Ma for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 01:46:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNTMA-0000at-H2 for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 01:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNTMA-0000wy-C3 for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 01:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yang Yingchao Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Feb 2023 06:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61208 X-GNU-PR-Package: emacs Original-Received: via spool by 61208-submit@debbugs.gnu.org id=B61208.16753203403598 (code B ref 61208); Thu, 02 Feb 2023 06:46:02 +0000 Original-Received: (at 61208) by debbugs.gnu.org; 2 Feb 2023 06:45:40 +0000 Original-Received: from localhost ([127.0.0.1]:60452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNTLi-0000vq-LN for submit@debbugs.gnu.org; Thu, 02 Feb 2023 01:45:40 -0500 Original-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 ) id 1pNNtW-0008WB-5z for 61208@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= Original-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 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/wrM8x4L In-reply-to: <877cx11qg7.fsf@thornhill.no> Original-Message-ID: <875yckubqb.fsf@qq.com> X-Mailman-Approved-At: Thu, 02 Feb 2023 01:45:33 -0500 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:254629 --=-=-= Content-Type: text/plain Content-Disposition: inline On Wed, Feb 01 2023, Theodor Thornhill wrote: > Eli Zaretskii writes: > >>> Cc: yang.yingchao@qq.com >>> 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" >>> >>> >>> #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 --=-=-=--