]> code.delx.au - gnu-emacs-elpa/blob - README.md
Version 8.0.1.
[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 - Node.js "file-level" scope detection.
20 - Emacs Lisp support:
21 - `defun`, `lambda`, `let`, `let*`, `cond`, `condition-case`, `defadvice`,
22 `dolist`, `quote`, `backquote` and backquote splicing.
23 - Works in `eval-expression` too.
24
25 ## Installation
26
27 Requires Emacs 24.3+. JavaScript language support requires
28 [js2-mode](https://github.com/mooz/js2-mode).
29
30 To install, run the command `M-x package-install RET context-coloring RET`, and
31 then add the following to your init file:
32
33 ```lisp
34 ;; JavaScript:
35 (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
36 (add-hook 'js2-mode-hook #'context-coloring-mode)
37
38 ;; Emacs Lisp:
39 (add-hook 'emacs-lisp-mode-hook #'context-coloring-mode)
40
41 ;; eval-expression:
42 (add-hook 'eval-expression-minibuffer-setup-hook #'context-coloring-mode) ; 24.4+
43 (add-hook 'minibuffer-setup-hook #'context-coloring-mode) ; 24.3
44 ```
45
46 ## Color Schemes
47
48 The [Zenburn](https://github.com/bbatsov/zenburn-emacs) theme, featured in the
49 screenshot above, now supports context coloring.
50
51 You can define your own colors by customizing faces like
52 `context-coloring-level-N-face`, where N is a number starting from 0.
53
54 [See here](https://gist.github.com/jacksonrayhamilton/6b89ca3b85182c490816) for
55 some color schemes for popular custom themes.
56
57 ## Options
58
59 - `context-coloring-syntactic-comments` (default: `t`): If non-nil, also color
60 comments using `font-lock`.
61 - `context-coloring-syntactic-strings` (default: `t`): If non-nil, also color
62 strings using `font-lock`.
63 - `context-coloring-javascript-block-scopes` (default: `nil`): If non-nil, also
64 color block scopes in the scope hierarchy in JavaScript.
65 - `context-coloring-javascript-detect-top-level-scope` (default: `t`): If
66 non-nil, detect when to use file-level scope.