]> code.delx.au - gnu-emacs/blobdiff - lisp/font-core.el
.
[gnu-emacs] / lisp / font-core.el
index e394be7dba2ce439de6f4a4f0c7084cacdda7965..0554d65749791438859461e10e87c6122ac8869a 100644 (file)
@@ -218,26 +218,23 @@ your own function which is called when `font-lock-mode' is toggled via
 ;; Get rid of fontification for the old major mode.
 ;; We do this when changing major modes.
 (defun font-lock-change-mode ()
-  (let ((inhibit-read-only t)
-       (inhibit-point-motion-hooks t)
-       (inhibit-modification-hooks t)
-       (deactivate-mark nil)
-       (buffer-file-name nil)
-       (buffer-file-truename nil)
-       (buffer-undo-list t)
-       (modified (buffer-modified-p)))
+  (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)))
-    (unless modified
-      (restore-buffer-modified-p nil)))
-  (when font-lock-defaults
-    (font-lock-unfontify-buffer)))
-
-(defun font-lock-default-function (font-lock-mode)
+      (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))
@@ -262,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))