How can I debug font lock keywords I write? For example
(progn
(font-lock-add-keywords
nil
'(
;; ("hi1" . 'success)
("hi2" . (intern (concat "warn" "ing")))
))
(font-lock-fontify-buffer))
will produce the following message in Messages buffer:
Error during redisplay: (jit-lock-function 1) signaled (wrong-type-argument stringp 22)
In order to see the call stack upon wrong-type-argument error, I invoke toggle-debug-on-error
and Emacs still doesn't enter debugger upon font lock error.
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:
jit-lock-debug-mode
(recently added to Emacs's development code).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.