bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58888: 28.1.90; font-lock-defaults not respected when hack-local-var


From: Ihor Radchenko
Subject: bug#58888: 28.1.90; font-lock-defaults not respected when hack-local-variables unsafe variable dialogue is displayed before setting the defaults
Date: Sun, 30 Oct 2022 06:58:11 +0000

Following up the discussion in bug#57003.

Consider the following file:

------------
# -*- 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.

I can also reproduce using
(define-derived-mode my/test-mode text-mode "Test"
""
(hack-local-variables)
(setq-local my/test-mode-keywords '(("keyword" . font-lock-keyword-face)))
(setq font-lock-defaults '(my/test-mode-keywords)))

The fontification works as expected with
(define-derived-mode my/test-mode text-mode "Test"
""
(setq-local my/test-mode-keywords '(("keyword" . font-lock-keyword-face)))
(setq font-lock-defaults '(my/test-mode-keywords)))

Also reproduced on Emacs master.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]