0

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.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
Nordlöw
  • 11,838
  • 10
  • 52
  • 99

2 Answers2

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
0

EmacsWiki is a great source for emacs knowledge, such as this.

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
  • 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