How do I make change to XXX-font-lock-keywords
(typically using assoc
plus setcdr
) affect the fontification in XXX-mode
? It doesn't suffice to simply change the variable to make the change have effect.
Asked
Active
Viewed 160 times
0
2 Answers
2
The best way, as a normal user, to modify font-lock entries is to use the function font-lock-add-keywords
and font-lock-remove-keywords
. For example:
(font-lock-add-keywords c-mode
'(("\\<\\(FIXME\\):" 1
font-lock-warning-face t)))

Lindydancer
- 25,428
- 4
- 49
- 68
-
Aha. I think I'll write a replace version myself then using the `add` and `remove`. Thx. – Nordlöw Nov 20 '12 at 13:24
0
-
But Wikis can change (or sometimes even disappear). Plus, pages on EmacsWiki often address a more general topic, so it's nice when an answer on StackOverflow is a concise, stand-alone source of information. That said, external links can be a great addition to an answer for further reading. – Thomas Nov 20 '12 at 05:14
-
@Thomas - reposting answers to obvious questions seems like a waste of everyone's time, especially if the answers are easily findable and more detailed than anyone would generally give in an SO post. i agree that not everything on EmacsWiki is as accessible, but this is font-lock 101. Not to mention that the answer posted here may become out of date, while EmacsWiki will be maintained over time. – jtahlborn Nov 20 '12 at 13:00