unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13542: 24.3.50; args-out-of-range in jit-lock-fontify-now
@ 2013-01-24 19:27 Aaron Ecay
  2013-01-30 17:06 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Aaron Ecay @ 2013-01-24 19:27 UTC (permalink / raw)
  To: 13542


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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#13542: 24.3.50; args-out-of-range in jit-lock-fontify-now
  2013-01-24 19:27 bug#13542: 24.3.50; args-out-of-range in jit-lock-fontify-now Aaron Ecay
@ 2013-01-30 17:06 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2013-01-30 17:06 UTC (permalink / raw)
  To: Aaron Ecay; +Cc: 13542

> 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.

That's a left over from the 2002-10-01 change that decided that jit-lock
should not widen.  I've installed the patch below which should fix
the problem.


        Stefan


=== modified file 'lisp/jit-lock.el'
--- lisp/jit-lock.el	2013-01-13 01:23:48 +0000
+++ lisp/jit-lock.el	2013-01-30 16:59:53 +0000
@@ -439,8 +435,6 @@
 Value is nil if there is nothing more to fontify."
   (if (zerop (buffer-size))
       nil
-    (save-restriction
-      (widen)
       (let* ((next (text-property-not-all around (point-max) 'fontified t))
 	     (prev (previous-single-property-change around 'fontified))
 	     (prop (get-text-property (max (point-min) (1- around))
@@ -473,7 +467,7 @@
 			   ((null next) start)
 			   ((< (- around start) (- next around)) start)
 			   (t next))))
-	result))))
+      result)))
 
 (defun jit-lock-stealth-fontify (&optional repeat)
   "Fontify buffers stealthily.
@@ -564,6 +558,8 @@
 	(when jit-lock-context-unfontify-pos
 	  ;; (message "Jit-Context %s" (buffer-name))
 	  (save-restriction
+            ;; Don't be blindsided by narrowing that starts in the middle
+            ;; of a jit-lock-defer-multiline.
 	    (widen)
 	    (when (and (>= jit-lock-context-unfontify-pos (point-min))
 		       (< jit-lock-context-unfontify-pos (point-max)))






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-30 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-24 19:27 bug#13542: 24.3.50; args-out-of-range in jit-lock-fontify-now Aaron Ecay
2013-01-30 17:06 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).