font-lock can be applied in different ways. By default it is applied using jit-lock-mode, which applies it "lazily" (aka "just-in-time"), which has the disadvantage that it is applied at a time where we can't display message (or enter the debugger) because that would make us inf-loop. So there are two ways to work around the problem:
- Use
jit-lock-debug-mode
(recently added to Emacs's development code). - Set
font-lock-support-mode
to nil, then turn font-lock off and then back on.
Both options should change font-lock so that it is applied at a time where debugging can be used.