;;; 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
(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)
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)
(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'.
(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
(add-text-properties start end (cddr val))
(setq val (cadr val)))
(cond
+ ((not (or val (eq override t)))
+ ;; If `val' is nil, don't do anything. It is important to do it
+ ;; explicitly, because when adding nil via things like
+ ;; font-lock-append-text-property, the property is actually
+ ;; changed from <face> to (<face>) which is undesirable. --Stef
+ nil)
((not override)
;; Cannot override existing fontification.
(or (text-property-not-all start end 'face nil)
(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)))))
(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)
(make-local-variable 'font-lock-fontified)
(make-local-variable 'font-lock-multiline)
(let* ((defaults (or font-lock-defaults
- (cdr (assq major-mode font-lock-defaults-alist))))
+ (cdr (assq major-mode
+ (with-no-warnings
+ font-lock-defaults-alist)))))
(keywords
(font-lock-choose-keywords (nth 0 defaults)
(font-lock-value-in-major-mode font-lock-maximum-decoration)))
\f
(provide 'font-lock)
-;;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c
+;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c
;;; font-lock.el ends here