299 |
"Fontify current buffer starting at position START. |
"Fontify current buffer starting at position START. |
300 |
This function is added to `fontification-functions' when `jit-lock-mode' |
This function is added to `fontification-functions' when `jit-lock-mode' |
301 |
is active." |
is active." |
302 |
(when (and jit-lock-mode (not (memory-full-p))) |
(when (and jit-lock-mode (not memory-full)) |
303 |
(if (null jit-lock-defer-time) |
(if (null jit-lock-defer-time) |
304 |
;; No deferral. |
;; No deferral. |
305 |
(jit-lock-fontify-now start (+ start jit-lock-chunk-size)) |
(jit-lock-fontify-now start (+ start jit-lock-chunk-size)) |
427 |
`jit-lock-stealth-time' seconds." |
`jit-lock-stealth-time' seconds." |
428 |
;; I used to check `inhibit-read-only' here, but I can't remember why. -stef |
;; I used to check `inhibit-read-only' here, but I can't remember why. -stef |
429 |
(unless (or executing-kbd-macro |
(unless (or executing-kbd-macro |
430 |
|
memory-full |
431 |
(window-minibuffer-p (selected-window))) |
(window-minibuffer-p (selected-window))) |
432 |
(let ((buffers (buffer-list)) |
(let ((buffers (buffer-list)) |
433 |
(outer-buffer (current-buffer)) |
(outer-buffer (current-buffer)) |
491 |
|
|
492 |
(defun jit-lock-deferred-fontify () |
(defun jit-lock-deferred-fontify () |
493 |
"Fontify what was deferred." |
"Fontify what was deferred." |
494 |
(when jit-lock-defer-buffers |
(when (and jit-lock-defer-buffers (not memory-full)) |
495 |
;; Mark the deferred regions back to `fontified = nil' |
;; Mark the deferred regions back to `fontified = nil' |
496 |
(dolist (buffer jit-lock-defer-buffers) |
(dolist (buffer jit-lock-defer-buffers) |
497 |
(when (buffer-live-p buffer) |
(when (buffer-live-p buffer) |
518 |
|
|
519 |
(defun jit-lock-context-fontify () |
(defun jit-lock-context-fontify () |
520 |
"Refresh fontification to take new context into account." |
"Refresh fontification to take new context into account." |
521 |
(dolist (buffer (buffer-list)) |
(unless memory-full |
522 |
(with-current-buffer buffer |
(dolist (buffer (buffer-list)) |
523 |
(when jit-lock-context-unfontify-pos |
(with-current-buffer buffer |
524 |
;; (message "Jit-Context %s" (buffer-name)) |
(when jit-lock-context-unfontify-pos |
525 |
(save-restriction |
;; (message "Jit-Context %s" (buffer-name)) |
526 |
(widen) |
(save-restriction |
527 |
(when (and (>= jit-lock-context-unfontify-pos (point-min)) |
(widen) |
528 |
(< jit-lock-context-unfontify-pos (point-max))) |
(when (and (>= jit-lock-context-unfontify-pos (point-min)) |
529 |
;; If we're in text that matches a complex multi-line |
(< jit-lock-context-unfontify-pos (point-max))) |
530 |
;; font-lock pattern, make sure the whole text will be |
;; If we're in text that matches a complex multi-line |
531 |
;; redisplayed eventually. |
;; font-lock pattern, make sure the whole text will be |
532 |
;; Despite its name, we treat jit-lock-defer-multiline here |
;; redisplayed eventually. |
533 |
;; rather than in jit-lock-defer since it has to do with multiple |
;; Despite its name, we treat jit-lock-defer-multiline here |
534 |
;; lines, i.e. with context. |
;; rather than in jit-lock-defer since it has to do with multiple |
535 |
(when (get-text-property jit-lock-context-unfontify-pos |
;; lines, i.e. with context. |
536 |
'jit-lock-defer-multiline) |
(when (get-text-property jit-lock-context-unfontify-pos |
537 |
(setq jit-lock-context-unfontify-pos |
'jit-lock-defer-multiline) |
538 |
(or (previous-single-property-change |
(setq jit-lock-context-unfontify-pos |
539 |
jit-lock-context-unfontify-pos |
(or (previous-single-property-change |
540 |
'jit-lock-defer-multiline) |
jit-lock-context-unfontify-pos |
541 |
(point-min)))) |
'jit-lock-defer-multiline) |
542 |
(with-buffer-prepared-for-jit-lock |
(point-min)))) |
543 |
;; Force contextual refontification. |
(with-buffer-prepared-for-jit-lock |
544 |
(remove-text-properties |
;; Force contextual refontification. |
545 |
jit-lock-context-unfontify-pos (point-max) |
(remove-text-properties |
546 |
'(fontified nil jit-lock-defer-multiline nil))) |
jit-lock-context-unfontify-pos (point-max) |
547 |
(setq jit-lock-context-unfontify-pos (point-max)))))))) |
'(fontified nil jit-lock-defer-multiline nil))) |
548 |
|
(setq jit-lock-context-unfontify-pos (point-max))))))))) |
549 |
|
|
550 |
(defun jit-lock-after-change (start end old-len) |
(defun jit-lock-after-change (start end old-len) |
551 |
"Mark the rest of the buffer as not fontified after a change. |
"Mark the rest of the buffer as not fontified after a change. |
555 |
This function ensures that lines following the change will be refontified |
This function ensures that lines following the change will be refontified |
556 |
in case the syntax of those lines has changed. Refontification |
in case the syntax of those lines has changed. Refontification |
557 |
will take place when text is fontified stealthily." |
will take place when text is fontified stealthily." |
558 |
(when (and jit-lock-mode (not (memory-full-p))) |
(when (and jit-lock-mode (not memory-full)) |
559 |
(save-excursion |
(save-excursion |
560 |
(with-buffer-prepared-for-jit-lock |
(with-buffer-prepared-for-jit-lock |
561 |
;; It's important that the `fontified' property be set from the |
;; It's important that the `fontified' property be set from the |