aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-10-01 16:54:42 +0000
committerStefan Monnier2002-10-01 16:54:42 +0000
commitc9cf2e67e84e9734dc42e558795b1e4910523908 (patch)
tree03c3c81750e76c21aedb7cd21080fb2fb33927a8
parent22e602074ab50d5b1edf2f194b8cc4d99e362a29 (diff)
downloademacs-c9cf2e67e84e9734dc42e558795b1e4910523908.tar.gz
emacs-c9cf2e67e84e9734dc42e558795b1e4910523908.zip
(jit-lock-fontify-now): Don't widen.
Let the jit-lock-functions do it if they want to.
-rw-r--r--lisp/jit-lock.el74
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."
297Defaults to the whole buffer. END can be out of bounds." 297Defaults to the whole buffer. END can be out of bounds."
298 (with-buffer-prepared-for-jit-lock 298 (with-buffer-prepared-for-jit-lock
299 (save-excursion 299 (save-excursion
300 (save-restriction 300 (unless start (setq start (point-min)))
301 (widen) 301 (setq end (if end (min end (point-max)) (point-max)))
302 (unless start (setq start (point-min))) 302 ;; This did bind `font-lock-beginning-of-syntax-function' to
303 (setq end (if end (min end (point-max)) (point-max))) 303 ;; nil at some point, for an unknown reason. Don't do this; it
304 ;; This did bind `font-lock-beginning-of-syntax-function' to 304 ;; can make highlighting slow due to expensive calls to
305 ;; nil at some point, for an unknown reason. Don't do this; it 305 ;; `parse-partial-sexp' in function
306 ;; can make highlighting slow due to expensive calls to 306 ;; `font-lock-fontify-syntactically-region'. Example: paging
307 ;; `parse-partial-sexp' in function 307 ;; from the end of a buffer to its start, can do repeated
308 ;; `font-lock-fontify-syntactically-region'. Example: paging 308 ;; `parse-partial-sexp' starting from `point-min', which can
309 ;; from the end of a buffer to its start, can do repeated 309 ;; take a long time in a large buffer.
310 ;; `parse-partial-sexp' starting from `point-min', which can 310 (let (next)
311 ;; take a long time in a large buffer. 311 (save-match-data
312 (let (next) 312 ;; Fontify chunks beginning at START. The end of a
313 (save-match-data 313 ;; chunk is either `end', or the start of a region
314 ;; Fontify chunks beginning at START. The end of a 314 ;; before `end' that has already been fontified.
315 ;; chunk is either `end', or the start of a region 315 (while start
316 ;; before `end' that has already been fontified. 316 ;; Determine the end of this chunk.
317 (while start 317 (setq next (or (text-property-any start end 'fontified t)
318 ;; Determine the end of this chunk. 318 end))
319 (setq next (or (text-property-any start end 'fontified t) 319
320 end)) 320 ;; Decide which range of text should be fontified.
321 321 ;; The problem is that START and NEXT may be in the
322 ;; Decide which range of text should be fontified. 322 ;; middle of something matched by a font-lock regexp.
323 ;; The problem is that START and NEXT may be in the 323 ;; Until someone has a better idea, let's start
324 ;; middle of something matched by a font-lock regexp. 324 ;; at the start of the line containing START and
325 ;; Until someone has a better idea, let's start 325 ;; stop at the start of the line following NEXT.
326 ;; at the start of the line containing START and 326 (goto-char next) (setq next (line-beginning-position 2))
327 ;; stop at the start of the line following NEXT. 327 (goto-char start) (setq start (line-beginning-position))
328 (goto-char next) (setq next (line-beginning-position 2))
329 (goto-char start) (setq start (line-beginning-position))
330 328
331 ;; Fontify the chunk, and mark it as fontified. 329 ;; Fontify the chunk, and mark it as fontified.
332 ;; We mark it first, to make sure that we don't indefinitely 330 ;; We mark it first, to make sure that we don't indefinitely
333 ;; re-execute this fontification if an error occurs. 331 ;; re-execute this fontification if an error occurs.
334 (put-text-property start next 'fontified t) 332 (put-text-property start next 'fontified t)
335 (run-hook-with-args 'jit-lock-functions start next) 333 (run-hook-with-args 'jit-lock-functions start next)
336 334
337 ;; Find the start of the next chunk, if any. 335 ;; Find the start of the next chunk, if any.
338 (setq start (text-property-any next end 'fontified nil))))))))) 336 (setq start (text-property-any next end 'fontified nil))))))))
339 337
340 338
341;;; Stealth fontification. 339;;; Stealth fontification.