1

I'm getting the following error when starting emacs: (as shown from the messages buffer):

c-font-lock-fontify-region: Symbol's function definition is void: nil

How do I track down what exactly is causing the error in this function? debug-on-error is true, but it still doesn't give any more information here.

Drew
  • 29,895
  • 7
  • 74
  • 104
Nathaniel Flath
  • 15,477
  • 19
  • 69
  • 94
  • You and another gentleman -- that's two reports of a similar issue this week. http://stackoverflow.com/q/24357632/2112489 – lawlist Jun 26 '14 at 17:20

2 Answers2

6

The symbol is nil. It does not name a function.

Generally speaking, to debug the error, you need to set debug-on-error to t and look at the *Backtrace* buffer. If no *Backtrace* buffer appears (which is the case here), this means that the caller of the function which signals the error catches the error. You would need to chase the code looking for condition-case and disable it. Good luck with that :-(

Looking at the c-font-lock-fontify-region definition in progmodes/cc-mode.el, I see there

(funcall (default-value 'font-lock-fontify-region-function)
         new-beg new-end verbose)

which can easily cause the error if (default-value 'font-lock-fontify-region-function) is nil.

sds
  • 58,617
  • 29
  • 161
  • 278
  • OK, looking at the function it claims about (c-font-lock-fontify-region), there are no uses of nil. So the question remains: How do I find out which variable/function call is actually nil? – Nathaniel Flath Jun 26 '14 at 18:16
  • 1
    See edit - you need to look at the `*Backtrace*` buffer. – sds Jun 26 '14 at 18:24
  • No *Backtrace* buffer appears, even with debug-on-error equal to t, but that did give enough information to determine that was the problem. – Nathaniel Flath Jun 26 '14 at 19:03
  • 2
    Note that Emacs 24.3 introduced the exceedingly useful (in such situations) `debug-on-message` variable. – phils Jun 26 '14 at 23:38
2

In order to get a backtrace even if the error is caught by a condition-case you can try to (setq debug-on-signal t). This will trigger in many cases which aren't bugs, so it's something to use only occasionally because it can really get in the way, but it might be helpful in this particular case.

Stefan
  • 27,908
  • 4
  • 53
  • 82