all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27130: c-mode indentation mistreats structs in function arguments
@ 2017-05-29 13:33 Sam Pagenkopf
  2020-11-30 11:11 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Pagenkopf @ 2017-05-29 13:33 UTC (permalink / raw)
  To: 27130

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 566 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#27130: c-mode indentation mistreats structs in function arguments
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-11-30 11:11 UTC (permalink / raw)
  To: Sam Pagenkopf; +Cc: 27130, Alan Mackenzie

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?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#27130: c-mode indentation mistreats structs in function arguments
  2020-11-30 11:11 ` Lars Ingebrigtsen
@ 2020-11-30 17:04   ` Alan Mackenzie
  2020-12-02  9:55     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2020-11-30 17:04 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Sam Pagenkopf, 27130, acm

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.  Possibly, one might want the .kind line indented one space
further (it is indented 2 * c-basic-offset from the draw_add on the
previous line).  C-c C-s on that line gives the following analysis:

    ((arglist-cont-nonempty 19 27) (brace-list-intro 19))

.  C-c C-s on the following line should give

    ((brace-list-entry 63))

, where 63 is the position of the . in .kind.  This is correct.  In fact,
something in this area was corrected in the last three or four years, 

The closing paren is lined up by c-align-arglist-close-under-paren, which
contains a bit of DWIMery which misfires here, causing the ) to be
indented c-basic-offset from the first character on the line opening the
construct (here the draw_add line).  This DWIMery has also recently
misfired on a C++ file, so I think I'll have to modernise
c-align-arglist-close-under-paren to be more discerning.

> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#27130: c-mode indentation mistreats structs in function arguments
  2020-11-30 17:04   ` Alan Mackenzie
@ 2020-12-02  9:55     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-02  9:55 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Sam Pagenkopf, 27130

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-02  9:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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.