Subject: 24.3.50; args-out-of-range in jit-lock-fontify-now

From: Aaron Ecay <[email-masked]>
Date: Thu, 24 Jan 2013 14:27:32 -0500

Related to the recent change to raise (as opposed to ignoring) errors
generated in timers, I have started seeing backtraces similar to the
following:

Debugger entered--Lisp error: (args-out-of-range 1 23)
  text-property-any(1 23 fontified t)
  jit-lock-fontify-now(1 501)
  jit-lock-stealth-fontify(t)
  apply(jit-lock-stealth-fontify t)
  byte-code("r\301^H\302H^H\303H\"\210)\301\207" [timer apply 5 6] 4)
  timer-event-handler([t 0 7 37086 nil jit-lock-stealth-fontify (t) idle
  943000])

This shows up (for example) in a message-mode buffer with some of the mail
headers hidden by narrowing.

The issue is that the min value for the region to be fontified is
calculated with the buffer temporarily widened (by the function
‘jit-lock-stealth-chunk-start’), but ‘jit-lock-fontify-now’ does not
widen the buffer.

I think the solution is either:
1) add a (save-restriction (widen) ...) to jit-lock-fontify-now*
2) add (setq start (max start (point-min))) at line 357 of jit-lock.el

I don’t know enough about the fontification code to know which is
correct.  (But note that strategy 2 is used for the ‘end’ argument to
‘jit-lock-fontify-now’, also at line 357).

* If widening should be done in general when fontifying, perhaps the
‘with-buffer-prepared-for-jit-lock’ macro should do it.

Thanks,

-- 
Aaron Ecay