Set the color of a keyword


how can I set the color of a keyword?

I found this solution:

But it says to modify library’s files (clicke.js and some .css), which I really want to avoid. Is there an alternative solution?


You could also do this with an overlay, but you’d have to duplicate your language’s string/comment/etc tokenizing logic to avoid false positives (when the word occurs in another syntactic construct).

A false positive would be, for example, if the keyword is in a comment.
How can I easily add an exception for this case?


Also: the function is undocumented.
And I can’t find an example for setting the color of a keyword using that function.
Please can you give me one?