all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#58888: 28.1.90; font-lock-defaults not respected when hack-local-variables unsafe variable dialogue is displayed before setting the defaults
@ 2022-10-30  6:58 Ihor Radchenko
  2022-10-31  2:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 14+ messages in thread
From: Ihor Radchenko @ 2022-10-30  6:58 UTC (permalink / raw)
  To: 58888

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>





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-04-13 14:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-30  6:58 bug#58888: 28.1.90; font-lock-defaults not respected when hack-local-variables unsafe variable dialogue is displayed before setting the defaults Ihor Radchenko
2022-10-31  2:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-31  7:11   ` Ihor Radchenko
2024-04-08 12:48     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-08 13:15       ` Eli Zaretskii
2024-04-08 13:42         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-08 19:25       ` Ihor Radchenko
2024-04-10 20:34         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-11  6:20           ` Eli Zaretskii
2024-04-11 13:27             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-11 14:12               ` Eli Zaretskii
2024-04-13 14:32                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-11 13:53         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-11 14:13           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.