3

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 ?)

fxbois
  • 806
  • 9
  • 21

1 Answers1

2

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

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • I wan't to let users add keywords not set all keyords list. I've done this : `(defconst web-mode-php-constants (eval-when-compile (regexp-opt (append (if (boundp 'web-mode-php-constants) web-mode-php-constants '()) '("TRUE" "FALSE" "NULL" "true" "false" "null")))) "PHP constants.")` .... but perhaps a better solution exists – fxbois May 17 '12 at 09:27