help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: continuing indentation in for loop condition in cc-mode


From: Gregory Fong
Subject: Re: continuing indentation in for loop condition in cc-mode
Date: Fri, 12 Feb 2016 18:18:31 -0800

(sorry if you get this twice, I didn't realize I wasn't subscribed
to the list, tried to send using gmane, then that didn't work, so
now I'm just using the reply mailto button from the archive,
which might break the thread)

Emanuel Berg <embe8573 <at> student.uu.se> writes:
> Gregory Fong <gregory.0xf0 <at> gmail.com> writes:
> > for (int i = 0;
> >   i < 5;
> >   ++i)
> > {
> > }
> >
> > but I can't seem to find an offset that adjusts this
> > parameter. c-show-syntatic information just shows
> > these as being a statement.
> >
> > Emacs will default to align with the first item in
> > the condition:
> >
> > for (int i = 0;
> >      i < 5;
> >      ++i)
> > {
> > }
> >
> > I can't imagine that I'm the only person who has
> > tried to change this, but it's surprisingly
> > difficult to search for answers.
>
> Why is that so surprising? I'd say most people would
> agree with the Emacs default.
>
> Doesn't it make the most sense as well?

I personally like the default.  Unfortunately, the company
I work for uses the style I mentioned at the top.

This is mostly surprising to me because it's really the
only indentation issue I've ever run into using emacs.
Everything else has been customizable regardless of
whatever bizarro coding standard I've had to use, which
is impressive.

>
> And, for such a basic for loop, why not put everything
> on the same line?
>
>     for (int i = 0; i < ARRAY_SIZE; i++) {
>         ...
>     }
>

Yes, that was a poor example.  I was thinking more
of the sorts of long lines you tend to get when working
in C++ with iterators, in which case I'm trying to get it
to look like this:

    for (auto iter = RidiculouslyLongClassName.begin();
      iter < RidiculouslyLongClassName.end();
      ++iter)
    {
      ...
    }


As it is right now, I keep having to remember to fix the
indentation manually, which has been driving me nuts.

If there's a known way to change this behavior, or if you
have an idea on where to start looking at how to do this,
I'd love to hear it. Just not sure where to start.

Thanks and regards,
Gregory



reply via email to

[Prev in Thread] Current Thread [Next in Thread]