;;; jit-lock.el --- just-in-time fontification
-;; Copyright (C) 1998, 2000, 2001, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004,
+;; 2005 Free Software Foundation, Inc.
;; Author: Gerd Moellmann <gerd@gnu.org>
;; Keywords: faces files
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(defgroup jit-lock nil
"Font Lock support mode to fontify just-in-time."
- :link '(custom-manual "(emacs)Support Modes")
:version "21.1"
:group 'font-lock)
:group 'jit-lock)
-(defcustom jit-lock-stealth-time 3
+(defcustom jit-lock-stealth-time 16
"*Time in seconds to wait before beginning stealth fontification.
Stealth fontification occurs if there is no input within this time.
If nil, stealth fontification is never performed.
:group 'jit-lock)
-(defcustom jit-lock-stealth-nice 0.125
+(defcustom jit-lock-stealth-nice 0.5
"*Time in seconds to pause between chunks of stealth fontification.
Each iteration of stealth fontification is separated by this amount of time,
thus reducing the demand that stealth fontification makes on the system.
(defcustom jit-lock-context-time 0.5
"Idle time after which text is contextually refontified, if applicable."
- :type '(number :tag "seconds"))
-
+ :type '(number :tag "seconds")
+ :group 'jit-lock)
+
(defcustom jit-lock-defer-time nil ;; 0.25
"Idle time after which deferred fontification should take place.
If nil, fontification is not deferred."
"Fontify current buffer starting at position START.
This function is added to `fontification-functions' when `jit-lock-mode'
is active."
- (when jit-lock-mode
+ (when (and jit-lock-mode (not (memory-full-p)))
(if (null jit-lock-defer-time)
;; No deferral.
(jit-lock-fontify-now start (+ start jit-lock-chunk-size))
(unless (or executing-kbd-macro
(window-minibuffer-p (selected-window)))
(let ((buffers (buffer-list))
+ (outer-buffer (current-buffer))
minibuffer-auto-raise
message-log-max)
(with-local-quit
(point (point-min)))
(while (and (setq start
(jit-lock-stealth-chunk-start point))
- (sit-for nice))
+ ;; In case sit-for runs any timers,
+ ;; give them the expected current buffer.
+ (with-current-buffer outer-buffer
+ (sit-for nice)))
;; fontify a block.
(jit-lock-fontify-now start (+ start jit-lock-chunk-size))
;; Wait a little if load is too high.
(when (and jit-lock-stealth-load
(> (car (load-average)) jit-lock-stealth-load))
- (sit-for (or jit-lock-stealth-time 30)))))))))))))
+ ;; In case sit-for runs any timers,
+ ;; give them the expected current buffer.
+ (with-current-buffer outer-buffer
+ (sit-for (or jit-lock-stealth-time 30))))))))))))))
\f
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 jit-lock-mode
+ (when (and jit-lock-mode (not (memory-full-p)))
(save-excursion
(with-buffer-prepared-for-jit-lock
;; It's important that the `fontified' property be set from the