comparison lisp/jit-lock.el @ 60461:f31205c87d5e

(jit-lock-stealth-fontify): When calling sit-for, make sure the current buffer is the expected one.
author Richard M. Stallman <rms@gnu.org>
date Sun, 06 Mar 2005 18:31:36 +0000
parents f379faf2494c
children 86d97731e558 29e773288013
comparison
equal deleted inserted replaced
60460:7da5648c2f7d 60461:f31205c87d5e
413 `jit-lock-stealth-time' seconds." 413 `jit-lock-stealth-time' seconds."
414 ;; I used to check `inhibit-read-only' here, but I can't remember why. -stef 414 ;; I used to check `inhibit-read-only' here, but I can't remember why. -stef
415 (unless (or executing-kbd-macro 415 (unless (or executing-kbd-macro
416 (window-minibuffer-p (selected-window))) 416 (window-minibuffer-p (selected-window)))
417 (let ((buffers (buffer-list)) 417 (let ((buffers (buffer-list))
418 (outer-buffer (current-buffer))
418 minibuffer-auto-raise 419 minibuffer-auto-raise
419 message-log-max) 420 message-log-max)
420 (with-local-quit 421 (with-local-quit
421 (while (and buffers (not (input-pending-p))) 422 (while (and buffers (not (input-pending-p)))
422 (with-current-buffer (pop buffers) 423 (with-current-buffer (pop buffers)
447 (let (start 448 (let (start
448 (nice (or jit-lock-stealth-nice 0)) 449 (nice (or jit-lock-stealth-nice 0))
449 (point (point-min))) 450 (point (point-min)))
450 (while (and (setq start 451 (while (and (setq start
451 (jit-lock-stealth-chunk-start point)) 452 (jit-lock-stealth-chunk-start point))
452 (sit-for nice)) 453 ;; In case sit-for runs any timers,
454 ;; give them the expected current buffer.
455 (with-current-buffer outer-buffer
456 (sit-for nice)))
453 457
454 ;; fontify a block. 458 ;; fontify a block.
455 (jit-lock-fontify-now start (+ start jit-lock-chunk-size)) 459 (jit-lock-fontify-now start (+ start jit-lock-chunk-size))
456 ;; If stealth jit-locking is done backwards, this leads to 460 ;; If stealth jit-locking is done backwards, this leads to
457 ;; excessive O(n^2) refontification. -stef 461 ;; excessive O(n^2) refontification. -stef
459 ;; (setq jit-lock-context-unfontify-pos end)) 463 ;; (setq jit-lock-context-unfontify-pos end))
460 464
461 ;; Wait a little if load is too high. 465 ;; Wait a little if load is too high.
462 (when (and jit-lock-stealth-load 466 (when (and jit-lock-stealth-load
463 (> (car (load-average)) jit-lock-stealth-load)) 467 (> (car (load-average)) jit-lock-stealth-load))
464 (sit-for (or jit-lock-stealth-time 30))))))))))))) 468 ;; In case sit-for runs any timers,
469 ;; give them the expected current buffer.
470 (with-current-buffer outer-buffer
471 (sit-for (or jit-lock-stealth-time 30))))))))))))))
465 472
466 473
467 474
468 ;;; Deferred fontification. 475 ;;; Deferred fontification.
469 476