From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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 09:41:23 +0200 Message-ID: <83wn50y0nw.fsf@gnu.org> References: <834js51rf8.fsf@gnu.org> <963AC74E-57EA-4478-AD4C-8210DBA7EC9C@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1994"; mail-complaints-to="usenet@ciao.gmane.io" Cc: yingchao.yang@seaboxdata.com, 61208@debbugs.gnu.org, theo@thornhill.no, yang.yingchao@qq.com To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 02 08:42:27 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 1pNUEi-0000JL-7C for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Feb 2023 08:42:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNUEP-0006lG-QG; Thu, 02 Feb 2023 02:42:05 -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 1pNUEM-0006kz-IO for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 02:42:02 -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 1pNUEM-0002nX-8J for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 02:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNUEL-0002SF-R3 for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 02:42:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Feb 2023 07:42:01 +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.16753236959400 (code B ref 61208); Thu, 02 Feb 2023 07:42:01 +0000 Original-Received: (at 61208) by debbugs.gnu.org; 2 Feb 2023 07:41:35 +0000 Original-Received: from localhost ([127.0.0.1]:60603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNUDv-0002RX-C6 for submit@debbugs.gnu.org; Thu, 02 Feb 2023 02:41:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNUDr-0002RH-KH for 61208@debbugs.gnu.org; Thu, 02 Feb 2023 02:41:33 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNUDk-0002hl-7J; Thu, 02 Feb 2023 02:41:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=1XrsIBM6bWQ/MKvofcw3zaIxduWjnUOVg6jzXCLcQoU=; b=NrtSStRvDQFmByJBkTyQ KpPz9+HmQEN5+bsQ3KdEr2qRWfawn6pqqh9zZTddCph7oXLMBVWmPAf8g+RI7isw7JuzODAi7Haex I5Y6hkB2XtfJn6Q9lEJxxG3rS7xyAj5+Kurbi/AOZY9jrwlwIgyTVJV/A22Aq1KloxT9/LttAh1aq CYup7VnY89An8MCEbMo/HwHqTeeHscOM8UUfkVGyb00BfAKGJeLOTxiUt5cmcNEXGEIDPTX8Sj5rn jhtoYsAPpOt1Od8WHQ9AstOrG59TkA49JlwjMdoRm756EliCFihUMq43WThOpfEfQz755w7jx1PLQ 28YDmRMuT4i4/g==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNUDj-0000U1-4p; Thu, 02 Feb 2023 02:41:23 -0500 In-Reply-To: <963AC74E-57EA-4478-AD4C-8210DBA7EC9C@gmail.com> (message from Yuan Fu on Wed, 1 Feb 2023 18:32:26 -0800) 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: , 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:254633 Archived-At: > From: Yuan Fu > Date: Wed, 1 Feb 2023 18:32:26 -0800 > Cc: yingchao.yang@seaboxdata.com, > Theodor Thornhill , > 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?