Thanks for this code, which allowed me quickly and lightly to color words in my application's tiny language.

I have one recommendation. Although the docs suggest that the textStorageWillProcessEditing delegate notification is not sent when the text is changed programmatically, my experience with OS 10.10.4 shows that applying temporary attributes causes the delegate notification to be raised. Unless your notification method checks whether the text has actually been changed, you will get the notification in an infinite loop.