From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Randy Taylor Newsgroups: gmane.emacs.bugs Subject: bug#66845: 29.1; cmake-ts-mode indentation broken Date: Wed, 08 Nov 2023 03:42:37 +0000 Message-ID: References: <4m1KSu7eJ_B7nNCVOnvZM_edTrQhMTtxiKFwUB4zNoYufrWuTYcq_tL1iIRml2xqDRdTDavJBnE7B4iNmswVLwzGXI96E_FNcXkCeDqUzVo=@rjt.dev> <103F31BD-239C-4059-A511-BE29BBAE5DA9@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37031"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Juan Palacios , 66845@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 08 04:43:52 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 1r0ZTq-0009S7-Rb for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Nov 2023 04:43:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0ZTS-0006Zw-KI; Tue, 07 Nov 2023 22:43:26 -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 1r0ZTQ-0006ZS-TG for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 22:43:24 -0500 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 1r0ZTQ-0000xB-L3 for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 22:43:24 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r0ZU2-00023h-Ff for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 22:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Randy Taylor Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Nov 2023 03:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66845 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66845-submit@debbugs.gnu.org id=B66845.16994150257878 (code B ref 66845); Wed, 08 Nov 2023 03:44:02 +0000 Original-Received: (at 66845) by debbugs.gnu.org; 8 Nov 2023 03:43:45 +0000 Original-Received: from localhost ([127.0.0.1]:43853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0ZTl-00022z-2A for submit@debbugs.gnu.org; Tue, 07 Nov 2023 22:43:45 -0500 Original-Received: from mail-4018.proton.ch ([185.70.40.18]:31377) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0ZTi-00022f-37 for 66845@debbugs.gnu.org; Tue, 07 Nov 2023 22:43:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rjt.dev; s=protonmail; t=1699414977; x=1699674177; bh=FQjrhsmpbElOic0xo2wYjUPeKCnY7oukYmcVAQoF3/M=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=wNnZLVnCqUExWg3O2MwqluHW1qmmrxoz31Y/bShVSa4unYQ+XFTSynOKiYpqNJNea CEHtbwyNbheIeSyS7/FRkLDFgOnRvMgPoPzIiq/SxI9k6Q/G9cAsX/yMm2AofnbHal K5TvADGGihxM+RNEkCsaU14mpC9fPjSlNHMzjPBzNOuI8JcCcFI8Zdjl/S+5d1q5y+ otnhSsD0I7LNimpd8F0mYioUpp7tfAtv3P0dA8HaM0oxgv9vbbOviaNh/P9N7gB44w D/5dGHwiYA3wDw3BZHTi/eJihXv5NyKW45HUh/UdFTBlDh2sbSDAHndEj+GpcVGEmS F11B1wW157uoA== In-Reply-To: <103F31BD-239C-4059-A511-BE29BBAE5DA9@gmail.com> Feedback-ID: 44397038:user:proton 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:273965 Archived-At: On Tuesday, November 7th, 2023 at 21:52, Yuan Fu wrote: >=20 > > On Nov 7, 2023, at 9:21 AM, Randy Taylor dev@rjt.dev wrote: > >=20 > > On Tuesday, November 7th, 2023 at 03:25, Yuan Fu casouri@gmail.com wrot= e: > >=20 > > > IMO it makes more sense to use prev-sibling: > > >=20 > > > ,@(ignore-errors > > > (treesit-query-capture 'cmake '((body) @capture)) > > > `(((parent-is "body") prev-sibling 0))) > > >=20 > > > This would allow users to manually adjust the indentation of a line a= nd have the rest of the body follow that. > >=20 > > This would be much more elegant but unfortunately that and my previous = patch failed to account for the following: > >=20 > > 1 if(TRUE) # Comment. > > 2 endif() > >=20 > > And place POINT at the end of line 1 and hit RET. It will indent to the= start of the comment :(. However, you gave me an idea: use the grand-paren= t as the anchor (which in this case is the if - exactly what we want). I've= attached a new patch which accounts for that. >=20 >=20 > Ah, I was a bit rusty too. The approach I mentioned should also have a ru= le for the first sibling which anchors on the parent, while the rest siblin= gs anchor on the previous sibling. But anchoring all on the parent is equal= ly valid. I see. Could you (or someone else) install the patch to emacs-29? >=20 > > Juan, thanks for testing the first patch. Please give this new one a wh= irl if you're able to. > >=20 > > > As for why parent-bol returns the BOL of the comment line, that= =E2=80=99s expected: The parent is body, and body starts at the comment, so= of course the beginning of the parent line is the beginning of the comment= line. In the image below, the highlighted portion marks the body node. > > >=20 > > > Some tree-sitter grammar would mark the beginning of body at the end = of if(TRUE), but what tree-sitter-cmake does here is equally valid. > >=20 > > Thanks, I understand what's happening now. Whenever line_comment is NOT= the first child, the beginning of body is at the end of if(TRUE). If line_= comment is the first child, then the beginning of body is at the start of t= he comment. I was expecting them to behave the same - that's why I was so c= onfused, and I don't really understand why it was done that way.<0001-Fix-c= make-ts-mode-indentation-Bug-66845.patch> >=20 >=20 > You=E2=80=99re right. That=E2=80=99s a strange behavior. We should probab= ly report to tree-sitter-cmake. I will try to get around to that sometime next week.