diff options
| author | Ingo Lohmar | 2017-07-01 13:09:20 +0200 |
|---|---|---|
| committer | Ingo Lohmar | 2017-07-03 20:06:27 +0200 |
| commit | 9ac7dccc51ee834b06cdabf6a5746eb375f984f0 (patch) | |
| tree | e828d23bc109d4576169f782dba1982c840f822c | |
| parent | caf92449802ea2250d6ac30a01797b0554d71dc3 (diff) | |
| download | emacs-9ac7dccc51ee834b06cdabf6a5746eb375f984f0.tar.gz emacs-9ac7dccc51ee834b06cdabf6a5746eb375f984f0.zip | |
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.
| -rw-r--r-- | etc/NEWS | 9 | ||||
| -rw-r--r-- | lisp/progmodes/js.el | 8 | ||||
| -rw-r--r-- | test/manual/indent/js-indent-align-list-continuation-nil.js | 20 |
3 files changed, 35 insertions, 2 deletions
| @@ -839,8 +839,15 @@ initialization files. | |||
| 839 | --- | 839 | --- |
| 840 | ** 'auto-revert-use-notify' is set back to t in 'global-auto-revert-mode'. | 840 | ** 'auto-revert-use-notify' is set back to t in 'global-auto-revert-mode'. |
| 841 | 841 | ||
| 842 | ** JS mode | ||
| 843 | |||
| 844 | --- | ||
| 845 | *** JS mode now sets 'comment-multi-line' to t. | ||
| 846 | |||
| 842 | --- | 847 | --- |
| 843 | ** JS mode now sets 'comment-multi-line' to t. | 848 | *** New variable 'js-indent-align-list-continuation', when set to nil, |
| 849 | will not align continuations of bracketed lists, but will indent them | ||
| 850 | by the fixed width 'js-indent-level'. | ||
| 844 | 851 | ||
| 845 | ** CSS mode | 852 | ** CSS mode |
| 846 | 853 | ||
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index bae9e52bf0f..e6ffe4d75a6 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -475,6 +475,11 @@ This applies to function movement, marking, and so on." | |||
| 475 | :type 'boolean | 475 | :type 'boolean |
| 476 | :group 'js) | 476 | :group 'js) |
| 477 | 477 | ||
| 478 | (defcustom js-indent-align-list-continuation t | ||
| 479 | "Align continuation of non-empty ([{ lines in `js-mode'." | ||
| 480 | :type 'boolean | ||
| 481 | :group 'js) | ||
| 482 | |||
| 478 | (defcustom js-comment-lineup-func #'c-lineup-C-comments | 483 | (defcustom js-comment-lineup-func #'c-lineup-C-comments |
| 479 | "Lineup function for `cc-mode-style', for C comments in `js-mode'." | 484 | "Lineup function for `cc-mode-style', for C comments in `js-mode'." |
| 480 | :type 'function | 485 | :type 'function |
| @@ -2092,7 +2097,8 @@ indentation is aligned to that column." | |||
| 2092 | (switch-keyword-p (looking-at "default\\_>\\|case\\_>[^:]")) | 2097 | (switch-keyword-p (looking-at "default\\_>\\|case\\_>[^:]")) |
| 2093 | (continued-expr-p (js--continued-expression-p))) | 2098 | (continued-expr-p (js--continued-expression-p))) |
| 2094 | (goto-char (nth 1 parse-status)) ; go to the opening char | 2099 | (goto-char (nth 1 parse-status)) ; go to the opening char |
| 2095 | (if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)") | 2100 | (if (or (not js-indent-align-list-continuation) |
| 2101 | (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")) | ||
| 2096 | (progn ; nothing following the opening paren/bracket | 2102 | (progn ; nothing following the opening paren/bracket |
| 2097 | (skip-syntax-backward " ") | 2103 | (skip-syntax-backward " ") |
| 2098 | (when (eq (char-before) ?\)) (backward-list)) | 2104 | (when (eq (char-before) ?\)) (backward-list)) |
diff --git a/test/manual/indent/js-indent-align-list-continuation-nil.js b/test/manual/indent/js-indent-align-list-continuation-nil.js new file mode 100644 index 00000000000..383b2539a26 --- /dev/null +++ b/test/manual/indent/js-indent-align-list-continuation-nil.js | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | const funcAssignment = function (arg1, | ||
| 2 | arg2, | ||
| 3 | arg3) { | ||
| 4 | return { test: this, | ||
| 5 | which: "would", | ||
| 6 | align: "as well with the default setting" | ||
| 7 | }; | ||
| 8 | } | ||
| 9 | |||
| 10 | function funcDeclaration(arg1, | ||
| 11 | arg2 | ||
| 12 | ) { | ||
| 13 | return [arg1, | ||
| 14 | arg2]; | ||
| 15 | } | ||
| 16 | |||
| 17 | // Local Variables: | ||
| 18 | // indent-tabs-mode: nil | ||
| 19 | // js-indent-align-list-continuation: nil | ||
| 20 | // End: | ||