Matt Might’s shell scripts for checking writing style are simple and effective, as is Benjamin Beckwith’s port of them to an Emacs mode. They pick up on some common defects in technical writing, such as use of the passive voice, weasel words and lexical illusions (inadvertent repetition of words.)
As a fun exercise, I decided to port this code to a variety of languages. To start with, I chose ClojureScript. I’d ultimately like to get to the point where I could create a bookmarklet or browser extension for checking my style when writing prose straight into the web browser.
My project’s called Wascal, and it’s the perfect way to eliminate those wascally weasel words, passive voice and duplicate words from your writing. Check out the code here on GitHub.
Here’s a screenshot of the Wascal in action. Below that I’ll present several observations about ClojureScript, discovered while writing the code
A few observations
\2 etc for back-references in matching expressions, and also that, in substitution expressions,
$& is the back-reference for the whole matched expression.
ClojureScript’s default library for manipulating the DOM comes from Google Closure. While I love the minification and dependency handling parts of Closure, it does not present a nice interface for manipulating the DOM. Fortunately a variety of alternatives exist, none of which I’ve tried yet. The most promising to me seems to be Chris Granger’s pinot, wonderfully named as a complement to his noir Clojure web framework.
e.preventDefault() I had to write
(. e (preventDefault)), as opposed to
(.preventDefault e). The latter returns the
preventDefault method itself, whereas the former invokes it.