[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cc-mode and continuing a for loop statement over two lines
From: |
nullius . filius |
Subject: |
Re: cc-mode and continuing a for loop statement over two lines |
Date: |
Thu, 28 Feb 2008 18:05:17 -0800 (PST) |
User-agent: |
G2/1.0 |
Thank you Nikolaj,
I could not get your code snippet to double indent. I like
the concept behind your hack, and I will play around with
it because I'm sure it will work.
Nikolaj Schumacher wrote:
> nullius.filius@gmail.com wrote:
>
> > I would like to indent twice if I have to continue a
> > for loop statement onto more than one line. For example,
> > as in the following code-
> >
> > for (vector<int>::iterator iter(data.begin());
> > iter != data.end(); ++iter)
> > {
> > // do something
> > }
>
> Here's what I came up with:
>
> (defun indent-for-cont (langelem)
> (let ((beg (car (c-declaration-limits nil))))
> (if (equal "for" (buffer-substring-no-properties beg (+ 3 beg)))
> '+
> 0)))
>
> Then add this:
> (statement . indent-for-cont)
> to your c-offsets-alist.
>
>
> regards,
> Nikolaj Schumacher