3

I'm fine-tuning my C++ style using c-add-style, but I've reached an impasse where I cannot convince Emacs to (extra) indent arguments where the first argument starts on a new line.

When I'm forced to start argument lists on a new line I prefer to indent the arguments an extra level to distinguish them from the function body:

void particularlyLongFunctionName(
        particularlyLongTypeName &particularlyLongArgumentName) {
    foo(particularlyLongArgumentName);
    bar();
}

My configuration, on the other hand, indents the argument list no more than the following code block:

void particularlyLongFunctionName(
    particularlyLongTypeName &particularlyLongArgumentName) {
    foo(particularlyLongArgumentName);
    bar();
}

Which field in the c-style-alist controls this setting?

1 Answer 1

7

Set point on the line in question and press C-c C-s to call c-show-syntactic-information. This shows you which variable you need to set.

I set this to:

(c-offsets-alist . (
    (arglist-intro . c-lineup-arglist-intro-after-paren))) ;; first parameter after open paren

which is not quite that what you want, but instead of c-lineup-arglist-intro-after-paren you could use ++.

Test another offset with C-c C-o (which calls c-set-offset).

Also have a look at the cc-mode manual and more concrete at the c-offset-alist docu node. Or at the Wiki.

2
  • This is great! But if I associate arglist-intro with + I get the same behavior that I started out with. @jue Commented Mar 6, 2018 at 7:50
  • @Caterpillar use ++
    – jue
    Commented Mar 7, 2018 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.