So here's the summary: To add new keywords to the mode
(font-lock-add-keywords 'emacs-lisp-mode '(("foo" . font-lock-keyword-face)))
It can have regular expressions:
(font-lock-add-keywords 'emacs-lisp-mode '(("\\[\\(.+?\\)\\]" . font-lock-keyword-face)))
(this makes the font all in square brackets of a given color)
For the current mode and current emacs session, you can simply evaluate the following:
(font-lock-add-keywords nil '(("\\[\\(.+?\\)\\]" . font-lock-keyword-face)))
(note - mode is not specified here)
To make it permanent, you can add it as a mode binding:
(add-hook 'bk-grmx-mode-hook (lambda () (font-lock-add-keywords nil '(("\\[\\(.+?\\)\\]" . font-lock-keyword-face))) ) )
You can also add it to the mode specification:
(define-derived-mode bk-grmx-mode fundamental-mode (setq font-lock-defaults '(bk-grmx-keyWords)) ;; the next line is added: (font-lock-add-keywords nil '(("\\[\\(.+?\\)\\]" . font-lock-keyword-face))) (setq mode-name "bk-grmx-mode")
Adobe source share