]> code.delx.au - gnu-emacs/blobdiff - lisp/jit-lock.el
Fix previous change.
[gnu-emacs] / lisp / jit-lock.el
index 67b1bfbe022a6fd78981231694266391fbfda32f..d98e879112450c883a9d0aaf2adfe4203c09ebd0 100644 (file)
@@ -19,8 +19,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:
 
@@ -60,7 +60,6 @@ Preserves the `buffer-modified-p' state of the current buffer."
 
 (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)
 
@@ -70,7 +69,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.
@@ -81,7 +80,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.
@@ -138,8 +137,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."
@@ -298,7 +298,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))
@@ -416,6 +416,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
@@ -450,7 +451,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))
@@ -462,7 +466,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
@@ -533,7 +540,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