diff options
| author | Gerd Moellmann | 2000-01-31 19:47:38 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-01-31 19:47:38 +0000 |
| commit | 8c887c51c1c283f6eb978a080141f2509325a4a2 (patch) | |
| tree | 1311b87e946039a954542e15df435fc08e27da6b | |
| parent | bbed5c3f02ffa1d1d532490997e1e66f0e8d1615 (diff) | |
| download | emacs-8c887c51c1c283f6eb978a080141f2509325a4a2.tar.gz emacs-8c887c51c1c283f6eb978a080141f2509325a4a2.zip | |
(jit-lock-function): Widen before calculating end
position.
(jit-lock-stealth-chunk-start): Rewritten.
| -rw-r--r-- | lisp/jit-lock.el | 106 |
1 files changed, 55 insertions, 51 deletions
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 345e46e5295..3798566845d 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el | |||
| @@ -242,16 +242,16 @@ This function is added to `fontification-functions' when `jit-lock-mode' | |||
| 242 | is active." | 242 | is active." |
| 243 | (when jit-lock-mode | 243 | (when jit-lock-mode |
| 244 | (with-buffer-prepared-for-font-lock | 244 | (with-buffer-prepared-for-font-lock |
| 245 | (let ((end (min (point-max) (+ start jit-lock-chunk-size))) | 245 | (save-excursion |
| 246 | (parse-sexp-lookup-properties font-lock-syntactic-keywords) | 246 | (save-restriction |
| 247 | (old-syntax-table (syntax-table)) | 247 | (widen) |
| 248 | (font-lock-beginning-of-syntax-function nil) | 248 | (let ((end (min (point-max) (+ start jit-lock-chunk-size))) |
| 249 | next font-lock-start font-lock-end) | 249 | (parse-sexp-lookup-properties font-lock-syntactic-keywords) |
| 250 | (when font-lock-syntax-table | 250 | (font-lock-beginning-of-syntax-function nil) |
| 251 | (set-syntax-table font-lock-syntax-table)) | 251 | (old-syntax-table (syntax-table)) |
| 252 | (save-excursion | 252 | next font-lock-start font-lock-end) |
| 253 | (save-restriction | 253 | (when font-lock-syntax-table |
| 254 | (widen) | 254 | (set-syntax-table font-lock-syntax-table)) |
| 255 | (save-match-data | 255 | (save-match-data |
| 256 | (condition-case error | 256 | (condition-case error |
| 257 | ;; Fontify chunks beginning at START. The end of a | 257 | ;; Fontify chunks beginning at START. The end of a |
| @@ -281,10 +281,10 @@ is active." | |||
| 281 | (setq start (text-property-any next end 'fontified nil))) | 281 | (setq start (text-property-any next end 'fontified nil))) |
| 282 | 282 | ||
| 283 | ((error quit) | 283 | ((error quit) |
| 284 | (message "Fontifying region...%s" error)))))) | 284 | (message "Fontifying region...%s" error)))) |
| 285 | 285 | ||
| 286 | ;; Restore previous buffer settings. | 286 | ;; Restore previous buffer settings. |
| 287 | (set-syntax-table old-syntax-table))))) | 287 | (set-syntax-table old-syntax-table))))))) |
| 288 | 288 | ||
| 289 | 289 | ||
| 290 | (defun jit-lock-after-fontify-buffer () | 290 | (defun jit-lock-after-fontify-buffer () |
| @@ -307,39 +307,44 @@ Called from `font-lock-after-fontify-buffer." | |||
| 307 | (defsubst jit-lock-stealth-chunk-start (around) | 307 | (defsubst jit-lock-stealth-chunk-start (around) |
| 308 | "Return the start of the next chunk to fontify around position AROUND.. | 308 | "Return the start of the next chunk to fontify around position AROUND.. |
| 309 | Value is nil if there is nothing more to fontify." | 309 | Value is nil if there is nothing more to fontify." |
| 310 | (save-restriction | 310 | (if (zerop (buffer-size)) |
| 311 | (widen) | 311 | nil |
| 312 | (let ((prev (previous-single-property-change around 'fontified)) | 312 | (save-restriction |
| 313 | (next (text-property-any around (point-max) 'fontified nil)) | 313 | (widen) |
| 314 | (prop (get-text-property around 'fontified))) | 314 | (let* ((next (text-property-any around (point-max) 'fontified nil)) |
| 315 | (cond ((and (null prop) | 315 | (prev (previous-single-property-change around 'fontified)) |
| 316 | (< around (point-max))) | 316 | (prop (get-text-property (max (point-min) (1- around)) |
| 317 | ;; Text at position AROUND is not fontified. The value of | 317 | 'fontified)) |
| 318 | ;; prev, if non-nil, is the start of the region of | 318 | (start (cond |
| 319 | ;; unfontified text. As a special case, prop will always | 319 | ((null prev) |
| 320 | ;; be nil at point-max. So don't handle that case here. | 320 | ;; There is no property change between AROUND |
| 321 | (max (or prev (point-min)) | 321 | ;; and the start of the buffer. If PROP is |
| 322 | (- around jit-lock-chunk-size))) | 322 | ;; non-nil, everything in front of AROUND is |
| 323 | 323 | ;; fontified, otherwise nothing is fontified. | |
| 324 | ((null prev) | 324 | (if prop |
| 325 | ;; Text at AROUND is fontified, and everything up to | 325 | nil |
| 326 | ;; point-min is. Return the value of next. If that is | 326 | (max (point-min) |
| 327 | ;; nil, there is nothing left to fontify. | 327 | (- around (/ jit-lock-chunk-size 2))))) |
| 328 | next) | 328 | (prop |
| 329 | 329 | ;; PREV is the start of a region of fontified | |
| 330 | ((or (null next) | 330 | ;; text containing AROUND. Start fontfifying a |
| 331 | (< (- around prev) (- next around))) | 331 | ;; chunk size before the end of the unfontified |
| 332 | ;; We either have no unfontified text following AROUND, or | 332 | ;; region in front of that. |
| 333 | ;; the unfontified text in front of AROUND is nearer. The | 333 | (max (or (previous-single-property-change prev 'fontified) |
| 334 | ;; value of prev is the end of the region of unfontified | 334 | (point-min)) |
| 335 | ;; text in front of AROUND. | 335 | (- prev jit-lock-chunk-size))) |
| 336 | (let ((start (previous-single-property-change prev 'fontified))) | 336 | (t |
| 337 | (max (or start (point-min)) | 337 | ;; PREV is the start of a region of unfontified |
| 338 | (- prev jit-lock-chunk-size)))) | 338 | ;; text containing AROUND. Start at PREV or |
| 339 | 339 | ;; chunk size in front of AROUND, whichever is | |
| 340 | (t | 340 | ;; nearer. |
| 341 | next))))) | 341 | (max prev (- around jit-lock-chunk-size))))) |
| 342 | 342 | (result (cond ((null start) next) | |
| 343 | ((null next) start) | ||
| 344 | ((< (- around start) (- next around)) start) | ||
| 345 | (t next)))) | ||
| 346 | result)))) | ||
| 347 | |||
| 343 | 348 | ||
| 344 | (defun jit-lock-stealth-fontify () | 349 | (defun jit-lock-stealth-fontify () |
| 345 | "Fontify buffers stealthily. | 350 | "Fontify buffers stealthily. |
| @@ -350,10 +355,10 @@ This functions is called after Emacs has been idle for | |||
| 350 | (let ((buffers (buffer-list)) | 355 | (let ((buffers (buffer-list)) |
| 351 | minibuffer-auto-raise | 356 | minibuffer-auto-raise |
| 352 | message-log-max) | 357 | message-log-max) |
| 353 | (while (and buffers | 358 | (while (and buffers (not (input-pending-p))) |
| 354 | (not (input-pending-p))) | ||
| 355 | (let ((buffer (car buffers))) | 359 | (let ((buffer (car buffers))) |
| 356 | (setq buffers (cdr buffers)) | 360 | (setq buffers (cdr buffers)) |
| 361 | |||
| 357 | (with-current-buffer buffer | 362 | (with-current-buffer buffer |
| 358 | (when jit-lock-mode | 363 | (when jit-lock-mode |
| 359 | ;; This is funny. Calling sit-for with 3rd arg non-nil | 364 | ;; This is funny. Calling sit-for with 3rd arg non-nil |
| @@ -373,7 +378,7 @@ This functions is called after Emacs has been idle for | |||
| 373 | (with-temp-message (if jit-lock-stealth-verbose | 378 | (with-temp-message (if jit-lock-stealth-verbose |
| 374 | (concat "JIT stealth lock " | 379 | (concat "JIT stealth lock " |
| 375 | (buffer-name))) | 380 | (buffer-name))) |
| 376 | 381 | ||
| 377 | ;; Perform deferred unfontification, if any. | 382 | ;; Perform deferred unfontification, if any. |
| 378 | (when jit-lock-first-unfontify-pos | 383 | (when jit-lock-first-unfontify-pos |
| 379 | (save-restriction | 384 | (save-restriction |
| @@ -388,8 +393,7 @@ This functions is called after Emacs has been idle for | |||
| 388 | (let (start | 393 | (let (start |
| 389 | (nice (or jit-lock-stealth-nice 0)) | 394 | (nice (or jit-lock-stealth-nice 0)) |
| 390 | (point (point))) | 395 | (point (point))) |
| 391 | (while (and (setq start | 396 | (while (and (setq start (jit-lock-stealth-chunk-start point)) |
| 392 | (jit-lock-stealth-chunk-start point)) | ||
| 393 | (sit-for nice)) | 397 | (sit-for nice)) |
| 394 | 398 | ||
| 395 | ;; Wait a little if load is too high. | 399 | ;; Wait a little if load is too high. |