diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2002-10-01 16:54:42 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2002-10-01 16:54:42 +0000 |
commit | c9cf2e67e84e9734dc42e558795b1e4910523908 (patch) | |
tree | 03c3c81750e76c21aedb7cd21080fb2fb33927a8 | |
parent | 22e602074ab50d5b1edf2f194b8cc4d99e362a29 (diff) | |
download | emacs-c9cf2e67e84e9734dc42e558795b1e4910523908.tar.gz |
(jit-lock-fontify-now): Don't widen.
Let the jit-lock-functions do it if they want to.
-rw-r--r-- | lisp/jit-lock.el | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 20214008302..2f832bf3dad 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el @@ -297,45 +297,43 @@ is active." Defaults to the whole buffer. END can be out of bounds." (with-buffer-prepared-for-jit-lock (save-excursion - (save-restriction - (widen) - (unless start (setq start (point-min))) - (setq end (if end (min end (point-max)) (point-max))) - ;; This did bind `font-lock-beginning-of-syntax-function' to - ;; nil at some point, for an unknown reason. Don't do this; it - ;; can make highlighting slow due to expensive calls to - ;; `parse-partial-sexp' in function - ;; `font-lock-fontify-syntactically-region'. Example: paging - ;; from the end of a buffer to its start, can do repeated - ;; `parse-partial-sexp' starting from `point-min', which can - ;; take a long time in a large buffer. - (let (next) - (save-match-data - ;; Fontify chunks beginning at START. The end of a - ;; chunk is either `end', or the start of a region - ;; before `end' that has already been fontified. - (while start - ;; Determine the end of this chunk. - (setq next (or (text-property-any start end 'fontified t) - end)) - - ;; Decide which range of text should be fontified. - ;; The problem is that START and NEXT may be in the - ;; middle of something matched by a font-lock regexp. - ;; Until someone has a better idea, let's start - ;; at the start of the line containing START and - ;; stop at the start of the line following NEXT. - (goto-char next) (setq next (line-beginning-position 2)) - (goto-char start) (setq start (line-beginning-position)) + (unless start (setq start (point-min))) + (setq end (if end (min end (point-max)) (point-max))) + ;; This did bind `font-lock-beginning-of-syntax-function' to + ;; nil at some point, for an unknown reason. Don't do this; it + ;; can make highlighting slow due to expensive calls to + ;; `parse-partial-sexp' in function + ;; `font-lock-fontify-syntactically-region'. Example: paging + ;; from the end of a buffer to its start, can do repeated + ;; `parse-partial-sexp' starting from `point-min', which can + ;; take a long time in a large buffer. + (let (next) + (save-match-data + ;; Fontify chunks beginning at START. The end of a + ;; chunk is either `end', or the start of a region + ;; before `end' that has already been fontified. + (while start + ;; Determine the end of this chunk. + (setq next (or (text-property-any start end 'fontified t) + end)) + + ;; Decide which range of text should be fontified. + ;; The problem is that START and NEXT may be in the + ;; middle of something matched by a font-lock regexp. + ;; Until someone has a better idea, let's start + ;; at the start of the line containing START and + ;; stop at the start of the line following NEXT. + (goto-char next) (setq next (line-beginning-position 2)) + (goto-char start) (setq start (line-beginning-position)) - ;; Fontify the chunk, and mark it as fontified. - ;; We mark it first, to make sure that we don't indefinitely - ;; re-execute this fontification if an error occurs. - (put-text-property start next 'fontified t) - (run-hook-with-args 'jit-lock-functions start next) - - ;; Find the start of the next chunk, if any. - (setq start (text-property-any next end 'fontified nil))))))))) + ;; Fontify the chunk, and mark it as fontified. + ;; We mark it first, to make sure that we don't indefinitely + ;; re-execute this fontification if an error occurs. + (put-text-property start next 'fontified t) + (run-hook-with-args 'jit-lock-functions start next) + + ;; Find the start of the next chunk, if any. + (setq start (text-property-any next end 'fontified nil)))))))) ;;; Stealth fontification. |