| 458 | | message-log-max) |
|---|
| 459 | | (with-local-quit |
|---|
| 460 | | (while (and buffers (not (input-pending-p))) |
|---|
| 461 | | (with-current-buffer (pop buffers) |
|---|
| 462 | | (when jit-lock-mode |
|---|
| 463 | | ;; This is funny. Calling sit-for with 3rd arg non-nil |
|---|
| 464 | | ;; so that it doesn't redisplay, internally calls |
|---|
| 465 | | ;; wait_reading_process_input also with a parameter |
|---|
| 466 | | ;; saying "don't redisplay." Since this function here |
|---|
| 467 | | ;; is called periodically, this effectively leads to |
|---|
| 468 | | ;; process output not being redisplayed at all because |
|---|
| 469 | | ;; redisplay_internal is never called. (That didn't |
|---|
| 470 | | ;; work in the old redisplay either.) So, we learn that |
|---|
| 471 | | ;; we mustn't call sit-for that way here. But then, we |
|---|
| 472 | | ;; have to be cautious not to call sit-for in a widened |
|---|
| 473 | | ;; buffer, since this could display hidden parts of that |
|---|
| 474 | | ;; buffer. This explains the seemingly weird use of |
|---|
| 475 | | ;; save-restriction/widen here. |
|---|
| 476 | | |
|---|
| 477 | | (with-temp-message (if jit-lock-stealth-verbose |
|---|
| 478 | | (concat "JIT stealth lock " |
|---|
| 479 | | (buffer-name))) |
|---|
| 480 | | |
|---|
| 481 | | ;; In the following code, the `sit-for' calls cause a |
|---|
| 482 | | ;; redisplay, so it's required that the |
|---|
| 483 | | ;; buffer-modified flag of a buffer that is displayed |
|---|
| 484 | | ;; has the right value---otherwise the mode line of |
|---|
| 485 | | ;; an unmodified buffer would show a `*'. |
|---|
| 486 | | (let (start |
|---|
| 487 | | (nice (or jit-lock-stealth-nice 0)) |
|---|
| 488 | | (point (point-min))) |
|---|
| 489 | | (while (and (setq start |
|---|
| 490 | | (jit-lock-stealth-chunk-start point)) |
|---|
| 491 | | ;; In case sit-for runs any timers, |
|---|
| 492 | | ;; give them the expected current buffer. |
|---|
| 493 | | (with-current-buffer outer-buffer |
|---|
| 494 | | (sit-for nice))) |
|---|
| 495 | | |
|---|
| 496 | | ;; fontify a block. |
|---|
| 497 | | (jit-lock-fontify-now start (+ start jit-lock-chunk-size)) |
|---|
| 498 | | ;; If stealth jit-locking is done backwards, this leads to |
|---|
| 499 | | ;; excessive O(n^2) refontification. -stef |
|---|
| 500 | | ;; (when (>= jit-lock-context-unfontify-pos start) |
|---|
| 501 | | ;; (setq jit-lock-context-unfontify-pos end)) |
|---|
| 502 | | |
|---|
| 503 | | ;; Wait a little if load is too high. |
|---|
| 504 | | (when (and jit-lock-stealth-load |
|---|
| 505 | | (> (car (load-average)) jit-lock-stealth-load)) |
|---|
| 506 | | ;; In case sit-for runs any timers, |
|---|
| 507 | | ;; give them the expected current buffer. |
|---|
| 508 | | (with-current-buffer outer-buffer |
|---|
| 509 | | (sit-for (or jit-lock-stealth-time 30)))))))))))))) |
|---|
| 510 | | |
|---|
| | 476 | message-log-max |
|---|
| | 477 | start) |
|---|
| | 478 | (if (and jit-lock-stealth-load |
|---|
| | 479 | (> (car (load-average)) jit-lock-stealth-load)) |
|---|
| | 480 | ;; Wait a little if load is too high. |
|---|
| | 481 | (setq delay jit-lock-stealth-time) |
|---|
| | 482 | (if (buffer-live-p buffer) |
|---|
| | 483 | (with-current-buffer buffer |
|---|
| | 484 | (if (and jit-lock-mode |
|---|
| | 485 | (setq start (jit-lock-stealth-chunk-start (point)))) |
|---|
| | 486 | ;; Fontify one block of at most `jit-lock-chunk-size' |
|---|
| | 487 | ;; characters. |
|---|
| | 488 | (with-temp-message (if jit-lock-stealth-verbose |
|---|
| | 489 | (concat "JIT stealth lock " |
|---|
| | 490 | (buffer-name))) |
|---|
| | 491 | (jit-lock-fontify-now start |
|---|
| | 492 | (+ start jit-lock-chunk-size)) |
|---|
| | 493 | ;; Run again after `jit-lock-stealth-nice' seconds. |
|---|
| | 494 | (setq delay (or jit-lock-stealth-nice 0))) |
|---|
| | 495 | ;; Nothing to fontify here. Remove this buffer from |
|---|
| | 496 | ;; `jit-lock-stealth-buffers' and run again immediately. |
|---|
| | 497 | (setq jit-lock-stealth-buffers (cdr jit-lock-stealth-buffers)))) |
|---|
| | 498 | ;; Buffer is no longer live. Remove it from |
|---|
| | 499 | ;; `jit-lock-stealth-buffers' and run again immediately. |
|---|
| | 500 | (setq jit-lock-stealth-buffers (cdr jit-lock-stealth-buffers)))) |
|---|
| | 501 | ;; Call us again. |
|---|
| | 502 | (when jit-lock-stealth-buffers |
|---|
| | 503 | (timer-set-idle-time jit-lock-stealth-repeat-timer (current-idle-time)) |
|---|
| | 504 | (timer-inc-time jit-lock-stealth-repeat-timer delay) |
|---|
| | 505 | (timer-activate-when-idle jit-lock-stealth-repeat-timer t))))) |
|---|