]> code.delx.au - gnu-emacs-elpa/commitdiff
Update scenarios. Update readme.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 23 Nov 2014 12:42:14 +0000 (04:42 -0800)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 23 Nov 2014 12:42:14 +0000 (04:42 -0800)
README.md
benchmark/scenarios.el
context-coloring.el

index 6735ff5b892bf4ccfdb3b97fdd0a485242895e28..14a71d61d0b5546f2629b8c85b22071e910021bf 100644 (file)
--- a/README.md
+++ b/README.md
@@ -13,24 +13,26 @@ Highlights JavaScript code according to function context.
 - Identifiers are bold when first declared.
 - Comments are gray and italic.
 
-In JavaScript, we are constantly leveraging closures to bind nearby
-data. Lexical scope information at-a-glance can assist a programmer in
+JavaScript programmers often leverage closures to bind nearby data to
+functions. Lexical scope information at-a-glance can assist a programmer in
 understanding the overall structure of a program. It can also help curb nasty
-bugs like implicit globals and name shadowing, and act as an indicator of
-excessive complexity.
-
-There are some breakthrough advantages, too. Context coloring could enable a
-programmer to write in a functional style. It would be easy to tell when he had
-escaped the boundaries of his function and produced side-effects.
-
-Context coloring also improves a programmer's ability to write functions that
-construct objects with implicit private state (which is a good way to avoid
-`this` too).
+bugs, like implicit globals and name shadowing. A rainbow can indicate excessive
+complexity. A spot of contrast following by an assignment expression could be a
+side-effect... or, a specially-constructed object's private state could be being
+manipulated.
 
 This coloring scheme is probably more useful than conventional JavaScript
 *syntax* highlighting. Highlighting keywords can help detect spelling errors, or
-alert one to unclosed string literals; but so can a [linter][]. (If you haven't
-already, you should [integrate][emacs integration] one into your editor.)
+alert one to unclosed string literals; but so can a [linter][].
+
+## Features
+
+- Light and dark color schemes.
+- Really fast async AST parsing. Some parse / recolor times:
+  - jQuery (9191 lines): 0.41 seconds
+  - lodash (6786 lines): 0.22 seconds
+  - Async (1124 lines): 28 milliseconds
+  - mkdirp (98 lines): instant
 
 ## Usage
 
index 0a0287b3ea660bcac169f80f2e30c627237ffb96..7eed6ec52bb8ef1b92b8ad52319488ec73caff74 100644 (file)
@@ -2,12 +2,18 @@
 (add-hook 'js-mode-hook 'context-coloring-mode)
 (elp-instrument-package "context-coloring-")
 
-;; Test 5 times.
-(find-file (expand-file-name
-            "./fixtures/jquery-2.1.1.js"
-            (file-name-directory (or load-file-name buffer-file-name))))
-(dotimes (n 4)
-  (sit-for 2)
-  (revert-buffer t t))
-(sit-for 2)
+(dolist (path '("./fixtures/jquery-2.1.1.js"
+                "./fixtures/lodash-2.4.1.js"
+                "./fixtures/async-0.9.0.js"
+                "./fixtures/mkdirp-0.5.0.js"))
+
+  ;; Test 5 times.
+  (find-file (expand-file-name
+              path
+              (file-name-directory (or load-file-name buffer-file-name))))
+  (dotimes (n 4)
+    (sit-for 2)
+    (revert-buffer t t))
+  (sit-for 2))
+
 (elp-results)
index 6393fefd018907adab355915677bf91b98b5a3c9..2ddfccc30d746509d73af9fa8ceb416fcae5def0 100644 (file)
@@ -193,7 +193,7 @@ imply that it should be colorized again.")
   (expand-file-name "./bin/scopifier" context-coloring-path)
   "Path to the external scopifier executable.")
 
-(defsubst context-coloring-apply-tokens (tokens)
+(defun context-coloring-apply-tokens (tokens)
   "Processes TOKENS to apply context-based coloring to the
 current buffer. Tokens are vectors consisting of 4 integers:
 start, end, level, and style."
@@ -218,11 +218,11 @@ buffer."
     (delete-process context-coloring-scopifier-process)
     (setq context-coloring-scopifier-process nil)))
 
-(defsubst context-coloring-parse-array (input)
+(defun context-coloring-parse-array (input)
   "Specialized alternative JSON parser."
   (vconcat (mapcar 'string-to-number (split-string (substring input 1 -1) ","))))
 
-(defsubst context-coloring-scopify ()
+(defun context-coloring-scopify ()
   "Invokes the external scopifier with the current buffer's
 contents, reading the scopifier's response asynchronously and
 applying a parsed list of tokens to