diff options
| author | Stefan Monnier | 2006-08-01 18:58:18 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-08-01 18:58:18 +0000 |
| commit | 4cffd2213707e403e379ec24934ec37edba3b6d3 (patch) | |
| tree | b55dcbf06decfa2a976c050ee6c5e5ead162c07e | |
| parent | 374f4f51dffcca37d7a048de79290877f4cc074e (diff) | |
| download | emacs-4cffd2213707e403e379ec24934ec37edba3b6d3.tar.gz emacs-4cffd2213707e403e379ec24934ec37edba3b6d3.zip | |
(font-lock-extend-jit-lock-region-after-change): New fun.
(font-lock-turn-on-thing-lock): Use it.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/font-lock.el | 35 |
2 files changed, 37 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0540072e0c7..039c0ad90fc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2006-08-01 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2006-08-01 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * font-lock.el (font-lock-extend-jit-lock-region-after-change): New fun. | ||
| 4 | (font-lock-turn-on-thing-lock): Use it. | ||
| 5 | |||
| 3 | * longlines.el (longlines-show-region): Make it work on read-only | 6 | * longlines.el (longlines-show-region): Make it work on read-only |
| 4 | buffers as well. | 7 | buffers as well. |
| 5 | 8 | ||
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 207d3b88f86..ecf54895c1c 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -893,7 +893,11 @@ The value of this variable is used when Font Lock mode is turned on." | |||
| 893 | (set (make-local-variable 'font-lock-fontified) t) | 893 | (set (make-local-variable 'font-lock-fontified) t) |
| 894 | ;; Use jit-lock. | 894 | ;; Use jit-lock. |
| 895 | (jit-lock-register 'font-lock-fontify-region | 895 | (jit-lock-register 'font-lock-fontify-region |
| 896 | (not font-lock-keywords-only)))))) | 896 | (not font-lock-keywords-only)) |
| 897 | ;; Tell jit-lock how we extend the region to refontify. | ||
| 898 | (add-hook 'jit-lock-after-change-extend-region-functions | ||
| 899 | 'font-lock-extend-jit-lock-region-after-change | ||
| 900 | nil t))))) | ||
| 897 | 901 | ||
| 898 | (defun font-lock-turn-off-thing-lock () | 902 | (defun font-lock-turn-off-thing-lock () |
| 899 | (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) | 903 | (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) |
| @@ -1096,6 +1100,35 @@ what properties to clear before refontifying a region.") | |||
| 1096 | end (progn (goto-char end) (line-beginning-position 2)))) | 1100 | end (progn (goto-char end) (line-beginning-position 2)))) |
| 1097 | (font-lock-fontify-region beg end))))) | 1101 | (font-lock-fontify-region beg end))))) |
| 1098 | 1102 | ||
| 1103 | (defvar jit-lock-start) (defvar jit-lock-end) | ||
| 1104 | (defun font-lock-extend-jit-lock-region-after-change (beg end old-len) | ||
| 1105 | (let ((region (font-lock-extend-region beg end old-len))) | ||
| 1106 | (if region | ||
| 1107 | (setq jit-lock-start (min jit-lock-start (car region)) | ||
| 1108 | jit-lock-end (max jit-lock-end (cdr region))) | ||
| 1109 | (save-excursion | ||
| 1110 | (goto-char beg) | ||
| 1111 | (forward-line 0) | ||
| 1112 | (setq jit-lock-start | ||
| 1113 | (min jit-lock-start | ||
| 1114 | (if (and (not (eobp)) | ||
| 1115 | (get-text-property (point) 'font-lock-multiline)) | ||
| 1116 | (or (previous-single-property-change | ||
| 1117 | (point) 'font-lock-multiline) | ||
| 1118 | (point-min)) | ||
| 1119 | (point)))) | ||
| 1120 | (goto-char end) | ||
| 1121 | (forward-line 1) | ||
| 1122 | (setq jit-lock-end | ||
| 1123 | (max jit-lock-end | ||
| 1124 | (if (and (not (bobp)) | ||
| 1125 | (get-text-property (1- (point)) | ||
| 1126 | 'font-lock-multiline)) | ||
| 1127 | (or (next-single-property-change | ||
| 1128 | (1- (point)) 'font-lock-multiline) | ||
| 1129 | (point-max)) | ||
| 1130 | (point)))))))) | ||
| 1131 | |||
| 1099 | (defun font-lock-fontify-block (&optional arg) | 1132 | (defun font-lock-fontify-block (&optional arg) |
| 1100 | "Fontify some lines the way `font-lock-fontify-buffer' would. | 1133 | "Fontify some lines the way `font-lock-fontify-buffer' would. |
| 1101 | The lines could be a function or paragraph, or a specified number of lines. | 1134 | The lines could be a function or paragraph, or a specified number of lines. |