2

Right now, my argument lists are indented by js-mode like this:

some_long_function_name( one_argument,
                         another_argument );

How can I get them to look like this:

some_long_function_name( one_argument,
    another_argument );

(My c-basic-offset is already set to 4.)

  • If the answer below doesn't work for you, this one might help: emacs.stackexchange.com/a/29975/4085 – Colin Fraizer Jan 13 '17 at 23:10
  • @ColinFraizer Yep, looked at that. Thanks for the link. – APerson Jan 14 '17 at 2:19
  • Have you looked at js2-mode? It's significantly more flexible than the built-in js-mode. A quick grep reveals the user option js2-bounce-indent-p may be of interest. – Basil Jul 4 '17 at 6:43
2

Support for this was recently added in the Emacs development tree, in response to the bug#27503 feature request, which in turn was inspired by a duplicate of this question.

The user option which controls this behaviour is js-indent-align-list-continuation, and it affects all list-like structures:

js-indent-align-list-continuation is a variable defined in js.el.

Its value is t

Documentation:

Align continuation of non-empty ([{ lines in js-mode.

So, for the desired effect:

(setq-default js-indent-align-list-continuation nil)

In order to avail of this option, however, you will need to either:

  • compile and install the latest Emacs;
  • wait for Emacs 26 to be released; or
  • place a patched version of js.el in your load-path.

Alternatively, you can override the current behaviour to match the future behaviour as per Colin Fraizer's answer to the aforementioned duplicate question.

1

This isn't quite what you're looking for, but you can get another_argument to be where you want by putting a newline before one_argument:

some_long_function_name( 
    one_argument,
    another_argument
);

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.