]> code.delx.au - gnu-emacs-elpa/blob - README.md
Update scenarios. Update readme.
[gnu-emacs-elpa] / README.md
1 # Context Coloring
2
3 <p align="center">
4 <img alt="Screenshot of JavaScript code highlighted by context." src="screenshot.png" title="Screenshot">
5 </p>
6
7 Highlights JavaScript code according to function context.
8
9 - Code in the global scope is one color. Code in functions within the global
10 scope is a different color, and code within such functions is another color,
11 and so on.
12 - Identifiers retain the color of the scope in which they were declared.
13 - Identifiers are bold when first declared.
14 - Comments are gray and italic.
15
16 JavaScript programmers often leverage closures to bind nearby data to
17 functions. Lexical scope information at-a-glance can assist a programmer in
18 understanding the overall structure of a program. It can also help curb nasty
19 bugs, like implicit globals and name shadowing. A rainbow can indicate excessive
20 complexity. A spot of contrast following by an assignment expression could be a
21 side-effect... or, a specially-constructed object's private state could be being
22 manipulated.
23
24 This coloring scheme is probably more useful than conventional JavaScript
25 *syntax* highlighting. Highlighting keywords can help detect spelling errors, or
26 alert one to unclosed string literals; but so can a [linter][].
27
28 ## Features
29
30 - Light and dark color schemes.
31 - Really fast async AST parsing. Some parse / recolor times:
32 - jQuery (9191 lines): 0.41 seconds
33 - lodash (6786 lines): 0.22 seconds
34 - Async (1124 lines): 28 milliseconds
35 - mkdirp (98 lines): instant
36
37 ## Usage
38
39 Requires Emacs 24+ and [Node.js 0.10+][node].
40
41 - Clone this repository.
42 - Run `make` in it.
43 - Add it to your [load path][].
44 - Add the following to your `~/.emacs`:
45
46 ```lisp
47 (require 'context-coloring)
48 (add-hook 'js-mode-hook 'context-coloring-mode)
49 ```
50
51 [linter]: https://github.com/jacksonrayhamilton/jslinted
52 [emacs integration]: https://github.com/jacksonrayhamilton/jslinted#emacs-integration
53 [node]: http://nodejs.org/download/
54 [load path]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html