diff options
| -rw-r--r-- | lisp/font-lock.el | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index d96051b429f..f16be50a4c3 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -209,6 +209,9 @@ Resources can be used to over-ride these face attributes. For example, the | |||
| 209 | resource `Emacs.font-lock-comment-face.attributeUnderline' can be used to | 209 | resource `Emacs.font-lock-comment-face.attributeUnderline' can be used to |
| 210 | specify the UNDERLINE-P attribute for face `font-lock-comment-face'.") | 210 | specify the UNDERLINE-P attribute for face `font-lock-comment-face'.") |
| 211 | 211 | ||
| 212 | (defvar font-lock-make-faces-done nil | ||
| 213 | "Non-nil if have already set up the faces for Font-Lock mode.") | ||
| 214 | |||
| 212 | (defun font-lock-make-faces () | 215 | (defun font-lock-make-faces () |
| 213 | "Make faces from `font-lock-face-attributes'. | 216 | "Make faces from `font-lock-face-attributes'. |
| 214 | A default list is used if this is nil. | 217 | A default list is used if this is nil. |
| @@ -229,10 +232,9 @@ See `font-lock-make-face' and `list-faces-display'." | |||
| 229 | "BackgroundMode")) | 232 | "BackgroundMode")) |
| 230 | (params (frame-parameters))) | 233 | (params (frame-parameters))) |
| 231 | (cond (bg-resource (intern (downcase bg-resource))) | 234 | (cond (bg-resource (intern (downcase bg-resource))) |
| 232 | ((or (string-equal "white" | 235 | ((< (apply '+ (x-color-values |
| 233 | (downcase (cdr (assq 'foreground-color params)))) | 236 | (cdr (assq 'background-color params)))) |
| 234 | (string-equal "black" | 237 | (/ (apply '+ (x-color-values "white")) 3)) |
| 235 | (downcase (cdr (assq 'background-color params))))) | ||
| 236 | 'dark) | 238 | 'dark) |
| 237 | (t 'light))))) | 239 | (t 'light))))) |
| 238 | (if (null font-lock-face-attributes) | 240 | (if (null font-lock-face-attributes) |
| @@ -291,7 +293,8 @@ See `font-lock-make-face' and `list-faces-display'." | |||
| 291 | (font-lock-variable-name-face "LightGoldenrod") | 293 | (font-lock-variable-name-face "LightGoldenrod") |
| 292 | (font-lock-type-face "PaleGreen") | 294 | (font-lock-type-face "PaleGreen") |
| 293 | (font-lock-reference-face "Aquamarine"))))))) | 295 | (font-lock-reference-face "Aquamarine"))))))) |
| 294 | (mapcar 'font-lock-make-face font-lock-face-attributes)) | 296 | (mapcar 'font-lock-make-face font-lock-face-attributes) |
| 297 | (setq font-lock-make-faces-done t)) | ||
| 295 | 298 | ||
| 296 | (defun font-lock-make-face (face-attributes) | 299 | (defun font-lock-make-face (face-attributes) |
| 297 | "Make a face from FACE-ATTRIBUTES. | 300 | "Make a face from FACE-ATTRIBUTES. |
| @@ -583,6 +586,10 @@ fontification occurs only if the buffer is less than `font-lock-maximum-size'. | |||
| 583 | To fontify a buffer without turning on Font Lock mode, and regardless of buffer | 586 | To fontify a buffer without turning on Font Lock mode, and regardless of buffer |
| 584 | size, you can use \\[font-lock-fontify-buffer]." | 587 | size, you can use \\[font-lock-fontify-buffer]." |
| 585 | (interactive "P") | 588 | (interactive "P") |
| 589 | |||
| 590 | (or font-lock-make-faces-done | ||
| 591 | (font-lock-make-faces)) | ||
| 592 | |||
| 586 | (let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode)))) | 593 | (let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode)))) |
| 587 | (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp... | 594 | (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp... |
| 588 | (setq on-p nil)) | 595 | (setq on-p nil)) |
| @@ -928,10 +935,6 @@ and `font-lock-keywords-case-fold-search' using `font-lock-defaults-alist'." | |||
| 928 | 935 | ||
| 929 | ;; Install ourselves: | 936 | ;; Install ourselves: |
| 930 | 937 | ||
| 931 | (if purify-flag | ||
| 932 | (add-hook 'after-init-hook 'font-lock-make-faces) | ||
| 933 | (font-lock-make-faces)) | ||
| 934 | |||
| 935 | (or (assq 'font-lock-mode minor-mode-alist) | 938 | (or (assq 'font-lock-mode minor-mode-alist) |
| 936 | (setq minor-mode-alist (cons '(font-lock-mode " Font") minor-mode-alist))) | 939 | (setq minor-mode-alist (cons '(font-lock-mode " Font") minor-mode-alist))) |
| 937 | 940 | ||