To install this package, run in Emacs:
M-x package-install RET context-coloring RET
Highlights code by scope. Top-level scopes are one color, second-level scopes are another color, and so on. Variables retain the color of the scope in which they are defined. A variable defined in an outer scope referenced by an inner scope is colored the same as the outer scope. By default, comments and strings are still highlighted syntactically.