diff options
author | Jackson Ray Hamilton <jackson@jacksonrayhamilton.com> | 2015-03-07 18:01:05 -0800 |
---|---|---|
committer | Jackson Ray Hamilton <jackson@jacksonrayhamilton.com> | 2015-03-10 10:19:07 -0700 |
commit | 933e0ab4b0d583b81b8624def414b7895987927b (patch) | |
tree | 881ed232dbd2f0e6443a7036dfcb9fd37bc5aaad /test | |
parent | 33d9869b5f7a5acaca838e2b57e5ae713df9603d (diff) | |
download | emacs-933e0ab4b0d583b81b8624def414b7895987927b.tar.gz |
New indentation option for js-mode
* lisp/progmodes/js.el (js--proper-indentation): Add new custom option
`js-indent-first-initialiser' and a function to utilize it,
`js--maybe-goto-declaration-keyword-end'.
* test/indent/js.js: Add local variables.
* test/indent/js-indent-first-initialiser-t.js: New test for
`js-indent-first-initialiser'.
* test/indent/js-indent-first-initialiser-dynamic.js: New test for
`js-indent-first-initialiser'.
Diffstat (limited to 'test')
-rw-r--r-- | test/indent/js-indent-first-initialiser-dynamic.js | 30 | ||||
-rw-r--r-- | test/indent/js-indent-first-initialiser-t.js | 21 | ||||
-rw-r--r-- | test/indent/js.js | 7 |
3 files changed, 56 insertions, 2 deletions
diff --git a/test/indent/js-indent-first-initialiser-dynamic.js b/test/indent/js-indent-first-initialiser-dynamic.js new file mode 100644 index 00000000000..9c705dbeba9 --- /dev/null +++ b/test/indent/js-indent-first-initialiser-dynamic.js @@ -0,0 +1,30 @@ +var foo = function() { + return 7; +}; + +var foo = function() { + return 7; + }, + bar = 8; + +var foo = function() { + return 7; + }, + bar = function() { + return 8; + }; + +// Local Variables: +// indent-tabs-mode: nil +// js-indent-level: 2 +// js-indent-first-initialiser: dynamic +// End: + +// The following test intentionally produces a scan error and should +// be placed below all other tests to prevent awkward indentation. +// (It still thinks it's within the body of a function.) + +var foo = function() { + return 7; + , + bar = 8; diff --git a/test/indent/js-indent-first-initialiser-t.js b/test/indent/js-indent-first-initialiser-t.js new file mode 100644 index 00000000000..2f08527e5ff --- /dev/null +++ b/test/indent/js-indent-first-initialiser-t.js @@ -0,0 +1,21 @@ +var foo = function() { + return 7; + }; + +var foo = function() { + return 7; + }, + bar = 8; + +var foo = function() { + return 7; + }, + bar = function() { + return 8; + }; + +// Local Variables: +// indent-tabs-mode: nil +// js-indent-level: 2 +// js-indent-first-initialiser: t +// End: diff --git a/test/indent/js.js b/test/indent/js.js index f41849da284..ad7cb56a277 100644 --- a/test/indent/js.js +++ b/test/indent/js.js @@ -1,5 +1,3 @@ -// -*- js-indent-level: 2 -*- - var a = 1; b = 2; @@ -65,3 +63,8 @@ b += baz(`http://foo.bar/${tee}`) .qux(); + +// Local Variables: +// indent-tabs-mode: nil +// js-indent-level: 2 +// End: |