]> code.delx.au - gnu-emacs-elpa/blobdiff - README.md
Update README
[gnu-emacs-elpa] / README.md
index 780a1e694c2f895a32f080a7f2a550d82c83358d..85e7e7b2824cb2c5b3ac332559513413b9cdd573 100644 (file)
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Install
 
     $ git clone git://github.com/mooz/js2-mode.git
     $ cd js2-mode
-    $ emacs --batch --eval '(byte-compile-file "js2-mode.el")'
+    $ emacs --batch -f batch-byte-compile js2-mode.el
 
 Then, place js2-mode.elc into your site-lisp directory.
 
@@ -22,10 +22,10 @@ See <http://code.google.com/p/js2-mode/wiki/InstallationInstructions> for detail
 Differences between original js2-mode.el
 ========================================
 
-Supported more popular indentation style
-----------------------------------------
+Popular indentation style
+-------------------------
 
-When js2-consistent-level-indent-inner-bracket-p is non-nil
+When `js2-consistent-level-indent-inner-bracket-p` is non-nil
     
     [foo, bar, baz].forEach(function (v) {
         if (validate(v))
@@ -36,7 +36,7 @@ When js2-consistent-level-indent-inner-bracket-p is non-nil
         return validate(v);
     });
 
-When js2-consistent-level-indent-inner-bracket-p is nil
+When `js2-consistent-level-indent-inner-bracket-p` is nil
 (Same as original js2-mode's indentation)
 
     [foo, bar, baz].forEach(function (v) {
@@ -48,8 +48,8 @@ When js2-consistent-level-indent-inner-bracket-p is nil
                        return validate(v);
                    });
 
-Fixed ugly indentation with multi-line variable declaration
------------------------------------------------------------
+Pretty multi-line variable declaration
+--------------------------------------
 
 In original js2-mode.el,
 
@@ -57,14 +57,14 @@ In original js2-mode.el,
     bar = 20,
     baz = 30;
 
-In this js2-mode.el,
+In this js2-mode.el, when the value `js2-pretty-multiline-decl-indentation-p` is non-nil,
 
     var foo = 10,
         bar = 20,
         baz = 30;
 
-Support for abbreviated destructuring assignments
--------------------------------------------------
+Abbreviated destructuring assignments
+-------------------------------------
 
     let {a, b}       = {a: 10, b: 20}; // Abbreviated   (Not supported in original js2-mode.el)
     let {a: a, b: b} = {a: 10, b: 20}; // Same as above (Supported in original js2-mode.el)
@@ -74,8 +74,8 @@ Support for abbreviated destructuring assignments
     for (let [k, { name, age }] in Iterator(obj)) // nested
         print(k, name, age);
 
-Support for expression closure in property value
-------------------------------------------------
+Expression closure in property value
+------------------------------------
 
     let worker = {
         get age() 20,
@@ -83,8 +83,8 @@ Support for expression closure in property value
         fire: function () _fire()
     };
 
-Fixed odd indentation of "else if" with no braces
------------------------------------------------------
+Fix for odd indentation of "else if" with no braces
+---------------------------------------------------
 
 In original js2-mode.el,
 
@@ -101,7 +101,7 @@ In this js2-mode.el,
         return bar;  // fixed
 
 Fixes in Imenu support
------------------------
+----------------------
 
 Supports element-get form:
 
@@ -114,9 +114,62 @@ Proper position for functions in nested object literals:
         bar: function() {}, // ok in original
         baz: {
              boop: function() {} // fixed here
-        },
+        }
+    }
+
+Imenu support for function nesting
+----------------------------------
+
+Supports one level of nesting:
+
+    function foo() {
+        function bar() { // shown as foo.bar
+            function baz() {} // hidden
+        }
+    }
+
+Top-level function can be anonymous wrapper:
+
+    (function() {
+        var foo = function() {}; // shown as foo
+    })();
+
+Examples of output:
+
+* [Underscore.js](https://github.com/documentcloud/underscore/blob/master/underscore.js)
+-> <https://gist.github.com/824262>
+* [Backbone.js](https://github.com/documentcloud/backbone/blob/master/backbone.js)
+-> <https://gist.github.com/824260>
+
+No support for library-specific extension methods like _.extend.
+
+Highlights undeclared/external variables
+----------------------------------------
+
+Original mode highlights them only on the left side of assignments:
+
+    var house;
+    hose = new House(); // highlights "hose"
+
+Here they are highlighted in all expressions:
+    
+    function feed(fishes, food) {
+        for each (var fish in fshes) { // highlights "fshes"
+            food.feed(fsh); // highlights "fsh"
+        }
+        hood.discard(); // highlights "hood"
     }
 
+Destructuring assignments and array comprehensions (JS 1.7) are supported:
+
+    let three, [one, two] = [1, 2];
+    thee = one + two; // highlights "thee" 
+
+    function revenue(goods) {
+        // highlights "coast"
+        return [price - coast for each ({price, cost} in goods)].reduce(add);
+    }
+    
 Bugs
 ====