4 <img alt="Screenshot of JavaScript code highlighted by context." src="screenshot.png" title="Screenshot">
7 Highlights JavaScript code according to function context.
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,
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.
16 This coloring scheme is probably more useful than conventional JavaScript
17 *syntax* highlighting. Highlighting keywords can help detect spelling errors, or
18 alert one to unclosed string literals; but so can a [linter][]. (If you haven't
19 already, you should [integrate][emacs integration] one into your editor.)
21 In JavaScript, we are constantly leveraging closures to bind nearby
22 data. Lexical scope information at-a-glance can assist a programmer in
23 understanding the overall structure of a program. It can also help curb nasty
24 bugs like implicit globals and name shadowing, and act as an indicator of
27 There are some breakthrough advantages, too. Context coloring could enable a
28 programmer to write in a functional style. It would be easy to tell when he had
29 escaped the boundaries of his function and produced side-effects.
31 Context coloring also improves a programmer's ability to write functions that
32 construct objects with implicit private state (which is a good way to avoid
37 Requires Emacs 24+ and [Node.js 0.10+][node].
39 - Clone this repository.
41 - Add it to your [load path][].
42 - Add the following to your `~/.emacs`:
45 (require 'context-coloring)
46 (add-hook 'js-mode-hook 'context-coloring-mode)
49 [linter]: https://github.com/jacksonrayhamilton/jslinted
50 [emacs integration]: https://github.com/jacksonrayhamilton/jslinted#emacs-integration
51 [node]: http://nodejs.org/download/
52 [load path]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html