From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61893: 29.0.60; Indentation in c-ts-mode broken again Date: Mon, 06 Mar 2023 07:03:33 +0100 Message-ID: <877cvuo1qi.fsf@thornhill.no> References: <83k000fsg8.fsf@gnu.org> <990CFB42-B7E4-4692-858B-20080B19A801@thornhill.no> <83a60wflwm.fsf@gnu.org> <835ybkfhuw.fsf@gnu.org> <3F6EB4C0-8216-4783-9DE4-0719F514F1B7@gmail.com> <83y1ofekaw.fsf@gnu.org> <3B2BAD9F-84AB-4243-AC98-95C52BA492E3@thornhill.no> <0476A0F0-75E4-45EF-9B18-ECC5E87851C1@gmail.com> <5F5AF93A-E0A8-47BF-97DB-1AAA9A025FA4@thornhill.no> <3A152DB8-DA88-4E40-A536-4514E2C3501A@gmail.com> <83ttyz8v4v.fsf@gnu.org> <7CDB5C99-AC13-463A-9B59-B6BB5011E683@gmail.com> Reply-To: Theodor Thornhill 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="13973"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 61893@debbugs.gnu.org, Daniel =?UTF-8?Q?Mart=C3=ADn?= To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 06 07:04:20 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 1pZ3xL-0003S4-75 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Mar 2023 07:04:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ3x6-0001Mj-C1; Mon, 06 Mar 2023 01:04:04 -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 1pZ3x4-0001MN-Hm for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 01:04: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 1pZ3x3-0001KL-Vb for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 01:04:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZ3x3-0008V2-Ph for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 01:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Mar 2023 06:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61893 X-GNU-PR-Package: emacs Original-Received: via spool by 61893-submit@debbugs.gnu.org id=B61893.167808261932637 (code B ref 61893); Mon, 06 Mar 2023 06:04:01 +0000 Original-Received: (at 61893) by debbugs.gnu.org; 6 Mar 2023 06:03:39 +0000 Original-Received: from localhost ([127.0.0.1]:41156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZ3wg-0008UK-Ka for submit@debbugs.gnu.org; Mon, 06 Mar 2023 01:03:39 -0500 Original-Received: from out-25.mta0.migadu.com ([91.218.175.25]:52040) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZ3we-0008UC-QU for 61893@debbugs.gnu.org; Mon, 06 Mar 2023 01:03:37 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1678082614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DGVG4maPIjxWRuvOzTCpdV3yox9FKyA/g/bt8y3AJzo=; b=o+yTPAD7lD7uvSsJQz+ldj0wNHoYWDLRDV5lDWRCwqphVkhp1nu/52l+61w1X4Qbt7uI9k m4i3/RAjuU/3OtXlYU6+8GPe7VYQj1NGdzpNDMlSFnvL5JtxMu3u9BVcGP31n0RZAASXM0 cDI4RA6Cg3gH99ePsQ+Cpbx+9N3TctgDWSc0+/eBKTxV9j335lbFkSwli605kJ2Z6q2Cfd d8SqGQzbRVHz/hgifAmng2HAr/HcLMae+st3GHJU9/Z9owMWmADWNhedJCK46d755fKQb2 YV3fVTsxjq0KpaKGezOHxUJg1vdeOORwx2NyrLykS6G0GUGBkqzkF4tv6nUcNw== In-Reply-To: <7CDB5C99-AC13-463A-9B59-B6BB5011E683@gmail.com> (Yuan Fu's message of "Sun, 5 Mar 2023 15:26:45 -0800") X-Migadu-Flow: FLOW_OUT 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:257370 Archived-At: Yuan Fu writes: >> On Mar 5, 2023, at 12:22 AM, Eli Zaretskii wrote: >>=20 >>> From: Yuan Fu >>> Date: Sat, 4 Mar 2023 15:03:46 -0800 >>> Cc: Eli Zaretskii , >>> Daniel Mart=C3=ADn , >>> 61893@debbugs.gnu.org >>>=20 >>>>>>> The elif directive=E2=80=99s and subsequent directives aren=E2=80= =99t indented >>>>>>> properly. Looking at the parsed tree, the elif directives are neste= d in >>>>>>> the if directive, and the nesting can be arbitrarily deep. We proba= bly >>>>>>> need a custom function rather than great-grand-parent to find the a= nchor, >>>>>>> like a function that keeps going up the tree until the node isn=E2= =80=99t a >>>>>>> preproc directive anymore. >>>>>>>=20 >>>>>>> Yuan >>>>>>=20 >>>>>> Yeah, you're right. I'll see what I can do, but bandwidth is a littl= e low at the moment, so if you have some extra time, don't hesitate to impr= ove it :) >>>>>=20 >>>>> Absolutely, I=E2=80=99ll work on it.=20 >>>>>=20 >>>>> Yuan >>>>=20 >>>> Thanks :) >>>=20 >>> Done! >>=20 >> Thanks. >>=20 >> Some problems still remain. > > Thanks, there are so many edge cases :-) > >>=20 >> Line 1761 of dispnew.c: type "C-e RET" -- point goes to column 7 >> instead of the expected column 2. > > Fixed. >>=20 >> Line 3381 of dispnew.c: type "C-e RET" -- point goes to the correct >> column, but line 3381 is reindented incorrectly. > > This is due to it aligning to the previous sibling, aka the comment. Do w= e want to skip comments for the =E2=80=9Calign to the prev sibling=E2=80=9D= rule? > >>=20 >> Line 6611 of dispnew.e: type "C-e RET" -- point goes to column 0 >> instead of the expected column 2. If you type "C-e RET" on the next >> line 6612, point goes to column 0 and the line is reindented >> incorrectly. > > Fixed. >>=20 >> Line 13925 of xdisp.c: type "C-e RET" -- point goes to column 33(!) >> and line 13925 is reindented incorrectly. > > Fixed. >>=20 >> Lines 34529 and 34530 of xdisp.c: "C-e RET" produces incorrect column >> of point and reindents line 34530. > > The preproc directive messed the parse tree, and tree-sitter can=E2=80=99= t tell that it=E2=80=99s an else statement, so it can=E2=80=99t be easily f= ixed sadly. > > Yuan Now this isn't indenting how I expect: int foo { | // <-- Now point is indented to column 0 } It seems like `c-ts-mode--anchor-prev-sibling` isn't handling this? Theo