From: Lars Ingebrigtsen <larsi@gnus.org>
To: Alan Mackenzie <acm@muc.de>
Cc: Sam Pagenkopf <ssaammp@gmail.com>, 27130@debbugs.gnu.org
Subject: bug#27130: c-mode indentation mistreats structs in function arguments
Date: Wed, 02 Dec 2020 10:55:26 +0100 [thread overview]
Message-ID: <871rg85y7l.fsf@gnus.org> (raw)
In-Reply-To: <X8UmIl+Yp8A/R17n__19080.0212485314$1606756311$gmane$org@ACM> (Alan Mackenzie's message of "Mon, 30 Nov 2020 17:04:34 +0000")
Alan Mackenzie <acm@muc.de> writes:
> Hello, Lars.
>
> On Mon, Nov 30, 2020 at 12:11:56 +0100, Lars Ingebrigtsen wrote:
>> Sam Pagenkopf <ssaammp@gmail.com> writes:
>
>> > In emacs 25.2.1.
>
>> > Relevant code:
>
>> > draw_add(&battle.draw, (Drawn){
>> > .kind = DRAW_RECT,
>> > .size = {40,24},
>> > .pos.border = {
>> > .align = {ALIGN_LEFT, ALIGN_TOP},
>> > .dist = 3
>> > }
>> > }
>> > );
>
>> > My guess is that it's reading (Drawn){...} as a statement, and the , as
>> > the (,) C operator.
>
>> I'm not sure how this should be indented (as I didn't even know that
>> that was valid C). But that does look wrong, in any case. (I've
>> confirmed that it indents it the same way in Emacs 28.)
>
>> Alan?
>
> That's strange. In my Emacs 28 copy, I get this indentation:
>
> int main ()
> {
> draw_add(&battle.draw, (Drawn){
> .kind = DRAW_RECT,
> .size = {40,24},
> .pos.border = {
> .align = {ALIGN_LEFT, ALIGN_TOP},
> .dist = 3
> }
> }
> );
> }
>
> , which apart from the closing parenthesis being indented too far, looks
> basically OK.
I was thinking the next-to-last } was in a somewhat odd place (the one
that closes the Drawn), but on the other hand I don't really know where
else it should be. On the third hand...
int main ()
{
draw_add(&battle.draw, (Drawn)
{
.kind = DRAW_RECT,
.size = {40,24},
.pos.border = {
.align = {ALIGN_LEFT, ALIGN_TOP},
.dist = 3
}
}
);
}
Now the end brace looks correct to me. So perhaps it should be indented
the same way in the original case? That is:
int main ()
{
draw_add(&battle.draw, (Drawn) {
.kind = DRAW_RECT,
.size = {40,24},
.pos.border = {
.align = {ALIGN_LEFT, ALIGN_TOP},
.dist = 3
}
}
);
}
I'm talking about the braces only -- as you point out, the end
parenthesis is a different matter.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
prev parent reply other threads:[~2020-12-02 9:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 13:33 bug#27130: c-mode indentation mistreats structs in function arguments Sam Pagenkopf
2020-11-30 11:11 ` Lars Ingebrigtsen
2020-11-30 17:04 ` Alan Mackenzie
2020-12-02 9:55 ` Lars Ingebrigtsen [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871rg85y7l.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=27130@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=ssaammp@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).