I've just started playing with emacs modes. I've made a derived-mode (from text-mode
), which does simple color modifications for different situations. For example, text above a line of all equal signs (=
) is turned magenta, this is done using the code:
(make-face 'heading-face1)
(set-face-foreground 'heading-face1 "brightmagenta")
(set-face-attribute 'heading-face1 nil :weight 'ultra-bold)
(setq font-lock-heading-face1 'heading-face1)
(font-lock-add-keywords nil '(("\\(.*\n=\\{5,\\}.*\\)"
1 font-lock-heading-face1 prepend)))
When I first open a file that has such text, it is colored appropriately; but if I add an extra =
, or create a new line of =============
, they turn to the normal text color.
Other font-locks do work dynamically. For example, numbers immediately use a different color...
What would cause patterns to be matched differently dynamically from when the file is first opened?