]> code.delx.au - gnu-emacs-elpa/blob - README.md
Documentation.
[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 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 - Comments are gray.
14
15 Lexical scope information at-a-glance can assist a programmer in understanding
16 the overall structure of a program. It can also help curb nasty bugs like name
17 shadowing or unexpected assignment. A rainbow can indicate excessive
18 complexity. A spot of contrast followed by an assignment expression could be a
19 side-effect... or, the state of a closure could be undergoing change.
20
21 This coloring strategy is probably more useful than conventional *syntax*
22 highlighting. Highlighting keywords can help one to detect spelling errors, and
23 highlighting the content between quotation marks can alert one to unclosed
24 string literals. But a [linter][] could also spot those errors, and if
25 [integrated via flycheck][integration], an extra spot opens up in your editing
26 toolbelt.
27
28 Give context coloring a try; you may find that it *changes the way you write
29 code*.
30
31 ## Features
32
33 - Supported languages: JavaScript
34 - Light and dark color schemes.
35 - Fast async AST parsing. Some total parse + recolor times:
36 - jQuery (9191 lines): 0.63 seconds
37 - Lodash (6786 lines): 0.37 seconds
38 - Async (1124 lines): 0.17 seconds
39 - mkdirp (98 lines): 0.09 seconds
40 - Extensible. Just write a scopifier for the language of your choice and add an
41 entry to `context-coloring-scopifier-plist`.
42 - Customizable. If you don't like the color schemes, or you want them to match
43 your favorite theme, just `M-x customize` and search for "context-coloring".
44
45 ## Usage
46
47 Requires Emacs 24+.
48
49 JavaScript language support requires [Node.js 0.10+][node].
50
51 - Clone this repository.
52
53 ```bash
54 cd ~/.emacs.d/
55 git clone https://github.com/jacksonrayhamilton/context-coloring.git
56 ```
57
58 - Add it to your [load path][].
59 - Add a mode hook for `context-coloring-mode`.
60
61 In your `~/.emacs` file:
62
63 ```lisp
64 (add-to-list 'load-path "~/.emacs.d/context-coloring")
65 (require 'context-coloring)
66 (add-hook 'js-mode-hook 'context-coloring-mode)
67 ```
68
69 [linter]: https://github.com/jacksonrayhamilton/jslinted
70 [integration]: https://github.com/jacksonrayhamilton/jslinted#emacs-integration
71 [node]: http://nodejs.org/download/
72 [load path]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html