My actual scenario involves using latex-mode-hook to load some libraries that require json-mode.

I replicated my issue in a MWE:

I have a LaTeX file:






If I load it like this:

emacs -Q test.tex

I get this "correct" latex-mode fontification:

enter image description here

I have also a config file (I simplified it to obtain the feature):

(add-hook 'latex-mode-hook
          #'(lambda ()
          (require 'json-mode)))

If I load my .tex file like this:

emacs -Q --eval "(load-file \"/tmp/config.el\")" test.tex

I lose latex-mode fontification:

enter image description here

  1. In the last case, to restore correct latex-mode fontification I need to do M-x latex-mode
  2. This problem does not happen with other packages or custom libraries but, in my experience, it happens only for the json-mode package.
  3. If I load json-mode "before" latex-mode I have no problem. E.g. if I modify the config.el file this way:
(require 'json-mode)

and I do:

emacs -Q --eval "(load-file \"/tmp/config.el\")" test.tex

I get the correct latex-mode fontification.

Am I doing something wrong or is it some kind of bug in json-mode or in Emacs?

Important note. This didn't happen with previous versions of Emacs. Before upgrading to version 29.2, I was using version 27 and never encountered this issue prior to the upgrade.

1 Answer 1


It was a bug in json-mode.el:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.