Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to debug font lock keywords error

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.

like image 556
Jisang Yoo Avatar asked Sep 02 '13 09:09

Jisang Yoo


1 Answers

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.

like image 159
Stefan Avatar answered Nov 16 '22 07:11

Stefan