customize emacs mode and font-lock-defaults

497 views Asked by At

I am writing a minor mode for HTML/PHP templates.

I have a var with PHP keywords

(defvar web-mode-php-keywords
 '("array" "as" "break" "catch" "continue")
  "PHP keywords.")

This var is used for font-locking like this :

(defvar web-mode-php-font-lock-keywords
 (list
  (cons (concat "\\<\\(" (regexp-opt web-mode-php-keywords) "\\)\\>") 'web-mode-keyword-face)
...

I don't manage to find out a way to let a user add a keyword to the web-mode-php-keywords list in his .emacs

web-mode-php-font-lock-keywords relies on web-mode-php-keywords and trying to alter web-mode-php-keywords in a hook doesn't work because web-mode-php-font-lock-keywords is already built

I think I miss something ... (is this related to eval-after-load ?)

1

There are 1 answers

1
Stefan On BEST ANSWER

I guess you could do (setq web-mode-php-keywords '("array" "as" "break" "catch" "continue" "mykeyword1" "mykeyword2"...)) before loading the web-mode file.