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:


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


How do I do this?

  • 1
    I have been ignoring the same urge for years! Today is the day to fix it. Jan 12 '18 at 8:26
  • 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)
  • 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
  • And how do I make this work in C or C++? Jan 12 '18 at 8:45
  • Is there any way to get the other style in python-mode on Emacs >= 24.3?
    – mgalgs
    Oct 5 '18 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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