I'm using emacs for perl scripting and for some unknown reason the syntax highlighting is inactivated when opening new or existing scripts.

I'm wondering if I press a key unknowingly that disactivates it.

Currently my only option is to close emacs and start a new session.

Is there a way to reactivate it?

Not sure which mode is providing the highlighting.


  • Use C-h v major-mode to find out what major mode handles your perl sources.
    – choroba
    Commented Jun 17, 2015 at 8:11
  • @choroba thanks. This works in a non perl buffer. In a perl buffer however it seems to provide help for the syntax at the cursor position. But found it through describe-variable and results in cperl-mode
    – yahan
    Commented Jun 17, 2015 at 8:49

1 Answer 1


You can always turn syntax highlighting back on using M-x font-lock-mode. Using the same command a second time will turn it back off. If you've got it bound to a key that you've inadvertently pressed, use Ctrl+h w font-lock-mode to find which key it's bound to.

If you want to set font-lock-mode permanently for cperl, you can do so by setting either cperl-font-lock or cperl-hairy to t. The former sets only syntax highlighting; the latter also sets some other values - check the info for the variable for more information.

  • thanks! turning this mode off and on works. I don't have a binding for font-lock-mode though, so probably something else is happening. But at least I should be able to enable it again.
    – yahan
    Commented Jun 17, 2015 at 10:54
  • I've occasionally had syntax highlighting fail when I've been working with very large scripts. In most cases turning it off and on again has worked. Maybe it's the same issue.
    – Jenny D
    Commented Jun 17, 2015 at 12:09
  • ai, it happened again and unfortunately toggling M-x font-lock-mode did not work...
    – yahan
    Commented Jun 17, 2015 at 14:20
  • Turn debug-on-error on and try it again. The issue here isn't that font-lock-mode isn't on - it's that it fails with this particular file. Debugging will help you figure out why.
    – Jenny D
    Commented Jun 17, 2015 at 18:05
  • Second though: What happens if you run M-x font-lock-fontify-buffer? Preferably with debug-on-error on.
    – Jenny D
    Commented Jun 18, 2015 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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