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: Thu, 2 Mar 2023 20:07:44 -0800 Message-ID: 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> 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="33847"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61893@debbugs.gnu.org, Theodor Thornhill , Daniel =?UTF-8?Q?Mart=C3=ADn?= To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 03 05:09:21 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 1pXwjR-0008b1-NO for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Mar 2023 05:09:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXwjA-0001HB-Uu; Thu, 02 Mar 2023 23:09: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 1pXwj9-0001Bo-H9 for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 23:09: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 1pXwj9-0001OA-5E for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 23:09:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pXwj8-0005EJ-Fs for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 23:09:02 -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 04:09:02 +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.167781648520033 (code B ref 61893); Fri, 03 Mar 2023 04:09:02 +0000 Original-Received: (at 61893) by debbugs.gnu.org; 3 Mar 2023 04:08:05 +0000 Original-Received: from localhost ([127.0.0.1]:59376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXwiC-0005D3-GD for submit@debbugs.gnu.org; Thu, 02 Mar 2023 23:08:04 -0500 Original-Received: from mail-pl1-f177.google.com ([209.85.214.177]:46065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXwiA-0005CX-Ge for 61893@debbugs.gnu.org; Thu, 02 Mar 2023 23:08:03 -0500 Original-Received: by mail-pl1-f177.google.com with SMTP id z2so1427648plf.12 for <61893@debbugs.gnu.org>; Thu, 02 Mar 2023 20:08:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677816476; 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=Dt8hJ/EgXTrn+IdesAFFKIjbHn4kJcUVDwiHwPV3tgw=; b=jqtyjWz4RHSC7wHp7sKfVOKt4HWXdtxz7vtwUoFzAMPYwi/xv4JwAdkuDoEHSqYFNr HrvmWEUPTWoUR2HR+YEs0WooAUzUPbIYHtYHbWYXLijnZ5Q6eytgj88/cykG0H1W8MPO Iv8Po3k97nMfevi+jAZ3QHsjUpbMs1eY6/pKimHqFvSm8bg/FA0oM1WKvTMeL6SvMBRp u7ZwMbSpBO0L+aXgrMAs8IteC0Fj87Q1tMbr2w+C+oXTnmepBlJvP8f0p5bQuSMVj1st FFAVowEDB+O11/L5xynLQsnLgZIgfhpBOBj46DHxn/IdXO5Oq0BY+viJNeOoYEV1BESG k0+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677816476; 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=Dt8hJ/EgXTrn+IdesAFFKIjbHn4kJcUVDwiHwPV3tgw=; b=NKgSIq5rawbPPGTfGIThyihkFzaunLr4EngOVqTqHb6dnA9E4FLvIaG+FnJWn5g/Y1 yVNN8bj/c+Nw8sRPLbj5ZQiurmR7LNf37AX8MaokacbAvQwhyU1m/oqv8IqKoE2oT0HW DR4s6Ub1wmgqBnSBiT4D+3KlS4F6R7hM5Hk7nvwXy8fHDJ9kZycd2xDY8wmAEohxxdfp ReDHLgjLxgEGiOfKSzCsP8GsAaRi0Fw2XQLqwLgIRAS3H4dJIjFpIU7HXRmB2T91eJpm wTvV2XkZnQHJBiRtdBFkxR/vV3oV1EpROrIVZIKW/aQ8tKrSu6zpWuXZYQFvf7AXO/z0 e8/A== X-Gm-Message-State: AO0yUKV+Pj+aFxJXpLnNbvwliJQai9jJLpEMLkO/JB+EopPUJtWF1PhB xKsoUdbn+ld2DeqB+x4FiZg= X-Google-Smtp-Source: AK7set8vEyuuXQ+1dXiAVOFSmZtqoapn1UxHkOUvvuRkxowyhzkWbV6LpGMotKCLizuD8rYFF8ThuA== X-Received: by 2002:a17:90b:1d07:b0:237:e1d2:c659 with SMTP id on7-20020a17090b1d0700b00237e1d2c659mr281108pjb.2.1677816476575; Thu, 02 Mar 2023 20:07:56 -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 h9-20020a17090acf0900b00219752c8ea5sm478170pju.37.2023.03.02.20.07.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2023 20:07:56 -0800 (PST) In-Reply-To: <83y1ofekaw.fsf@gnu.org> 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:257190 Archived-At: > 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. 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=99= ve fixed it. Theo, while working on this, I found some problem with the = current indent for preproc directives. In the following example: 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; } } 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. Yuan=