Use find-file-hook instead of find-file-hooks.
[bpt/emacs.git] / lisp / jit-lock.el
index 4cbc7da..4486d87 100644 (file)
@@ -1,7 +1,7 @@
 ;;; jit-lock.el --- just-in-time fontification
 
 ;; Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Gerd Moellmann <gerd@gnu.org>
 ;; Keywords: faces files
@@ -10,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -74,14 +74,14 @@ This variable controls both display-time and stealth fontification."
   :group 'jit-lock)
 
 
-(defcustom jit-lock-stealth-time 16
+(defcustom jit-lock-stealth-time nil
   "*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.
 
 The value of this variable is used when JIT Lock mode is turned on."
   :type '(choice (const :tag "never" nil)
-                (number :tag "seconds"))
+                (number :tag "seconds" :value 16))
   :group 'jit-lock)
 
 
@@ -349,7 +349,7 @@ Defaults to the whole buffer.  END can be out of bounds."
         ;; 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))
@@ -397,16 +397,18 @@ Defaults to the whole buffer.  END can be out of bounds."
            ;; eagerly extend the refontified region with
            ;; jit-lock-after-change-extend-region-functions.
            (when (< start orig-start)
-            (run-with-timer 0 nil 'jit-lock-fontify-again
+            (run-with-timer 0 nil 'jit-lock-force-redisplay
                             (current-buffer) start orig-start))
 
           ;; Find the start of the next chunk, if any.
           (setq start (text-property-any next end 'fontified nil))))))))
 
-(defun jit-lock-fontify-again (buf start end)
-  "Fontify in buffer BUF from START to END."
+(defun jit-lock-force-redisplay (buf start end)
+  "Force the display engine to re-render buffer BUF from START to END."
   (with-current-buffer buf
     (with-buffer-prepared-for-jit-lock
+     ;; Don't cause refontification (it's already been done), but just do
+     ;; some random buffer change, so as to force redisplay.
      (put-text-property start end 'fontified t))))