diff options
author | Alan Mackenzie <acm@muc.de> | 2006-03-14 18:23:47 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2006-03-14 18:23:47 +0000 |
commit | ef0083218d1bb912de6e7a156e5b56607ac4997b (patch) | |
tree | a87580096d1e70512b158ff12472e3c30312c874 /lisp/jit-lock.el | |
parent | 8a34117e23756a7e6e5f3f1a00d46774e6f35975 (diff) | |
download | emacs-ef0083218d1bb912de6e7a156e5b56607ac4997b.tar.gz |
* font-core.el: New function/variable
font-lock-extend-region\(-function\)?.
* font-lock.el (font-lock-after-change-function): Call
font-lock-extend-region. Obey font-lock-lines-before.
(font-lock-default-fontify-region): Remove reference to
font-lock-lines-before.
* jit-lock.el (jit-lock-after-change): Call
font-lock-extend-region. Obey font-lock-lines-before.
Diffstat (limited to 'lisp/jit-lock.el')
-rw-r--r-- | lisp/jit-lock.el | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 09870310584..f82ead462f0 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el @@ -557,36 +557,44 @@ This function ensures that lines following the change will be refontified in case the syntax of those lines has changed. Refontification will take place when text is fontified stealthily." (when (and jit-lock-mode (not memory-full)) - (save-excursion - (with-buffer-prepared-for-jit-lock - ;; It's important that the `fontified' property be set from the - ;; beginning of the line, else font-lock will properly change the - ;; text's face, but the display will have been done already and will - ;; be inconsistent with the buffer's content. - (goto-char start) - (setq start (line-beginning-position)) - - ;; If we're in text that matches a multi-line font-lock pattern, - ;; make sure the whole text will be redisplayed. - ;; I'm not sure this is ever necessary and/or sufficient. -stef - (when (get-text-property start 'font-lock-multiline) - (setq start (or (previous-single-property-change - start 'font-lock-multiline) - (point-min)))) - - ;; Make sure we change at least one char (in case of deletions). - (setq end (min (max end (1+ start)) (point-max))) - ;; Request refontification. - (put-text-property start end 'fontified nil)) - ;; Mark the change for deferred contextual refontification. - (when jit-lock-context-unfontify-pos - (setq jit-lock-context-unfontify-pos - ;; Here we use `start' because nothing guarantees that the - ;; text between start and end will be otherwise refontified: - ;; usually it will be refontified by virtue of being - ;; displayed, but if it's outside of any displayed area in the - ;; buffer, only jit-lock-context-* will re-fontify it. - (min jit-lock-context-unfontify-pos start)))))) + (let ((region (font-lock-extend-region start end old-len))) + (save-excursion + (with-buffer-prepared-for-jit-lock + ;; It's important that the `fontified' property be set from the + ;; beginning of the line, else font-lock will properly change the + ;; text's face, but the display will have been done already and will + ;; be inconsistent with the buffer's content. + ;; + ;; FIXME!!! (Alan Mackenzie, 2006-03-14): If start isn't at a BOL, + ;; expanding the region to BOL might mis-fontify, should the BOL not + ;; be at a "safe" position. + (setq start (if region + (car region) + (goto-char start) + (line-beginning-position (- 1 font-lock-lines-before)))) + + ;; If we're in text that matches a multi-line font-lock pattern, + ;; make sure the whole text will be redisplayed. + ;; I'm not sure this is ever necessary and/or sufficient. -stef + (when (get-text-property start 'font-lock-multiline) + (setq start (or (previous-single-property-change + start 'font-lock-multiline) + (point-min)))) + + (if region (setq end (cdr region))) + ;; Make sure we change at least one char (in case of deletions). + (setq end (min (max end (1+ start)) (point-max))) + ;; Request refontification. + (put-text-property start end 'fontified nil)) + ;; Mark the change for deferred contextual refontification. + (when jit-lock-context-unfontify-pos + (setq jit-lock-context-unfontify-pos + ;; Here we use `start' because nothing guarantees that the + ;; text between start and end will be otherwise refontified: + ;; usually it will be refontified by virtue of being + ;; displayed, but if it's outside of any displayed area in the + ;; buffer, only jit-lock-context-* will re-fontify it. + (min jit-lock-context-unfontify-pos start))))))) (provide 'jit-lock) |