]> code.delx.au - gnu-emacs/blobdiff - lisp/jit-lock.el
*** empty log message ***
[gnu-emacs] / lisp / jit-lock.el
index 43c8457c80b9fe887b0ef7b90e4607850175ddcf..2f8fcba91d1f2b689ae56ae294fa0a3400c36682 100644 (file)
@@ -1,6 +1,7 @@
 ;;; 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
@@ -19,8 +20,8 @@
 
 ;; 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:
 
@@ -69,7 +70,7 @@ Preserves the `buffer-modified-p' state of the current buffer."
   :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.
@@ -80,7 +81,7 @@ The value of this variable is used when JIT Lock mode is turned on."
   :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.
@@ -137,8 +138,9 @@ The value of this variable is used when JIT Lock mode is turned on."
 
 (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."
@@ -297,7 +299,7 @@ Only applies to the current buffer."
   "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))
@@ -415,6 +417,7 @@ This functions is called after Emacs has been idle for
   (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
@@ -449,7 +452,10 @@ This functions is called after Emacs has been idle for
                      (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))
@@ -461,7 +467,10 @@ This functions is called after Emacs has been idle for
                    ;; 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
@@ -532,7 +541,7 @@ is the pre-change length.
 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