About 15-20 minutes into using emacs my syntax highlighting stops dynamically updating. Instead any new text just uses the color of the text right before it.

Any ideas on how to debug this issue or any work arounds? Running M-x global-font-lock-mode (x2) properly refreshes it, but it doesn't re-enable the dynamic syntax highlighting.

The only way to solve the issue I've found is to kill my emacs server and start a new server, but the issue eventually crops up again.

Here are some screenshots of Python code which shows the behavior.

Here it is properly highlighted:

enter image description here

This is what new code looks like after it stops working:

enter image description here

And here's how it looks after running M-x font-lock-mode (x2):

enter image description here


This is normally a sign that some error occurred during font-locking. I suggest you look at the *Messages* buffer soon after the highlighting stops updating dynamically (it should contain some error message about it).

You can try and get more info about the error with:

M-x font-lock-debug-mode RET
M-x toggle-debug-on-error RET

Or with

M-x toggle-debug-on-error RET
M-: (setq font-lock-support-mode nil) RET
M-x font-lock-mode RET
M-x font-lock-mode RET

[ I.e. re-start font-lock so it pays attention to the new value of font-lock-support-mode. ]

After that, try and reproduce the problem which should then give you a backtrace.

  • Another alternative is to use package github.com/Lindydancer/font-lock-studio -- it's a debugger for font-lock keywords. If you step or run the keywords inside font-lock-studio (and debug-on-error or non-nil), the elisp debugger will start if it encounters a problem with a font-lock keyword. – Lindydancer Jul 20 '18 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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