unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: yingchao.yang@seaboxdata.com
Cc: 61208@debbugs.gnu.org, casouri@gmail.com, theo@thornhill.no
Subject: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with macros in c-ts-mode
Date: Thu, 02 Feb 2023 09:16:37 +0200	[thread overview]
Message-ID: <83zg9wy1t6.fsf@gnu.org> (raw)
In-Reply-To: <tencent_E0B22481A7EDAB4288CF1F29DE232B7E7707@qq.com> (message from Yang Yingchao on Thu, 02 Feb 2023 08:48:55 +0800)

> From: Yang Yingchao <yang.yingchao@qq.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, Yuan Fu <casouri@gmail.com>,
>  61208@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.





  reply	other threads:[~2023-02-02  7:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fc907ec5049baaaff04d38dd4ed5ab996500a50b6d723604fff453aad543dc86@mu.id>
2023-02-01  6:33 ` bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with macros in c-ts-mode Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-01 12:49   ` Eli Zaretskii
2023-02-01 13:10     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-02  0:48       ` Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-02  7:16         ` Eli Zaretskii [this message]
     [not found]       ` <875yckubqb.fsf@qq.com>
2023-02-02  1:48         ` Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-02  2:32     ` Yuan Fu
2023-02-02  7:41       ` Eli Zaretskii
2023-02-02 18:22         ` Eli Zaretskii

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=83zg9wy1t6.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=61208@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=theo@thornhill.no \
    --cc=yingchao.yang@seaboxdata.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).