Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The default indentation style for multi-line function calls in many emacs modes is to align the closing round bracket with the other arguments to the function, thus:

function_one(
    arg1,
    arg2
    );

I would prefer it if the closing bracket aligned with the start of the line that contains the opening bracket. For example:

function_one(
    function_two(
        f2_arg1,
        f2_arg2
    ),
    f1_arg2,
    f1_arg3
);

How do I do this?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

For the many modes derived from CC Mode (for example, c-mode, java-mode, php-mode), customise c-offsets-alist so that arglist-close is set to c-lineup-close-paren.

For cperl-mode, customise cperl-indent-parens-as-block to true.

For perl-mode in GNU emacs 24.3 and greater, customise perl-indent-parens-as-block to true.

For python-mode, this behaviour is found in GNU emacs 24.3 and greater.

You can customise a variable by typing M-x customize-variable. Alternatively, add the following lines to your ~/.emacs:

(add-to-list 'c-offsets-alist '(arglist-close . c-lineup-close-paren))
(setq cperl-indent-parens-as-block t)
(setq perl-indent-parens-as-block t)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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