Set the color of a keyword

Hello,

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?

Thanks,
P

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?

Thanks

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?

Thanks,
P