]> code.delx.au - gnu-emacs-elpa/blob - README.md
Merge branch 'feature/language-generalization' into develop
[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 - Light and dark color schemes.
34 - Fast async AST parsing. Some total parse + recolor times:
35 - jQuery (9191 lines): 0.63 seconds
36 - Lodash (6786 lines): 0.37 seconds
37 - Async (1124 lines): 0.17 seconds
38 - mkdirp (98 lines): 0.09 seconds
39
40 ## Usage
41
42 Requires Emacs 24+.
43
44 JavaScript language support requires [Node.js 0.10+][node].
45
46 - Clone this repository.
47
48 ```bash
49 cd ~/.emacs.d/
50 git clone https://github.com/jacksonrayhamilton/context-coloring.git
51 ```
52
53 - Add it to your [load path][].
54 - Add a mode hook for `context-coloring-mode`.
55
56 In your `~/.emacs` file:
57
58 ```lisp
59 (add-to-list 'load-path "~/.emacs.d/context-coloring")
60 (require 'context-coloring)
61 (add-hook 'js-mode-hook 'context-coloring-mode)
62 ```
63
64 [linter]: https://github.com/jacksonrayhamilton/jslinted
65 [integration]: https://github.com/jacksonrayhamilton/jslinted#emacs-integration
66 [node]: http://nodejs.org/download/
67 [load path]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html