Context Coloring

Screenshot of JavaScript code highlighted by context in Emacs

Douglas Crockford’s context-based code coloring is a concept that proposes syntax highlighting should be based on the meaning (context) of code, rather than just its surface syntax. (Read more about his proposal here: https://www.crockford.com/contextcoloring.html)

I liked his idea, so I decided to implement it as a plugin for my choice editor, Emacs!

With this plugin, code in lexically-scoped languages (such as JavaScript & Lisp) will be colored according to scope depth. 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.

If you’ve ever wondered how a “closure” works, then turn on context coloring to see!

Install in Emacs with: M-x package-install RET context-coloring RET
Source code: https://github.com/jacksonrayhamilton/context-coloring