From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 61558@debbugs.gnu.org
Subject: bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif
Date: Fri, 17 Feb 2023 20:23:33 +0100 [thread overview]
Message-ID: <87cz68p03u.fsf@thornhill.no> (raw)
In-Reply-To: <835yc12v7a.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 16 Feb 2023 22:48:09 +0200")
Eli Zaretskii <eliz@gnu.org> writes:
> To reproduce:
>
> emacs -Q
> C-x C-f src/dispnew.c RET
> C-u 265 M-g g
> C-e
> RET
>
> The code around there looks like this:
>
> static struct glyph_matrix *
> new_glyph_matrix (struct glyph_pool *pool)
> {
> struct glyph_matrix *result = xzalloc (sizeof *result);
>
> #if defined GLYPH_DEBUG && defined ENABLE_CHECKING
> /* Increment number of allocated matrices. This count is used
> to detect memory leaks. */
> ++glyph_matrix_count; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> #endif
>
> Line 265 is the one indicated with "<<<<<<". Pressing RET goes to
> column 0, not column 2 as expected. It looks like indentation doesn't
> work in code fragments that are guarded by #ifdef..#endif preprocessor
> conditions. I tried several such places, for example, lines 295, 796,
> 1338, 1360, 1745, 2401, 2615, and many more.
>
Yep. We need rules for these in particular. They aren't really
straightforward because the expected indent style varies, afaict. For
example:
#ifdef WINDOWSNT
#include "w32.h"
#endif
compared to
#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* Increment number of allocated matrices. This count is used
to detect memory leaks. */
++glyph_matrix_count;
#endif
Is it a correct assuption to think that whatever is inside one of these
if-blocks should indent according to their grand-parents rule?
In this case:
static struct glyph_matrix *
new_glyph_matrix (struct glyph_pool *pool)
{
struct glyph_matrix *result = xzalloc (sizeof *result);
#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* Increment number of allocated matrices. This count is used
to detect memory leaks. */
++glyph_matrix_count;
#endif
/* Set pool and return. */
result->pool = pool;
return result;
}
++glyph_matrix_count;
is indented one step from the compound_statement node, right? So we
need a way to "ignore" the parents indentation.
> Strangely, in other places indentation does work: lines 1069, 3119.
>
Yeah, in these cases we have something other than the preproc directive
itself to indent from.
Theo
next prev parent reply other threads:[~2023-02-17 19:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 20:48 bug#61558: 29.0.60; Indentation with c-ts-mode doesn't work in code guarded by #ifdef..#endif Eli Zaretskii
2023-02-17 19:23 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-17 19:32 ` Eli Zaretskii
2023-02-17 19:49 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-18 9:53 ` Eli Zaretskii
2023-02-18 21:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-18 21:30 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-19 7:42 ` Eli Zaretskii
2023-02-19 9:20 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-19 7:43 ` Eli Zaretskii
2023-02-19 8:01 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-25 4:30 ` Yuan Fu
2023-02-25 6:37 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-26 8:49 ` Yuan Fu
2023-02-26 10:30 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cz68p03u.fsf@thornhill.no \
--to=bug-gnu-emacs@gnu.org \
--cc=61558@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.