XEmacs 21.4.5 "Civil Service".
[chise/xemacs-chise.git-] / lisp / font-lock.el
index 71c7a33..d927539 100644 (file)
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1992-1995, 1997 Free Software Foundation, Inc.
 ;; Copyright (C) 1995 Amdahl Corporation.
-;; Copyright (C) 1996, 2000 Ben Wing.
+;; Copyright (C) 1996, 2000, 2001 Ben Wing.
 
 ;; Author: Jamie Zawinski <jwz@jwz.org>, for the LISPM Preservation Society.
 ;; Minimally merged with FSF 19.34 by Barry Warsaw <bwarsaw@python.org>
@@ -904,15 +904,12 @@ See the variable `font-lock-keywords' for customization."
                          font-lock-maximum-size
                        (cdr (or (assq major-mode font-lock-maximum-size)
                                 (assq t font-lock-maximum-size))))))
-    ;; Font-lock mode will refuse to turn itself on if in batch mode, or if
-    ;; the current buffer is "invisible".  The latter is because packages
-    ;; sometimes put their temporary buffers into some particular major mode
-    ;; to get syntax tables and variables and whatnot, but we don't want the
-    ;; fact that the user has font-lock-mode on a mode hook to slow these
-    ;; things down.
-    (if (or noninteractive (eq (aref (buffer-name) 0) ?\ ))
-       (setq on-p nil))
-    (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp...
+    ;; Font-lock mode will refuse to turn itself on if in batch mode
+    ;; to avoid potential (probably not actual, though) slowdown.  We
+    ;; used to try to "be nice" by avoiding doing this in temporary
+    ;; buffers.  But with the deferral code we don't need this, and it
+    ;; definitely screws some things up.
+    (if (noninteractive)
        (setq on-p nil))
     (cond (on-p
           (make-local-hook 'after-change-functions)
@@ -1206,10 +1203,15 @@ buffer modifications are performed or a buffer is reverted.")
 (defun font-lock-after-change-function (beg end old-len)
   (when font-lock-mode
     ;; treat deletions as if the following character (or previous, if
-    ;; there is no following) were inserted.  this is a bit of a hack
+    ;; there is no following) were inserted. (also use the previous
+    ;; character at end of line.  this avoids a problem when you
+    ;; insert a comment on the line before a line of code: if we use
+    ;; the following char, then when you hit backspace, the following
+    ;; line of code turns the comment color.) this is a bit of a hack
     ;; but allows us to use text properties for everything.
     (if (= beg end)
-       (cond ((/= end (point-max)) (setq end (1+ end)))
+       (cond ((not (save-excursion (goto-char end) (eolp)))
+              (setq end (1+ end)))
              ((/= beg (point-min)) (setq beg (1- beg)))
              (t nil)))
     (put-text-property beg end 'font-lock-pending t)