]> code.delx.au - gnu-emacs/blobdiff - lisp/font-lock.el
*** empty log message ***
[gnu-emacs] / lisp / font-lock.el
index 83b7516604d7888d263570c67dfa294a560d0008..ceadcf19728f1491e25f49422a96d89f4ec5cb00 100644 (file)
@@ -1,7 +1,7 @@
 ;;; font-lock.el --- Electric font lock mode
 
-;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001, 02, 2003, 2004
-;;  Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+;;   2000, 2001, 2002, 2003, 2004 2005  Free Software Foundation, Inc.
 
 ;; Author: jwz, then rms, then sm
 ;; Maintainer: FSF
@@ -958,7 +958,8 @@ The value of this variable is used when Font Lock mode is turned on."
   (funcall font-lock-fontify-region-function beg end loudly))
 
 (defun font-lock-unfontify-region (beg end)
-  (funcall font-lock-unfontify-region-function beg end))
+  (save-buffer-state nil
+    (funcall font-lock-unfontify-region-function beg end)))
 
 (defun font-lock-default-fontify-buffer ()
   (let ((verbose (if (numberp font-lock-verbose)
@@ -1046,13 +1047,12 @@ This is used by `font-lock-default-unfontify-region' to decide
 what properties to clear before refontifying a region.")
 
 (defun font-lock-default-unfontify-region (beg end)
-  (save-buffer-state nil
-    (remove-list-of-text-properties
-     beg end (append
-             font-lock-extra-managed-props
-             (if font-lock-syntactic-keywords
-                 '(syntax-table face font-lock-multiline)
-               '(face font-lock-multiline))))))
+  (remove-list-of-text-properties
+   beg end (append
+           font-lock-extra-managed-props
+           (if font-lock-syntactic-keywords
+               '(syntax-table face font-lock-multiline)
+             '(face font-lock-multiline)))))
 
 ;; Called when any modification is made to buffer text.
 (defun font-lock-after-change-function (beg end old-len)
@@ -1289,7 +1289,7 @@ START should be at the beginning of a line."
     (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
     (goto-char start)
     ;;
-    ;; Find the state at the `beginning-of-line' before `start'.
+    ;; Find the `start' state.
     (setq state (or ppss (syntax-ppss start)))
     ;;
     ;; Find each interesting place between here and `end'.
@@ -1301,9 +1301,9 @@ START should be at the beginning of a line."
            (setq state (parse-partial-sexp (point) end nil nil state
                                            'syntax-table))
            (when face (put-text-property beg (point) 'face face)))
-         (setq state (parse-partial-sexp (point) end nil nil state
-                                         'syntax-table))
-         (< (point) end)))))
+         (< (point) end))
+      (setq state (parse-partial-sexp (point) end nil nil state
+                                     'syntax-table)))))
 
 ;;; End of Syntactic fontification functions.
 \f
@@ -1425,7 +1425,10 @@ LOUDLY, if non-nil, allows progress-meter bar."
        (while highlights
          (if (numberp (car (car highlights)))
              (font-lock-apply-highlight (car highlights))
-           (font-lock-fontify-anchored-keywords (car highlights) end))
+           (let ((pos (point)))
+             (font-lock-fontify-anchored-keywords (car highlights) end)
+             ;; Ensure forward progress.
+             (if (< (point) pos) (goto-char pos))))
          (setq highlights (cdr highlights))))
       (setq keywords (cdr keywords)))))
 
@@ -1456,7 +1459,7 @@ If REGEXP is non-nil, it means these keywords are used for
                       (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(")
                     "^\\s(")
                  (0
-                  (if (memq (get-text-property (1- (point)) 'face)
+                  (if (memq (get-text-property (match-beginning 0) 'face)
                             '(font-lock-string-face font-lock-doc-face
                               font-lock-comment-face))
                       font-lock-warning-face)
@@ -2003,5 +2006,5 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
 \f
 (provide 'font-lock)
 
-;;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c
+;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c
 ;;; font-lock.el ends here