GNU bug report logs - #61893
29.0.60; Indentation in c-ts-mode broken again

Previous Next

Package: emacs;

Reported by: Eli Zaretskii <eliz <at> gnu.org>

Date: Wed, 1 Mar 2023 14:38:01 UTC

Severity: normal

Found in version 29.0.60

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 61893 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 61893 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>,
 Daniel Martín <mardani29 <at> yahoo.es>
Subject: Re: bug#61893: 29.0.60; Indentation in c-ts-mode broken again
Date: Thu, 2 Mar 2023 20:07:44 -0800

> On Mar 1, 2023, at 10:31 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Wed, 1 Mar 2023 14:08:23 -0800
>> Cc: Daniel Martín <mardani29 <at> yahoo.es>,
>> Theodor Thornhill <theo <at> thornhill.no>,
>> 61893 <at> debbugs.gnu.org
>> 
>>> Thanks.  So I wasn't dreaming after all.
>> 
>> Sorry about that. It should be fixed now.
> 
> Thanks, it's much better now.
> 
> 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.
> 
> Line 6584 of dispnew.c, which is this:
> 
> #endif /* HAVE_WINDOW_SYSTEM */
> 
> 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?
> 
> Line 6608 of dispnew.c is just "#else"; typing "C-e RET" there
> unexpectedly goes to column 2 instead of 4.

That’s indeed the “align to previous statement”’s fault, caused by preproc directives Theo was working on. I’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 = 1;
#endif
      int check_this = 3;
#ifdef stuff
      int c = 1;
#elif defined stuff
  int e = 5;
#else
  int d = 11;
#endif
  int check_this = 3;
    }
}

The elif directive’s and subsequent directives aren’t 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’t a preproc directive anymore.

Yuan



This bug report was last modified 2 years and 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.