-(defun font-lock-mode-internal (arg)
- ;; Turn on Font Lock mode.
- (when arg
- (add-hook 'after-change-functions 'font-lock-after-change-function t t)
- (font-lock-set-defaults)
- (font-lock-turn-on-thing-lock)
- ;; Fontify the buffer if we have to.
+(defun font-lock-specified-p (mode)
+ "Return non-nil if the current buffer is ready for fontification.
+The MODE argument, if non-nil, means Font Lock mode is about to
+be enabled."
+ (or font-lock-defaults
+ (and (boundp 'font-lock-keywords)
+ font-lock-keywords)
+ (and mode
+ (boundp 'font-lock-set-defaults)
+ font-lock-set-defaults
+ font-lock-major-mode
+ (not (eq font-lock-major-mode major-mode)))))
+
+(defun font-lock-initial-fontify ()
+ ;; The first fontification after turning the mode on. This must
+ ;; only be called after the mode hooks have been run.
+ (when (and font-lock-mode
+ (font-lock-specified-p t))