Offer non-aligned indentation in lists in js-mode (Bug#27503)
* lisp/progmodes/js.el (js--proper-indentation): New customization option 'js-indent-align-list-continuation'. Affects argument lists as well as arrays and object properties. * test/manual/indent/js-indent-align-list-continuation-nil.js: Test the change.
This commit is contained in:
parent
caf9244980
commit
9ac7dccc51
3 changed files with 35 additions and 2 deletions
9
etc/NEWS
9
etc/NEWS
|
|
@ -839,8 +839,15 @@ initialization files.
|
|||
---
|
||||
** 'auto-revert-use-notify' is set back to t in 'global-auto-revert-mode'.
|
||||
|
||||
** JS mode
|
||||
|
||||
---
|
||||
** JS mode now sets 'comment-multi-line' to t.
|
||||
*** JS mode now sets 'comment-multi-line' to t.
|
||||
|
||||
---
|
||||
*** New variable 'js-indent-align-list-continuation', when set to nil,
|
||||
will not align continuations of bracketed lists, but will indent them
|
||||
by the fixed width 'js-indent-level'.
|
||||
|
||||
** CSS mode
|
||||
|
||||
|
|
|
|||
|
|
@ -475,6 +475,11 @@ This applies to function movement, marking, and so on."
|
|||
:type 'boolean
|
||||
:group 'js)
|
||||
|
||||
(defcustom js-indent-align-list-continuation t
|
||||
"Align continuation of non-empty ([{ lines in `js-mode'."
|
||||
:type 'boolean
|
||||
:group 'js)
|
||||
|
||||
(defcustom js-comment-lineup-func #'c-lineup-C-comments
|
||||
"Lineup function for `cc-mode-style', for C comments in `js-mode'."
|
||||
:type 'function
|
||||
|
|
@ -2092,7 +2097,8 @@ indentation is aligned to that column."
|
|||
(switch-keyword-p (looking-at "default\\_>\\|case\\_>[^:]"))
|
||||
(continued-expr-p (js--continued-expression-p)))
|
||||
(goto-char (nth 1 parse-status)) ; go to the opening char
|
||||
(if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")
|
||||
(if (or (not js-indent-align-list-continuation)
|
||||
(looking-at "[({[]\\s-*\\(/[/*]\\|$\\)"))
|
||||
(progn ; nothing following the opening paren/bracket
|
||||
(skip-syntax-backward " ")
|
||||
(when (eq (char-before) ?\)) (backward-list))
|
||||
|
|
|
|||
20
test/manual/indent/js-indent-align-list-continuation-nil.js
Normal file
20
test/manual/indent/js-indent-align-list-continuation-nil.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const funcAssignment = function (arg1,
|
||||
arg2,
|
||||
arg3) {
|
||||
return { test: this,
|
||||
which: "would",
|
||||
align: "as well with the default setting"
|
||||
};
|
||||
}
|
||||
|
||||
function funcDeclaration(arg1,
|
||||
arg2
|
||||
) {
|
||||
return [arg1,
|
||||
arg2];
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// indent-tabs-mode: nil
|
||||
// js-indent-align-list-continuation: nil
|
||||
// End:
|
||||
Loading…
Add table
Reference in a new issue