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

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

cc-mode and continuing a for loop statement over two lines


From: nullius . filius
Subject: cc-mode and continuing a for loop statement over two lines
Date: Wed, 27 Feb 2008 22:40:24 -0800 (PST)
User-agent: G2/1.0

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
}

This is so cc-mode formats like the ANSI predefined style
in astyle.

This is the code in my dot emacs (boosted from elsewhere).
I have not found a variable for tweaking continuation lines
from inside for loop statements.

------------------------------------------------------------------------
(defconst c-indentation 4)
(defvar my-c-style
  `((c-basic-offset                . ,c-indentation)
    (c-tab-always-indent           . t)
    (c-comment-only-line-offset    . 0)
    (c-hanging-braces-alist        . ((substatement-open . (before
after))
                                      (brace-list-open)
                                      (brace-list-close)
                                      (brace-list-intro)
                                      (brace-entry-open)))
    (c-hanging-colons-alist        . ((member-init-intro before)
                                      (inher-intro)
                                      (case-label after)
                                      (label after)
                                      (access-label after)))
    (c-cleanup-list                . (scope-operator
                                      empty-defun-braces
                                      defun-close-semi))
    (c-offsets-alist               . ((arglist-close .
                                        c-lineup-arglist-close-under-
paren)
                                      (substatement-open . 0)
                                      (innamespace . nil)
                                      (label . nil)
                                      (block-open        . 0)
                                      (inline-open       . 0)
                                      (template-args-cont .
                                         c-lineup-template-args)
                                      (inher-cont     . c-lineup-multi-
inher)
                                      (statement-cont . (c-lineup-math
++))
                                      (knr-argdecl-intro . -)))
    (c-echo-syntactic-information-p . t)
    )
  "My C Programming Style")

(defun my-c-mode-common-hook ()
  (c-add-style "PERSONAL" my-c-style t))

(add-hook 'c++-mode-hook 'my-c-mode-common-hook)
 
------------------------------------------------------------------------


reply via email to

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