[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fontification loop
From: |
Stefan Monnier |
Subject: |
Re: fontification loop |
Date: |
Tue, 26 Sep 2006 11:35:14 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
>>> I just caught Emacs hogging the CPU with endless
>>> redisplay/fontification. The following code triggers it for me:
>>
>>> --8<---------------cut here---------------start------------->8---
>>> (progn
>>> (switch-to-buffer "*fontification loop*")
>>> (emacs-lisp-mode)
>>> (while (< (point) (floor (* (sqrt 2) jit-lock-chunk-size)))
>>> (insert "\nfoo\nbar\nbaz"))
>>> (put-text-property (- (point-max) 5) (point-max) 'invisible t))
>>> --8<---------------cut here---------------end--------------->8---
>>
>>> If emacs crashed, and you have the emacs process in the gdb debugger,
>>> please include the output from the following gdb commands:
>>> `bt full' and `xbacktrace'.
>>> If you would like to further debug the crash, please read the file
>>> /home/andreas/ext/emacs/etc/DEBUG for instructions.
>>
>> I can't reproduce it here. Does the patch below help?
> I've patched and compiled jit-lock.el and dumped a new emacs.
> Curiously, I can no longer trigger the CPU hogging with the code
> /above/, /but/ it occurs again as soon as I use trace-function like
> this:
The patch was bogus, and I think it doesn't fix the problem, because the
problem is linked to the fact that jit-lock-fontify-now may be called *at
point-max* and the code doesn't expect it (so it ends up repeatedly
fontifying the region between point-max and point-max :-( ).
I believe the patch below (more specifically the first part) fixes it.
Stefan
--- jit-lock.el 25 Sep 2006 14:16:21 -0400 1.56
+++ jit-lock.el 26 Sep 2006 11:19:55 -0400
@@ -349,7 +349,7 @@
;; 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
+ (while (and start (< start end))
;; Determine the end of this chunk.
(setq next (or (text-property-any start end 'fontified t)
end))
@@ -405,9 +405,11 @@
(defun jit-lock-fontify-again (buf start end)
"Fontify in buffer BUF from START to END."
+ ;; Don't bother refontifying text that's not even displayed.
+ (when (setq start (text-property-not-all start end 'fontified nil buf))
(with-current-buffer buf
(with-buffer-prepared-for-jit-lock
- (put-text-property start end 'fontified t))))
+ (put-text-property start end 'fontified nil)))))
- Re: fontification loop, (continued)
- Re: fontification loop, Andreas Seltenreich, 2006/09/24
- Re: fontification loop, Andreas Seltenreich, 2006/09/24
- Re: fontification loop, Richard Stallman, 2006/09/24
- Re: fontification loop, Andreas Seltenreich, 2006/09/25
- Re: fontification loop, martin rudalics, 2006/09/25
- Re: fontification loop, Andreas Seltenreich, 2006/09/25
- Re: fontification loop, T. V. Raman, 2006/09/27
- Re: fontification loop, Stefan Monnier, 2006/09/25
Re: fontification loop, Stefan Monnier, 2006/09/25