diff options
| author | Chong Yidong | 2007-02-06 22:36:42 +0000 |
|---|---|---|
| committer | Chong Yidong | 2007-02-06 22:36:42 +0000 |
| commit | 8db9c5eeb41b0cac6ab2a12794ccb7033b7e9848 (patch) | |
| tree | b056134f350121bc464c2030d6d048d58b759518 | |
| parent | 867eb050827c77b0b8951e4dfca446630e3c04fb (diff) | |
| download | emacs-8db9c5eeb41b0cac6ab2a12794ccb7033b7e9848.tar.gz emacs-8db9c5eeb41b0cac6ab2a12794ccb7033b7e9848.zip | |
(face-set-after-frame-default): Compile attributes to be set by frame
parameters before merging in X resources.
| -rw-r--r-- | lisp/faces.el | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/lisp/faces.el b/lisp/faces.el index 35ae4164e83..abe17f67c17 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -1754,35 +1754,48 @@ Initialize colors of certain faces from frame parameters." | |||
| 1754 | (face-attribute 'default :weight t)) | 1754 | (face-attribute 'default :weight t)) |
| 1755 | (set-face-attribute 'default frame :width | 1755 | (set-face-attribute 'default frame :width |
| 1756 | (face-attribute 'default :width t)))) | 1756 | (face-attribute 'default :width t)))) |
| 1757 | (dolist (face (face-list)) | 1757 | ;; Find attributes that should be initialized from frame parameters. |
| 1758 | ;; Don't let frame creation fail because of an invalid face spec. | 1758 | (let ((face-params '((foreground-color default :foreground) |
| 1759 | (condition-case () | 1759 | (background-color default :background) |
| 1760 | (when (not (equal face 'default)) | 1760 | (border-color border :background) |
| 1761 | (face-spec-set face (face-user-default-spec face) frame) | 1761 | (cursor-color cursor :background) |
| 1762 | (internal-merge-in-global-face face frame) | 1762 | (scroll-bar-foreground scroll-bar :foreground) |
| 1763 | (when (and (memq window-system '(x w32 mac)) | 1763 | (scroll-bar-background scroll-bar :background) |
| 1764 | (or (not (boundp 'inhibit-default-face-x-resources)) | 1764 | (mouse-color mouse :background))) |
| 1765 | (not (eq face 'default)))) | 1765 | apply-params) |
| 1766 | (make-face-x-resource-internal face frame))) | 1766 | (dolist (param face-params) |
| 1767 | (error nil))) | 1767 | (let* ((value (frame-parameter frame (nth 0 param))) |
| 1768 | ;; Initialize attributes from frame parameters. | 1768 | (face (nth 1 param)) |
| 1769 | (let ((params '((foreground-color default :foreground) | 1769 | (attr (nth 2 param)) |
| 1770 | (background-color default :background) | 1770 | (default-value (face-attribute face attr t))) |
| 1771 | (border-color border :background) | 1771 | ;; Compile a list of face attributes to set, but don't set |
| 1772 | (cursor-color cursor :background) | 1772 | ;; them yet. The call to make-face-x-resource-internal, |
| 1773 | (scroll-bar-foreground scroll-bar :foreground) | 1773 | ;; below, can change frame parameters, and the final set of |
| 1774 | (scroll-bar-background scroll-bar :background) | 1774 | ;; frame parameters should be the ones acquired at this step. |
| 1775 | (mouse-color mouse :background)))) | 1775 | (if (eq default-value 'unspecified) |
| 1776 | (dolist (param params) | 1776 | ;; The face spec does not specify a new-frame value for |
| 1777 | (let ((frame-param (frame-parameter frame (nth 0 param))) | 1777 | ;; this attribute. Check if the existing frame parameter |
| 1778 | (face (nth 1 param)) | 1778 | ;; specifies it. |
| 1779 | (attr (nth 2 param))) | 1779 | (if value |
| 1780 | (when (and frame-param | 1780 | (push (list face frame attr value) apply-params)) |
| 1781 | ;; Don't override face attributes explicitly | 1781 | ;; The face spec specifies a value for this attribute, to be |
| 1782 | ;; specified for new frames. | 1782 | ;; applied to the face on all new frames. |
| 1783 | (eq (face-attribute face attr t) 'unspecified)) | 1783 | (push (list face frame attr default-value) apply-params)))) |
| 1784 | (set-face-attribute face frame attr frame-param)))))) | 1784 | ;; Initialize faces from face specs and X resources. The |
| 1785 | 1785 | ;; condition-case prevents invalid specs from causing frame | |
| 1786 | ;; creation to fail. | ||
| 1787 | (dolist (face (delq 'default (face-list))) | ||
| 1788 | (condition-case () | ||
| 1789 | (progn | ||
| 1790 | (face-spec-set face (face-user-default-spec face) frame) | ||
| 1791 | (internal-merge-in-global-face face frame) | ||
| 1792 | (if (memq window-system '(x w32 mac)) | ||
| 1793 | (make-face-x-resource-internal face frame))) | ||
| 1794 | (error nil))) | ||
| 1795 | ;; Apply the attributes specified by frame parameters. This | ||
| 1796 | ;; rewrites parameters changed by make-face-x-resource-internal | ||
| 1797 | (dolist (param apply-params) | ||
| 1798 | (apply 'set-face-attribute param)))) | ||
| 1786 | 1799 | ||
| 1787 | (defun tty-handle-reverse-video (frame parameters) | 1800 | (defun tty-handle-reverse-video (frame parameters) |
| 1788 | "Handle the reverse-video frame parameter for terminal frames." | 1801 | "Handle the reverse-video frame parameter for terminal frames." |