]> code.delx.au - gnu-emacs-elpa/blob - README.md
Remove asynchronous support.
[gnu-emacs-elpa] / README.md
1 # Context Coloring [![Build Status](https://travis-ci.org/jacksonrayhamilton/context-coloring.png?branch=master)](https://travis-ci.org/jacksonrayhamilton/context-coloring) [![Coverage Status](https://coveralls.io/repos/jacksonrayhamilton/context-coloring/badge.svg?branch=master)](https://coveralls.io/r/jacksonrayhamilton/context-coloring?branch=master)
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 by scope. Top-level scopes are one color, second-level scopes
8 are another color, and so on. Variables retain the color of the scope in which
9 they are defined. A variable defined in an outer scope referenced by an inner
10 scope is colored the same as the outer scope.
11
12 By default, comments and strings are still highlighted syntactically.
13
14 ## Features
15
16 - Light and dark (customizable) color schemes.
17 - JavaScript support:
18 - Script, function and block scopes (and even `catch` block scopes).
19 - Very fast for files under 1000 lines.
20 - Emacs Lisp support:
21 - `defun`, `lambda`, `let`, `let*`, `cond`, `condition-case`, `defadvice`,
22 `dolist`, `quote`, `backquote` and backquote splicing.
23 - Instantaneous lazy coloring, 8000 lines-per-second full coloring.
24 - Works in `eval-expression` too.
25
26 ## Installation
27
28 Requires Emacs 24.3+. JavaScript language support requires
29 [js2-mode](https://github.com/mooz/js2-mode).
30
31 `M-x package-install RET context-coloring RET` and add the following to your
32 init file:
33
34 ```lisp
35 ;; JavaScript:
36 (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
37 (add-hook 'js2-mode-hook #'context-coloring-mode)
38
39 ;; Emacs Lisp:
40 (add-hook 'emacs-lisp-mode-hook #'context-coloring-mode)
41
42 ;; eval-expression:
43 (add-hook 'minibuffer-setup-hook #'context-coloring-mode)
44 ```
45
46 ## Customizing
47
48 ### Options
49
50 - `context-coloring-syntactic-comments` (default: `t`): If non-nil, also color
51 comments using `font-lock`.
52 - `context-coloring-syntactic-strings` (default: `t`): If non-nil, also color
53 strings using `font-lock`.
54 - `context-coloring-default-delay` (default: `0.25`): Default delay between a
55 buffer update and colorization.
56 - `context-coloring-javascript-block-scopes` (default: `nil`): If non-nil, also
57 color block scopes in the scope hierarchy in JavaScript.
58
59 ### Color Schemes
60
61 Color schemes for custom themes are automatically applied when those themes are
62 active. Built-in theme support is available for: `ample`, `anti-zenburn`,
63 `grandshell`, `leuven`, `monokai`, `solarized`, `spacegray`, `tango` and
64 `zenburn`.
65
66 You can define your own theme colors too:
67
68 ```lisp
69 (context-coloring-define-theme
70 'zenburn
71 :colors '("#dcdccc"
72 "#93e0e3"
73 "#bfebbf"
74 "#f0dfaf"
75 "#dfaf8f"
76 "#cc9393"
77 "#dc8cc3"
78 "#94bff3"
79 "#9fc59f"
80 "#d0bf8f"
81 "#dca3a3"))
82 ```
83
84 See `C-h f context-coloring-define-theme` for more info on theme parameters.