]> code.delx.au - gnu-emacs-elpa/blob - README.md
Update benchmark times.
[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 followed by an assignment expression could be a
21 side-effect... or, a specially-constructed object's private state could be
22 undergoing change.
23
24 This coloring scheme is probably more useful than conventional JavaScript
25 *syntax* highlighting. Highlighting keywords can help one to detect spelling
26 errors, or alert one to unclosed string literals; but so can a [linter][], which
27 can also be integrated into your workflow via [flycheck][].
28
29 ## Features
30
31 - Light and dark color schemes.
32 - Fast async AST parsing. Some total parse + recolor times:
33 - jQuery (9191 lines): 0.63 seconds
34 - Lodash (6786 lines): 0.37 seconds
35 - Async (1124 lines): 0.17 seconds
36 - mkdirp (98 lines): 0.09 seconds
37
38 ## Usage
39
40 Requires Emacs 24+ and [Node.js 0.10+][node].
41
42 - Clone this repository.
43 - Run `make` in it.
44 - Add it to your [load path][].
45 - Add the following to your `~/.emacs`:
46
47 ```lisp
48 (require 'context-coloring)
49 (add-hook 'js-mode-hook 'context-coloring-mode)
50 ```
51
52 [linter]: https://github.com/jacksonrayhamilton/jslinted
53 [flycheck]: https://github.com/flycheck/flycheck
54 [node]: http://nodejs.org/download/
55 [load path]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html