comparison lisp/jit-lock.el @ 90370:e3bacb89536a

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-46 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 157-163) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 58-61) - Update from CVS
author Miles Bader <miles@gnu.org>
date Sun, 19 Mar 2006 19:43:57 +0000
parents c5406394f567 caf8f09897bc
children e6bf73e43cf4
comparison
equal deleted inserted replaced
90369:88810aee3a45 90370:e3bacb89536a
555 is the pre-change length. 555 is the pre-change length.
556 This function ensures that lines following the change will be refontified 556 This function ensures that lines following the change will be refontified
557 in case the syntax of those lines has changed. Refontification 557 in case the syntax of those lines has changed. Refontification
558 will take place when text is fontified stealthily." 558 will take place when text is fontified stealthily."
559 (when (and jit-lock-mode (not memory-full)) 559 (when (and jit-lock-mode (not memory-full))
560 (save-excursion 560 (let ((region (font-lock-extend-region start end old-len)))
561 (with-buffer-prepared-for-jit-lock 561 (save-excursion
562 ;; It's important that the `fontified' property be set from the 562 (with-buffer-prepared-for-jit-lock
563 ;; beginning of the line, else font-lock will properly change the 563 ;; It's important that the `fontified' property be set from the
564 ;; text's face, but the display will have been done already and will 564 ;; beginning of the line, else font-lock will properly change the
565 ;; be inconsistent with the buffer's content. 565 ;; text's face, but the display will have been done already and will
566 (goto-char start) 566 ;; be inconsistent with the buffer's content.
567 (setq start (line-beginning-position)) 567 ;;
568 568 ;; FIXME!!! (Alan Mackenzie, 2006-03-14): If start isn't at a BOL,
569 ;; If we're in text that matches a multi-line font-lock pattern, 569 ;; expanding the region to BOL might mis-fontify, should the BOL not
570 ;; make sure the whole text will be redisplayed. 570 ;; be at a "safe" position.
571 ;; I'm not sure this is ever necessary and/or sufficient. -stef 571 (setq start (if region
572 (when (get-text-property start 'font-lock-multiline) 572 (car region)
573 (setq start (or (previous-single-property-change 573 (goto-char start)
574 start 'font-lock-multiline) 574 (line-beginning-position)))
575 (point-min)))) 575
576 576 ;; If we're in text that matches a multi-line font-lock pattern,
577 ;; Make sure we change at least one char (in case of deletions). 577 ;; make sure the whole text will be redisplayed.
578 (setq end (min (max end (1+ start)) (point-max))) 578 ;; I'm not sure this is ever necessary and/or sufficient. -stef
579 ;; Request refontification. 579 (when (get-text-property start 'font-lock-multiline)
580 (put-text-property start end 'fontified nil)) 580 (setq start (or (previous-single-property-change
581 ;; Mark the change for deferred contextual refontification. 581 start 'font-lock-multiline)
582 (when jit-lock-context-unfontify-pos 582 (point-min))))
583 (setq jit-lock-context-unfontify-pos 583
584 ;; Here we use `start' because nothing guarantees that the 584 (if region (setq end (cdr region)))
585 ;; text between start and end will be otherwise refontified: 585 ;; Make sure we change at least one char (in case of deletions).
586 ;; usually it will be refontified by virtue of being 586 (setq end (min (max end (1+ start)) (point-max)))
587 ;; displayed, but if it's outside of any displayed area in the 587 ;; Request refontification.
588 ;; buffer, only jit-lock-context-* will re-fontify it. 588 (put-text-property start end 'fontified nil))
589 (min jit-lock-context-unfontify-pos start)))))) 589 ;; Mark the change for deferred contextual refontification.
590 (when jit-lock-context-unfontify-pos
591 (setq jit-lock-context-unfontify-pos
592 ;; Here we use `start' because nothing guarantees that the
593 ;; text between start and end will be otherwise refontified:
594 ;; usually it will be refontified by virtue of being
595 ;; displayed, but if it's outside of any displayed area in the
596 ;; buffer, only jit-lock-context-* will re-fontify it.
597 (min jit-lock-context-unfontify-pos start)))))))
590 598
591 (provide 'jit-lock) 599 (provide 'jit-lock)
592 600
593 ;; arch-tag: 56b5de6e-f581-453b-bb97-49c39372ff9e 601 ;; arch-tag: 56b5de6e-f581-453b-bb97-49c39372ff9e
594 ;;; jit-lock.el ends here 602 ;;; jit-lock.el ends here