Some improvements in "highlighting"

A number of fixes, especially for #1212 (which I made this PR for).

 - [x] Fix "the NULL class" bug. (see d96c2d0 for details and steps to reproduce)
 - [x] Format, improve and optimize the `match-highlighter` addon.
 - [x] Add the selection-mode option (solves #1212).

Watch out! Feel free to provide any feedback you want.