Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 9 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 cperl-mode, GNU Emacs 24.3+, set cperl-close-paren-offset to the negative of cperl-indent-level
  • 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
    
Is there any way of getting this to work in python-mode with Emacs 23.1.1? – ishmael Oct 10 '14 at 3:31
    
The solution for Emacs 23.1.1 is simply to get the latest python-mode.el here. Untar it in your ~/.emacs.d directory, then in your .emacs file, add this: (add-to-list 'load-path (expand-file-name "~/.emacs.d/python-mode.el-6.1.3")) (require 'python-mode) – ishmael Oct 10 '14 at 4:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .