]> code.delx.au - gnu-emacs/blobdiff - lisp/font-core.el
(ibuffer-update): Call `minibufferp' with argument
[gnu-emacs] / lisp / font-core.el
index ff0bec65902d5fa0413843f99cd7fff683826a89..0554d65749791438859461e10e87c6122ac8869a 100644 (file)
@@ -25,6 +25,9 @@
 
 ;;; Code:
 
+(defvar font-lock-maximum-size)
+(defvar font-lock-verbose)
+
 ;; This variable is used by mode packages that support Font Lock mode by
 ;; defining their own keywords to use for `font-lock-keywords'.  (The mode
 ;; command should make it buffer-local and set it to provide the set up.)
@@ -67,7 +70,7 @@ around a text block relevant to that mode).
 
 Other variables include that for syntactic keyword fontification,
 `font-lock-syntactic-keywords'
-and those for buffer-specialised fontification functions,
+and those for buffer-specialized fontification functions,
 `font-lock-fontify-buffer-function', `font-lock-unfontify-buffer-function',
 `font-lock-fontify-region-function', `font-lock-unfontify-region-function',
 `font-lock-inhibit-thing-lock' and `font-lock-maximum-size'.")
@@ -206,11 +209,32 @@ your own function which is called when `font-lock-mode' is toggled via
   ;; batch job) or if the buffer is invisible (the name starts with a space).
   (when (or noninteractive (eq (aref (buffer-name) 0) ?\ ))
     (setq font-lock-mode nil))
-  (funcall font-lock-function font-lock-mode))
-
-(defun font-lock-default-function (font-lock-mode)
+  (funcall font-lock-function font-lock-mode)
+  ;; Arrange to unfontify this buffer if we change major mode later.
+  (if font-lock-mode
+      (add-hook 'change-major-mode-hook 'font-lock-change-mode nil t)
+    (remove-hook 'change-major-mode-hook 'font-lock-change-mode t)))
+
+;; Get rid of fontification for the old major mode.
+;; We do this when changing major modes.
+(defun font-lock-change-mode ()
+  (font-lock-mode -1))
+
+(defun font-lock-defontify ()
+  "Clear out all `font-lock-face' properties in current buffer.
+A major mode that uses `font-lock-face' properties should put
+this function onto `change-major-mode-hook'."
+  (let ((modp (buffer-modified-p))
+       (inhibit-read-only t))
+    (save-restriction
+      (widen)
+      (remove-list-of-text-properties (point-min) (point-max)
+                                     '(font-lock-face)))
+    (set-buffer-modified-p modp)))
+
+(defun font-lock-default-function (mode)
   ;; Turn on Font Lock mode.
-  (when font-lock-mode
+  (when mode
     (font-lock-set-defaults)
     (set (make-local-variable 'char-property-alias-alist)
         (copy-tree char-property-alias-alist))
@@ -235,7 +259,7 @@ your own function which is called when `font-lock-mode' is toggled via
               (message "Fontifying %s...buffer size greater than font-lock-maximum-size"
                        (buffer-name)))))))
   ;; Turn off Font Lock mode.
-  (unless font-lock-mode
+  (unless mode
     ;; Remove `font-lock-face' as an alias for the `face' property.
     (set (make-local-variable 'char-property-alias-alist)
         (copy-tree char-property-alias-alist))