]> code.delx.au - gnu-emacs-elpa/blob - README.md
Added description of indentation style
[gnu-emacs-elpa] / README.md
1 js2-mode
2 ========
3
4 An improved JavaScript mode for GNU Emacs. Forked from <http://code.google.com/p/js2-mode/>.
5
6 Install
7 =======
8
9 $ git clone git://github.com/mooz/js2-mode.git
10 $ cd js2-mode
11 $ emacs --batch --eval '(byte-compile-file "js2-mode.el")'
12
13 Then, place js2-mode.elc into your site-lisp directory.
14
15 In you emacs config:
16
17 (autoload 'js2-mode "js2-mode" nil t)
18 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
19
20 See <http://code.google.com/p/js2-mode/wiki/InstallationInstructions> for details.
21
22 Differences between original js2-mode.el
23 ========================================
24
25 Support for abbreviated destructuring assignments
26 -------------------------------------------------
27
28 let {a, b} = {a: 10, b: 20}; // Abbreviated (Not supported in original js2-mode.el)
29 let {a: a, b: b} = {a: 10, b: 20}; // Same as above (Supported in original js2-mode.el)
30
31 (function ({responseText}) { /* */ })(xhr); // As the argument of function
32
33 Support for expression closure in property value
34 ------------------------------------------------
35
36 let worker = {
37 get age() 20,
38 get sex() "male",
39 fire: function () _fire()
40 };
41
42 Supported more popular indentation style
43 ----------------------------------------
44
45 When js2-consistent-level-indent-inner-bracket-p is non-nil
46
47 [foo, bar, baz].forEach(function (v) {
48 if (validate(v))
49 process(v);
50 });
51
52 [a, b, c].some(function (v) {
53 return validate(v);
54 });
55
56 When js2-consistent-level-indent-inner-bracket-p is nil
57 (Same as original js2-mode's indentation)
58
59 [foo, bar, baz].forEach(function (v) {
60 if (validate(v))
61 process(v);
62 });
63
64 [a, b, c].some(function (v) {
65 return validate(v);
66 });
67
68 Fixed the odd indentation of "else if" with no braces
69 -----------------------------------------------------
70
71 In original js2-mode.el,
72
73 if (foo)
74 return foo;
75 else if (bar)
76 return bar; // here
77
78 In this js2-mode.el,
79
80 if (foo)
81 return foo;
82 else if (bar)
83 return bar; // fixed
84
85 Bugs
86 ====
87
88 If you find problems, please report them to <http://github.com/mooz/js2-mode/issues>.