how to debug font lock keywords error
Asked Answered
D

1

6

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.

Deposit answered 2/9, 2013 at 9:8 Comment(1)
As to why we get an error for that particular example, #18570724Deposit
A
6

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.

Avaunt answered 2/9, 2013 at 14:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.