> ------------ > # -*- mode:my/test -*- > This is test with keyword to be fontified. > > # Local Variables: > # eval: (setq unsafe-variable t) > # End: > ------------- > > Then, consider the following major mode: > > (define-derived-mode my/test-mode text-mode "Test" > "" > (add-hook 'hack-local-variables-hook > (lambda () > (setq-local my/test-mode-keywords '(("keyword" . font-lock-keyword-face))) > (setq font-lock-defaults '(my/test-mode-keywords))) > nil 'local)) > > 1. emacs -Q > 2. Evaluate the major mode definition > 3. Open the file > 4. Answer "y" in the unsafe variable prompt > 5. Observe "keyword" not being fontified. > 6. Expected: "keyword" fontified using font-lock-keyword-face. Hmm... AFAICT the problem here is that the implementation of `global-font-lock-mode` ends up trying to enable `font-lock-mode` in that file's buffer during execution of the `after-major-mode-change-hook` of *another* buffer while querying whether to obey those file-local settings, and then fails to try again when the hook is run in the desired buffer. I suspect the patch below might help (requires recompiling `font-core.el` and re-dumping Emacs), but as the comment in there explains it might not always be sufficient either. Hmm... Stefan