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

[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: Nikolaj Schumacher
Subject: Re: cc-mode and continuing a for loop statement over two lines
Date: Thu, 28 Feb 2008 18:46:20 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.91 (darwin)

address@hidden 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




reply via email to

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