bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with macros i


From: Eli Zaretskii
Subject: bug#61208: 29.0.60; treesit-beginning/end-of-defun problem with macros in c-ts-mode
Date: Thu, 02 Feb 2023 09:41:23 +0200

> From: Yuan Fu <casouri@gmail.com>
> Date: Wed, 1 Feb 2023 18:32:26 -0800
> Cc: yingchao.yang@seaboxdata.com,
>  Theodor Thornhill <theo@thornhill.no>,
>  61208@debbugs.gnu.org,
>  yang.yingchao@qq.com
> 
> 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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]