From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#61893: 29.0.60; Indentation in c-ts-mode broken again Date: Fri, 3 Mar 2023 14:01:39 -0800 Message-ID: <0476A0F0-75E4-45EF-9B18-ECC5E87851C1@gmail.com> 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> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) 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="25066"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 61893@debbugs.gnu.org, Daniel =?UTF-8?Q?Mart=C3=ADn?= To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 03 23:03:03 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 1pYDUU-0006Fh-Nj for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Mar 2023 23:03:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYDTZ-0006l8-2u; Fri, 03 Mar 2023 17:02: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 1pYDTX-0006k5-Cc for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2023 17:02:03 -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 1pYDTW-0003dr-D1 for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2023 17:02:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pYDTV-0007kQ-Um for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2023 17:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Mar 2023 22:02: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.167788091929773 (code B ref 61893); Fri, 03 Mar 2023 22:02:01 +0000 Original-Received: (at 61893) by debbugs.gnu.org; 3 Mar 2023 22:01:59 +0000 Original-Received: from localhost ([127.0.0.1]:34092 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYDTS-0007k9-Sl for submit@debbugs.gnu.org; Fri, 03 Mar 2023 17:01:59 -0500 Original-Received: from mail-pl1-f174.google.com ([209.85.214.174]:39797) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYDTR-0007jv-7v for 61893@debbugs.gnu.org; Fri, 03 Mar 2023 17:01:57 -0500 Original-Received: by mail-pl1-f174.google.com with SMTP id i3so4232798plg.6 for <61893@debbugs.gnu.org>; Fri, 03 Mar 2023 14:01:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677880911; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YsTI38z01Yo+54ReYSgDcDqCLTFvP4i1W+cudvRjesc=; b=QlouELE94YATov+iYqyl74Rc0/4+cq6DE7SkeBpHDQ1P7RAK7pXe57qz+GSSAQn1IK 4rE+WaDvexIWo/9pLyX5xvKdt3MV5fOPBtijcqorKMQRQbDSyR30u7A5NQL0eZiyb243 rQxD7nncD9WHjpxBHCdudW/fydQZPqceTIB0Cfqg09rQu7OiDtEXflAwPfLe+IXmVn5P VOa/Uvfc5tYuykGfIGA5Ww42sUqNJjITDfwyPyEf4O8jDUXfWten7Lc6YfHGyRhNrnu6 MPy2UUOscX3LmAvRQVDSj/AqSsEmh1eBoWzuJcQLxzm4gGmoLLQtsL205ne6aaHAODyo 2mRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677880911; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YsTI38z01Yo+54ReYSgDcDqCLTFvP4i1W+cudvRjesc=; b=IIqubZuELOBUwj8L0JgwVKU7b6fYl97QwBPkZYTZQeuHbRkk3Nh7tuIUVGMDrHum4k uw63KMMkRjFeuNLF/h6tUWd1b3ktOMPJ2TxAZo4sZbpegowHTw7ACyt68MvMVfKXJzEX 9sQoUOqNDHZTHxdCNXWVUBGo80uqL+b76nuDGTo1DFyqCOBmAtCpFlErqlSlK3NrJTyP CXcImlShfYugGztp5nkBSLx/uA/liNUuroB1n8YkAZkbNVNVUnddr2BhPd9ACYjk5Sno JzzQ92EfRe9q2PFr0FNnIRTpS7oIDYylPTBl34c/BaMReyQUykSJMF0ub7XHio6OFuAZ qOsQ== X-Gm-Message-State: AO0yUKXNLEo2QD/bZDOAPgfO96dzlhBqVs1YeFT6WGZtoHwUtqEV9xl4 IyniUZgRgxDPGiaYtI33wGQ= X-Google-Smtp-Source: AK7set+9w4cPi8qZK5YhpoVAZLAXkZBoUPH83HgcDVOpmVb3NzqwVKYURCxdZU2wBmMh8ukkc0yuLQ== X-Received: by 2002:a17:90a:359:b0:233:fdfd:7122 with SMTP id 25-20020a17090a035900b00233fdfd7122mr3165825pjf.37.1677880911065; Fri, 03 Mar 2023 14:01:51 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id y20-20020a17090abd1400b00234e6d2de3dsm1955390pjr.11.2023.03.03.14.01.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Mar 2023 14:01:50 -0800 (PST) In-Reply-To: <3B2BAD9F-84AB-4243-AC98-95C52BA492E3@thornhill.no> X-Mailer: Apple Mail (2.3731.400.51.1.1) 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:257233 Archived-At: > On Mar 2, 2023, at 10:07 PM, Theodor Thornhill = wrote: >=20 >=20 >=20 > On 3 March 2023 05:07:44 CET, Yuan Fu wrote: >>=20 >>=20 >>> On Mar 1, 2023, at 10:31 PM, Eli Zaretskii wrote: >>>=20 >>>> From: Yuan Fu >>>> Date: Wed, 1 Mar 2023 14:08:23 -0800 >>>> Cc: Daniel Mart=C3=ADn , >>>> Theodor Thornhill , >>>> 61893@debbugs.gnu.org >>>>=20 >>>>> Thanks. So I wasn't dreaming after all. >>>>=20 >>>> Sorry about that. It should be fixed now. >>>=20 >>> Thanks, it's much better now. >>>=20 >>> I spotted the following problems, not sure if they are new or not: = go >>> to line 297 of dispnew.c, which is "#endif". Then type "C-e RET" -- >>> point goes to column zero instead of the expected column 6. This >>> affects the following 3 lines as well; only the next 'if' fixes the >>> indentation. I see the same problem with every "#endif" line. >>>=20 >>> Line 6584 of dispnew.c, which is this: >>>=20 >>> #endif /* HAVE_WINDOW_SYSTEM */ >>>=20 >>> exhibits a slightly different incorrect behavior: "C-e RET" on that >>> line moves point to column 7, not column 6, presumably to align with >>> the "/*" of the comment? >>>=20 >>> Line 6608 of dispnew.c is just "#else"; typing "C-e RET" there >>> unexpectedly goes to column 2 instead of 4. >>=20 >> That=E2=80=99s indeed the =E2=80=9Calign to previous statement=E2=80=9D= =E2=80=99s fault, caused by preproc directives Theo was working on. = I=E2=80=99ve fixed it. Theo, while working on this, I found some problem = with the current indent for preproc directives. In the following = example: >>=20 >> static void >> free_glyph_pool (struct glyph_pool *pool) >> { >> if (pool) >> { >> #if defined GLYPH_DEBUG >> int c =3D 1; >> #endif >> int check_this =3D 3; >> #ifdef stuff >> int c =3D 1; >> #elif defined stuff >> int e =3D 5; >> #else >> int d =3D 11; >> #endif >> int check_this =3D 3; >> } >> } >>=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 = nested in the if directive, and the nesting can be arbitrarily deep. We = probably need a custom function rather than great-grand-parent to find = the anchor, 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 little = low at the moment, so if you have some extra time, don't hesitate to = improve it :) Absolutely, I=E2=80=99ll work on it.=20 Yuan=