> Each time Emacs becomes idle, `jit-lock-stealth-fontify' is called; > with this patch, it requeues itself as a non-idle timer until it > finishes fontifying. What happens if Emacs becomes idle again before > fontification finishes? (This may happen if jit-lock-stealth-time is > very short, or if a timer or process filter makes Emacs idle.) It > seems to me that this will set off another series of non-idle timers, > which is not what we want. > I think that if jit-lock-stealth-fontify is called with no argument, > and fontification is proceeding, it should do nothing. Not really. `buffer-list' may have changed in between and I have to recalculate `jit-lock-stealth-buffers'. I also should care about the liveness of my buffers here. Anyway your reasoning is valid, I could pile up a sequence of timers all working on the same possibly stale version of `jit-lock-stealth-buffers'. Sooner or later they should stop but that's no justification for what I wrote. > One way to do > this is to introduce a new `jit-lock-stealth-fontifying' variable. > (This may not work well if stealth fontification is so slow that the > buffer list changes significantly before fontification finishes, but I > think there's not much we can do about this.) I'll simply use another timer. > Now the nitpicks. First, jit-lock-stealth-buffers should be > defvar'ed. It _was_ in my first patch. Please convince yourself that I'm not completely imbecile. > Second, this part is rather hard to read: > > (let (.... > load-delay) > (when (or (not jit-lock-stealth-load) > (or (<= (car (load-average)) jit-lock-stealth-load) > (not (setq load-delay t)))) > ...)) > I suggest changing it to > > (let (... > (load-delay (and jit-lock-stealth-load > (>= (car (load-average)) jit-lock-stealth-load)))) > (when (not load-delay) > ...)) > I want to call myself with a zero delay when there's nothing to fontify in the car of `jit-lock-stealth-buffers' and there are buffers left. But you're right, obviously. > Finally, is it really necessary to test jit-lock-stealth-time here? > If it's invalid, jit-lock-stealth-fontify wouldn't get called in the > first place. > > (when (and jit-lock-stealth-buffers jit-lock-stealth-time) > (run-at-time > (if load-delay jit-lock-stealth-time (or jit-lock-stealth-nice 0)) > nil 'jit-lock-stealth-fontify t)) > Paranoia. The user could have set this to nil in between two calls. Emacs timers are vindictive. > Other than that, I think this proposal is good. Not much left, I suppose. Please look again at the new patch.