annotate lisp/faces.el @ 24202:afc9a7e3752f

(all): Add eol-mnemonic-* variables.
author Eli Zaretskii <eliz@gnu.org>
date Wed, 27 Jan 1999 10:11:51 +0000
parents 4cd52e40cf31
children 82cf6c4c1e03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1 ;;; faces.el --- Lisp interface to the c "face" structure
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; any later version.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; GNU General Public License for more details.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
20 ;; Boston, MA 02111-1307, USA.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;;; Commentary:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;; Mostly derived from Lucid.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26 ;;; Code:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
10107
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
28 (eval-when-compile
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
29 ;; These used to be defsubsts, now they're subrs. Avoid losing if we're
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
30 ;; being compiled with an old Emacs that still has defsubrs in it.
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
31 (put 'face-name 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
32 (put 'face-id 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
33 (put 'face-font 'byte-optimizer nil)
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
34 (put 'face-font-explicit 'byte-optimizer nil)
10107
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
35 (put 'face-foreground 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
36 (put 'face-background 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
37 (put 'face-stipple 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
38 (put 'face-underline-p 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
39 (put 'set-face-font 'byte-optimizer nil)
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
40 (put 'set-face-font-auto 'byte-optimizer nil)
10107
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
41 (put 'set-face-foreground 'byte-optimizer nil)
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
42 (put 'set-face-background 'byte-optimizer nil)
11850
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
43 (put 'set-face-stipple 'byte-optimizer nil)
10107
2af74ff52cd0 At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents: 10105
diff changeset
44 (put 'set-face-underline-p 'byte-optimizer nil))
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
45
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
46 ;;;; Functions for manipulating face vectors.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
47
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
48 ;;; A face vector is a vector of the form:
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
49 ;;; [face NAME ID FONT FOREGROUND BACKGROUND STIPPLE
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
50 ;;; UNDERLINE-P INVERSE-VIDEO-P FONT-EXPLICIT-P BOLD-P ITALIC-P]
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
51
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
52 ;;; Type checkers.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 (defsubst internal-facep (x)
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
54 (and (vectorp x) (= (length x) 12) (eq (aref x 0) 'face)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55
10584
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
56 (defun facep (x)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
57 "Return t if X is a face name or an internal face vector."
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
58 (and (or (internal-facep x)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
59 (and (symbolp x) (assq x global-face-data)))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
60 t))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
61
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 (defmacro internal-check-face (face)
10584
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
63 (` (or (internal-facep (, face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
64 (signal 'wrong-type-argument (list 'internal-facep (, face))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
66 ;;; Accessors.
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
67 (defun face-name (face)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
68 "Return the name of face FACE."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 (aref (internal-get-face face) 1))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
71 (defun face-id (face)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
72 "Return the internal ID number of face FACE."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
73 (aref (internal-get-face face) 2))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
74
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
75 (defun face-font (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
76 "Return the font name of face FACE, or nil if it is unspecified.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
77 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
78 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
79 The font default for a face is either nil, or a list
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
80 of the form (bold), (italic) or (bold italic).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
81 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
82 (aref (internal-get-face face frame) 3))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
83
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
84 (defun face-foreground (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
85 "Return the foreground color name of face FACE, or nil if unspecified.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
87 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
88 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89 (aref (internal-get-face face frame) 4))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
90
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
91 (defun face-background (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
92 "Return the background color name of face FACE, or nil if unspecified.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
93 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
94 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
95 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
96 (aref (internal-get-face face frame) 5))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
97
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
98 (defun face-stipple (face &optional frame)
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
99 "Return the stipple pixmap name of face FACE, or nil if unspecified.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
100 If the optional argument FRAME is given, report on face FACE in that frame.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
101 If FRAME is t, report on the defaults for face FACE (for new frames).
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
102 If FRAME is omitted or nil, use the selected frame."
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
103 (aref (internal-get-face face frame) 6))
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
104
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
105 (defalias 'face-background-pixmap 'face-stipple)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
106
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
107 (defun face-underline-p (face &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
108 "Return t if face FACE is underlined.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
109 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
110 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
111 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
112 (aref (internal-get-face face frame) 7))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
113
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
114 (defun face-inverse-video-p (face &optional frame)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
115 "Return t if face FACE is in inverse video.
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
116 If the optional argument FRAME is given, report on face FACE in that frame.
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
117 If FRAME is t, report on the defaults for face FACE (for new frames).
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
118 If FRAME is omitted or nil, use the selected frame."
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
119 (aref (internal-get-face face frame) 8))
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
120
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
121 (defun face-font-explicit (face &optional frame)
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
122 "Return non-nil if this face's font was explicitly specified."
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
123 (aref (internal-get-face face frame) 9))
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
124
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
125 (defun face-bold-p (face &optional frame)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
126 "Return non-nil if the font of FACE is bold.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
127 If the optional argument FRAME is given, report on face FACE in that frame.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
128 If FRAME is t, report on the defaults for face FACE (for new frames).
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
129 If FRAME is omitted or nil, use the selected frame."
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
130 (aref (internal-get-face face frame) 10))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
131
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
132 (defun face-italic-p (face &optional frame)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
133 "Return non-nil if the font of FACE is italic.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
134 If the optional argument FRAME is given, report on face FACE in that frame.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
135 If FRAME is t, report on the defaults for face FACE (for new frames).
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
136 If FRAME is omitted or nil, use the selected frame."
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
137 (aref (internal-get-face face frame) 11))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
138
18936
5aa5fcdc25c1 (face-documentation): Renamed from face-doc-string.
Richard M. Stallman <rms@gnu.org>
parents: 18919
diff changeset
139 (defalias 'face-doc-string 'face-documentation)
5aa5fcdc25c1 (face-documentation): Renamed from face-doc-string.
Richard M. Stallman <rms@gnu.org>
parents: 18919
diff changeset
140 (defun face-documentation (face)
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
141 "Get the documentation string for FACE."
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
142 (get face 'face-documentation))
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
143
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
144 ;;; Mutators.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
145
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
146 (defun set-face-font (face font &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 "Change the font of face FACE to FONT (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
148 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
149 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
150 (interactive (internal-face-interactive "font"))
17173
84aa6682810b (set-face-font): Allow specifing fontset for the arg FONT.
Kenichi Handa <handa@m17n.org>
parents: 17162
diff changeset
151 (if (stringp font)
23621
82325b2dbb5e (set-face-font): Call resolve-fontset-name on w32.
Andrew Innes <andrewi@gnu.org>
parents: 23499
diff changeset
152 (setq font (or (resolve-fontset-name font)
17173
84aa6682810b (set-face-font): Allow specifing fontset for the arg FONT.
Kenichi Handa <handa@m17n.org>
parents: 17162
diff changeset
153 (x-resolve-font-name font 'default frame))))
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
154 (internal-set-face-1 face 'font font 3 frame)
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
155 ;; Record that this face's font was set explicitly, not automatically,
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
156 ;; unless we are setting it to nil.
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
157 (internal-set-face-1 face nil (not (null font)) 9 frame))
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
158
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
159 (defun set-face-font-auto (face font &optional frame)
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
160 "Change the font of face FACE to FONT (a string), for an automatic change.
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
161 An automatic change means that we don't change the \"explicit\" flag;
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
162 if the font was derived from the frame font before, it is now.
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
163 If the optional FRAME argument is provided, change only
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
164 in that frame; otherwise change each frame."
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
165 (interactive (internal-face-interactive "font"))
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
166 (if (stringp font)
23621
82325b2dbb5e (set-face-font): Call resolve-fontset-name on w32.
Andrew Innes <andrewi@gnu.org>
parents: 23499
diff changeset
167 (setq font (or (resolve-fontset-name font)
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
168 (x-resolve-font-name font 'default frame))))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
169 (internal-set-face-1 face 'font font 3 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
170
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
171 (defun set-face-font-explicit (face flag &optional frame)
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
172 "Set the explicit-font flag of face FACE to FLAG.
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
173 If the optional FRAME argument is provided, change only
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
174 in that frame; otherwise change each frame."
18919
fd6c9bd9ca6b (set-face-font-explicit): Call internal-set-face-1 properly.
Richard M. Stallman <rms@gnu.org>
parents: 18890
diff changeset
175 (internal-set-face-1 face nil flag 9 frame))
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
176
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
177 (defun set-face-foreground (face color &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
178 "Change the foreground color of face FACE to COLOR (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
179 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
180 in that frame; otherwise change each frame."
19125
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
181 (interactive (internal-face-interactive "foreground" 'color))
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
182 (internal-set-face-1 face 'foreground color 4 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
183
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
184 (defvar face-default-stipple "gray3"
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
185 "Default stipple pattern used on monochrome displays.
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
186 This stipple pattern is used on monochrome displays
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
187 instead of shades of gray for a face background color.
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
188 See `set-face-stipple' for possible values for this variable.")
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
189
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
190 (defun face-color-gray-p (color &optional frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
191 "Return t if COLOR is a shade of gray (or white or black).
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
192 FRAME specifies the frame and thus the display for interpreting COLOR."
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
193 (let* ((values (x-color-values color frame))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
194 (r (nth 0 values))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
195 (g (nth 1 values))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
196 (b (nth 2 values)))
14409
11a297676bda (face-color-gray-p): Return nil if x-color-values does.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
197 (and values
11a297676bda (face-color-gray-p): Return nil if x-color-values does.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
198 (< (abs (- r g)) (/ (max 1 (abs r) (abs g)) 20))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
199 (< (abs (- g b)) (/ (max 1 (abs g) (abs b)) 20))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
200 (< (abs (- b r)) (/ (max 1 (abs b) (abs r)) 20)))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
201
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
202 (defun set-face-background (face color &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
203 "Change the background color of face FACE to COLOR (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
204 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
205 in that frame; otherwise change each frame."
19125
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
206 (interactive (internal-face-interactive "background" 'color))
9665
36bdda3a1dc9 (set-face-background): Set either stipple or color,
Richard M. Stallman <rms@gnu.org>
parents: 9661
diff changeset
207 ;; For a specific frame, use gray stipple instead of gray color
36bdda3a1dc9 (set-face-background): Set either stipple or color,
Richard M. Stallman <rms@gnu.org>
parents: 9661
diff changeset
208 ;; if the display does not support a gray color.
12725
968d38f57f3a (set-face-background): Don't treat nil as a color.
Richard M. Stallman <rms@gnu.org>
parents: 12690
diff changeset
209 (if (and frame (not (eq frame t)) color
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13725
diff changeset
210 ;; Check for support for foreground, not for background!
12776
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
211 ;; face-color-supported-p is smart enough to know
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
212 ;; that grays are "supported" as background
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
213 ;; because we are supposed to use stipple for them!
d69a2d6d1ae9 (set-face-background): When using face-color-supported-p,
Richard M. Stallman <rms@gnu.org>
parents: 12725
diff changeset
214 (not (face-color-supported-p frame color nil)))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
215 (set-face-stipple face face-default-stipple frame)
11464
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
216 (if (null frame)
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
217 (let ((frames (frame-list)))
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
218 (while frames
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
219 (set-face-background (face-name face) color (car frames))
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
220 (setq frames (cdr frames)))
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
221 (set-face-background face color t)
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
222 color)
4921121fbdc0 (set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
223 (internal-set-face-1 face 'background color 5 frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
224
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
225 (defun set-face-stipple (face pixmap &optional frame)
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
226 "Change the stipple pixmap of face FACE to PIXMAP.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
227 PIXMAP should be a string, the name of a file of pixmap data.
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
228 The directories listed in the `x-bitmap-file-path' variable are searched.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
229
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
230 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
231 where WIDTH and HEIGHT are the size in pixels,
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
232 and DATA is a string, containing the raw bits of the bitmap.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
233
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
234 If the optional FRAME argument is provided, change only
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
235 in that frame; otherwise change each frame."
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
236 (interactive (internal-face-interactive-stipple "stipple"))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
237 (internal-set-face-1 face 'background-pixmap pixmap 6 frame))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
238
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
239 (defalias 'set-face-background-pixmap 'set-face-stipple)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
240
10105
249d94c7e4f1 (face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents: 10022
diff changeset
241 (defun set-face-underline-p (face underline-p &optional frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
242 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
243 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
244 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
245 (interactive (internal-face-interactive "underline-p" "underlined"))
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
246 (internal-set-face-1 face 'underline underline-p 7 frame))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
247
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
248 (defun set-face-inverse-video-p (face inverse-video-p &optional frame)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
249 "Specify whether face FACE is in inverse video.
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
250 \(Yes if INVERSE-VIDEO-P is non-nil.)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
251 If the optional FRAME argument is provided, change only
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
252 in that frame; otherwise change each frame."
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
253 (interactive (internal-face-interactive "inverse-video-p" "inverse-video"))
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
254 (internal-set-face-1 face 'inverse-video inverse-video-p 8 frame))
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
255
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
256 (defun set-face-bold-p (face bold-p &optional frame)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
257 "Specify whether face FACE is bold. (Yes if BOLD-P is non-nil.)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
258 If the optional FRAME argument is provided, change only
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
259 in that frame; otherwise change each frame."
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
260 (cond ((eq bold-p nil) (make-face-unbold face frame t))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
261 (t (make-face-bold face frame t))))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
262
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
263 (defun set-face-italic-p (face italic-p &optional frame)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
264 "Specify whether face FACE is italic. (Yes if ITALIC-P is non-nil.)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
265 If the optional FRAME argument is provided, change only
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
266 in that frame; otherwise change each frame."
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
267 (cond ((eq italic-p nil) (make-face-unitalic face frame t))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
268 (t (make-face-italic face frame t))))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
269
19238
24bfe6095dfe (set-face-doc-string): Define once again, as alias.
Richard M. Stallman <rms@gnu.org>
parents: 19125
diff changeset
270 (defalias 'set-face-doc-string 'set-face-documentation)
18936
5aa5fcdc25c1 (face-documentation): Renamed from face-doc-string.
Richard M. Stallman <rms@gnu.org>
parents: 18919
diff changeset
271 (defun set-face-documentation (face string)
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
272 "Set the documentation string for FACE to STRING."
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
273 (put face 'face-documentation string))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
274
11153
984f7567a1bd Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 11152
diff changeset
275 (defun modify-face-read-string (face default name alist)
11152
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
276 (let ((value
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
277 (completing-read
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
278 (if default
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
279 (format "Set face %s %s (default %s): "
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
280 face name (downcase default))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
281 (format "Set face %s %s: " face name))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
282 alist)))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
283 (cond ((equal value "none")
23494
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
284 '(nil))
11152
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
285 ((equal value "")
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
286 default)
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
287 (t value))))
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
288
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
289 (defun modify-face (face foreground background stipple
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
290 bold-p italic-p underline-p &optional inverse-p frame)
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
291 "Change the display attributes for face FACE.
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
292 If the optional FRAME argument is provided, change only
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
293 in that frame; otherwise change each frame.
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
294
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
295 FOREGROUND and BACKGROUND should be a colour name string (or list of strings to
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
296 try) or nil. STIPPLE should be a stipple pattern name string or nil.
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
297 If nil, means do not change the display attribute corresponding to that arg.
23494
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
298 If (nil), that means clear out the attribute.
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
299
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
300 BOLD-P, ITALIC-P, UNDERLINE-P, and INVERSE-P specify whether
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
301 the face should be set bold, italic, underlined or in inverse-video,
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
302 respectively. If one of these arguments is neither nil or t, it means do not
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
303 change the display attribute corresponding to that argument.
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
304
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
305 If called interactively, prompts for a face name and face attributes."
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
306 (interactive
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
307 (let* ((completion-ignore-case t)
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
308 (face (symbol-name (read-face-name "Modify face: ")))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
309 (colors (mapcar 'list x-colors))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
310 (stipples (mapcar 'list (apply 'nconc
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
311 (mapcar 'directory-files
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
312 x-bitmap-file-path))))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
313 (foreground (modify-face-read-string
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
314 face (face-foreground (intern face))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
315 "foreground" colors))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
316 (background (modify-face-read-string
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
317 face (face-background (intern face))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
318 "background" colors))
15871
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
319 ;; If the stipple value is a list (WIDTH HEIGHT DATA),
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
320 ;; represent that as a string by printing it out.
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
321 (old-stipple-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
322 (if (stringp (face-stipple (intern face)))
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
323 (face-stipple (intern face))
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
324 (if (face-stipple (intern face))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
325 (prin1-to-string (face-stipple (intern face))))))
15871
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
326 (new-stipple-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
327 (modify-face-read-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
328 face old-stipple-string
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
329 "stipple" stipples))
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
330 ;; Convert the stipple value text we read
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
331 ;; back to a list if it looks like one.
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
332 ;; This makes the assumption that a pixmap file name
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
333 ;; won't start with an open-paren.
4904f9f8bf41 (modify-face): Handle stipple values
Richard M. Stallman <rms@gnu.org>
parents: 15510
diff changeset
334 (stipple
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
335 (and new-stipple-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
336 (if (string-match "^(" new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
337 (read new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
338 new-stipple-string)))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
339 (bold-p (y-or-n-p (concat "Should face " face " be bold ")))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
340 (italic-p (y-or-n-p (concat "Should face " face " be italic ")))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
341 (underline-p (y-or-n-p (concat "Should face " face " be underlined ")))
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
342 (inverse-p (y-or-n-p (concat "Should face " face " be inverse-video ")))
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
343 (all-frames-p (y-or-n-p (concat "Modify face " face " in all frames "))))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
344 (message "Face %s: %s" face
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
345 (mapconcat 'identity
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
346 (delq nil
23494
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
347 (list (if (equal foreground '(nil))
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
348 " no foreground"
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
349 (and foreground (concat (downcase foreground) " foreground")))
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
350 (if (equal background '(nil))
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
351 " no background"
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
352 (and background (concat (downcase background) " background")))
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
353 (if (equal stipple '(nil))
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
354 " no stipple"
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
355 (and stipple (concat (downcase new-stipple-string) " stipple")))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
356 (and bold-p "bold") (and italic-p "italic")
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
357 (and inverse-p "inverse")
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
358 (and underline-p "underline"))) ", "))
11152
eb26f12a8be6 (modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents: 10598
diff changeset
359 (list (intern face) foreground background stipple
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
360 bold-p italic-p underline-p inverse-p
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
361 (if all-frames-p nil (selected-frame)))))
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
362 ;; Clear this before we install the new foreground and background;
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
363 ;; otherwise, clearing it after would swap them!
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
364 (when (and (or foreground background) (face-inverse-video-p face))
19511
8430323b838e (modify-face): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 19479
diff changeset
365 (set-face-inverse-video-p face nil frame)
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
366 ;; Arrange to restore it after, if we are not setting it now.
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
367 (or (memq inverse-p '(t nil))
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
368 (setq inverse-p t)))
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
369 (condition-case nil
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
370 (face-try-color-list 'set-face-foreground face foreground frame)
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
371 (error nil))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
372 (condition-case nil
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
373 (face-try-color-list 'set-face-background face background frame)
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
374 (error nil))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
375 (condition-case nil
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
376 (set-face-stipple face stipple frame)
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
377 (error nil))
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
378 ;; Now that we have the new colors,
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
379 (if (memq inverse-p '(nil t))
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
380 (set-face-inverse-video-p face inverse-p frame))
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
381 (cond ((eq bold-p nil)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
382 (if (face-font face frame)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
383 (make-face-unbold face frame t)))
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
384 ((eq bold-p t)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
385 (make-face-bold face frame t)))
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
386 (cond ((eq italic-p nil)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
387 (if (face-font face frame)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
388 (make-face-unitalic face frame t)))
13725
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
389 ((eq italic-p t) (make-face-italic face frame t)))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
390 (if (memq underline-p '(nil t))
9729af46fe60 Take optional arg FRAME.
Simon Marshall <simon@gnu.org>
parents: 13704
diff changeset
391 (set-face-underline-p face underline-p frame))
9197
3fe469325a8b (modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8999
diff changeset
392 (and (interactive-p) (redraw-display)))
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
393
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
394 ;;;; Associating face names (symbols) with their face vectors.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
395
3925
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
396 (defvar global-face-data nil
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
397 "Internal data for face support functions. Not for external use.
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
398 This is an alist associating face names with the default values for
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
399 their parameters. Newly created frames get their data from here.")
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
400
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
401 (defun face-list ()
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
402 "Returns a list of all defined face names."
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
403 (mapcar 'car global-face-data))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
404
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
405 (defun internal-find-face (name &optional frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
406 "Retrieve the face named NAME. Return nil if there is no such face.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
407 If the optional argument FRAME is given, this gets the face NAME for
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
408 that frame; otherwise, it uses the selected frame.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
409 If FRAME is the symbol t, then the global, non-frame face is returned.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
410 If NAME is already a face, it is simply returned."
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
411 (if (and (eq frame t) (not (symbolp name)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
412 (setq name (face-name name)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
413 (if (symbolp name)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
414 (cdr (assq name
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
415 (if (eq frame t)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
416 global-face-data
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
417 (frame-face-alist (or frame (selected-frame))))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
418 (internal-check-face name)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
419 name))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
420
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
421 (defun internal-get-face (name &optional frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
422 "Retrieve the face named NAME; error if there is none.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
423 If the optional argument FRAME is given, this gets the face NAME for
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
424 that frame; otherwise, it uses the selected frame.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
425 If FRAME is the symbol t, then the global, non-frame face is returned.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
426 If NAME is already a face, it is simply returned."
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
427 (or (internal-find-face name frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
428 (internal-check-face name)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
429
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
430
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
431 (defun internal-set-face-1 (face name value index frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
432 (let ((inhibit-quit t))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
433 (if (null frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
434 (let ((frames (frame-list)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
435 (while frames
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
436 (internal-set-face-1 (face-name face) name value index (car frames))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
437 (setq frames (cdr frames)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
438 (aset (internal-get-face (if (symbolp face) face (face-name face)) t)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
439 index value)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
440 value)
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
441 (let ((internal-face (internal-get-face face frame)))
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
442 (or (eq frame t)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
443 (if (eq name 'inverse-video)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
444 (or (eq value (aref internal-face index))
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
445 (invert-face face frame))
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
446 (and name (fboundp 'set-face-attribute-internal)
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
447 (set-face-attribute-internal (face-id face)
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
448 name value frame))))
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
449 (aset internal-face index value)))))
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
450
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
451
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
452 (defun read-face-name (prompt)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
453 (let (face)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
454 (while (= (length face) 0)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
455 (setq face (completing-read prompt
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
456 (mapcar '(lambda (x) (list (symbol-name x)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
457 (face-list))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
458 nil t)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
459 (intern face)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
460
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
461 (defun internal-face-interactive (what &optional bool)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
462 (let* ((fn (intern (concat "face-" what)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
463 (prompt (concat "Set " what " of face"))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
464 (face (read-face-name (concat prompt ": ")))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
465 (default (if (fboundp fn)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
466 (or (funcall fn face (selected-frame))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
467 (funcall fn 'default (selected-frame)))))
19125
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
468 value)
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
469 (setq value
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
470 (cond ((eq bool 'color)
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
471 (completing-read (concat prompt " " (symbol-name face) " to: ")
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
472 (mapcar (function (lambda (color)
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
473 (cons color color)))
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
474 x-colors)
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
475 nil nil nil nil default))
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
476 (bool
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
477 (y-or-n-p (concat "Should face " (symbol-name face)
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
478 " be " bool "? ")))
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
479 (t
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
480 (read-string (concat prompt " " (symbol-name face) " to: ")
8aad7cef6fc0 (internal-face-interactive): Handle default in usual way,
Richard M. Stallman <rms@gnu.org>
parents: 19114
diff changeset
481 nil nil default))))
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
482 (list face (if (equal value "") nil value))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
483
15884
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
484 (defun internal-face-interactive-stipple (what)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
485 (let* ((fn (intern (concat "face-" what)))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
486 (prompt (concat "Set " what " of face"))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
487 (face (read-face-name (concat prompt ": ")))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
488 (default (if (fboundp fn)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
489 (or (funcall fn face (selected-frame))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
490 (funcall fn 'default (selected-frame)))))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
491 ;; If the stipple value is a list (WIDTH HEIGHT DATA),
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
492 ;; represent that as a string by printing it out.
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
493 (old-stipple-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
494 (if (stringp (face-stipple face))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
495 (face-stipple face)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
496 (if (null (face-stipple face))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
497 nil
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
498 (prin1-to-string (face-stipple face)))))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
499 (new-stipple-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
500 (read-string
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
501 (concat prompt " " (symbol-name face) " to: ")
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
502 old-stipple-string))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
503 ;; Convert the stipple value text we read
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
504 ;; back to a list if it looks like one.
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
505 ;; This makes the assumption that a pixmap file name
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
506 ;; won't start with an open-paren.
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
507 (stipple
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
508 (if (string-match "^(" new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
509 (read new-stipple-string)
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
510 new-stipple-string)))
ea80dae13b2f (modify-face): Handle nil as stipple value.
Richard M. Stallman <rms@gnu.org>
parents: 15871
diff changeset
511 (list face (if (equal stipple "") nil stipple))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
512
17386
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
513 (defun make-face (name &optional no-resources)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
514 "Define a new FACE on all frames.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
515 You can modify the font, color, etc of this face with the set-face- functions.
17386
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
516 If NO-RESOURCES is non-nil, then we ignore X resources
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
517 and always make a face whose attributes are all nil.
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
518
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
519 If the face already exists, it is unmodified."
3001
c6c6e476d93d * faces.el (make-face): Change interactive spec to 'S'.
Jim Blandy <jimb@redhat.com>
parents: 2906
diff changeset
520 (interactive "SMake face: ")
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
521 (or (internal-find-face name)
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
522 (let ((face (make-vector 12 nil)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
523 (aset face 0 'face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
524 (aset face 1 name)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
525 (let* ((frames (frame-list))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
526 (inhibit-quit t)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
527 (id (internal-next-face-id)))
18063
89a58c1d8d2c (make-face): Call make-face-internal only if defined.
Richard M. Stallman <rms@gnu.org>
parents: 17950
diff changeset
528 (if (fboundp 'make-face-internal)
89a58c1d8d2c (make-face): Call make-face-internal only if defined.
Richard M. Stallman <rms@gnu.org>
parents: 17950
diff changeset
529 (make-face-internal id))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
530 (aset face 2 id)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
531 (while frames
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
532 (set-frame-face-alist (car frames)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
533 (cons (cons name (copy-sequence face))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
534 (frame-face-alist (car frames))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
535 (setq frames (cdr frames)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
536 (setq global-face-data (cons (cons name face) global-face-data)))
17386
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
537 ;; When making a face after frames already exist
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
538 (or no-resources
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
539 (if (memq window-system '(x w32))
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
540 (make-face-x-resource-internal face)))
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
541 ;; Add to menu of faces.
9622
14e1032a7ae7 (make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents: 9572
diff changeset
542 (if (fboundp 'facemenu-add-new-face)
14e1032a7ae7 (make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents: 9572
diff changeset
543 (facemenu-add-new-face name))
8011
1bb462fc29fc (make-face): Return the face name, not the vector.
Richard M. Stallman <rms@gnu.org>
parents: 8000
diff changeset
544 face))
1bb462fc29fc (make-face): Return the face name, not the vector.
Richard M. Stallman <rms@gnu.org>
parents: 8000
diff changeset
545 name)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
546
17386
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
547 (defun make-empty-face (face)
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
548 "Define a new FACE on all frames, which initially reflects the defaults.
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
549 You can modify the font, color, etc of this face with the set-face- functions.
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
550 If the face already exists, it is unmodified."
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
551 (interactive "SMake empty face: ")
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
552 (make-face face t))
b251c8820860 (make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents: 17173
diff changeset
553
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
554 ;; Fill in a face by default based on X resources, for all existing frames.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
555 ;; This has to be done when a new face is made.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
556 (defun make-face-x-resource-internal (face &optional frame set-anyway)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
557 (cond ((null frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
558 (let ((frames (frame-list)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
559 (while frames
16590
a0cfcb9f8033 Use w32 instead of ms-windows for window-system symbol
Geoff Voelker <voelker@cs.washington.edu>
parents: 16199
diff changeset
560 (if (memq (framep (car frames)) '(x w32))
6873
086e14489073 (make-face-x-resource-internal): Don't mess with terminal frames.
Richard M. Stallman <rms@gnu.org>
parents: 6871
diff changeset
561 (make-face-x-resource-internal (face-name face)
086e14489073 (make-face-x-resource-internal): Don't mess with terminal frames.
Richard M. Stallman <rms@gnu.org>
parents: 6871
diff changeset
562 (car frames) set-anyway))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
563 (setq frames (cdr frames)))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
564 (t
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
565 (setq face (internal-get-face (face-name face) frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
566 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
567 ;; These are things like "attributeForeground" instead of simply
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
568 ;; "foreground" because people tend to do things like "*foreground",
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
569 ;; which would cause all faces to be fully qualified, making faces
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
570 ;; inherit attributes in a non-useful way. So we've made them slightly
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
571 ;; less obvious to specify in order to make them work correctly in
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
572 ;; more random environments.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
573 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
574 ;; I think these should be called "face.faceForeground" instead of
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
575 ;; "face.attributeForeground", but they're the way they are for
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
576 ;; hysterical reasons.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
577 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
578 (let* ((name (symbol-name (face-name face)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
579 (fn (or (x-get-resource (concat name ".attributeFont")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
580 "Face.AttributeFont")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
581 (and set-anyway (face-font face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
582 (fg (or (x-get-resource (concat name ".attributeForeground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
583 "Face.AttributeForeground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
584 (and set-anyway (face-foreground face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
585 (bg (or (x-get-resource (concat name ".attributeBackground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
586 "Face.AttributeBackground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
587 (and set-anyway (face-background face))))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
588 (bgp (or (x-get-resource (concat name ".attributeStipple")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
589 "Face.AttributeStipple")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
590 (x-get-resource (concat name ".attributeBackgroundPixmap")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
591 "Face.AttributeBackgroundPixmap")
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
592 (and set-anyway (face-stipple face))))
8149
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
593 (ulp (let ((resource (x-get-resource
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
594 (concat name ".attributeUnderline")
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
595 "Face.AttributeUnderline")))
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
596 (if resource
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
597 (member (downcase resource) '("on" "true"))
5e27997957db (x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents: 8109
diff changeset
598 (and set-anyway (face-underline-p face)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
599 )
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
600 (if fn
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
601 (condition-case ()
12460
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
602 (cond ((string= fn "italic")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
603 (make-face-italic face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
604 ((string= fn "bold")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
605 (make-face-bold face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
606 ((string= fn "bold-italic")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
607 (make-face-bold-italic face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
608 (t
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
609 (set-face-font face fn frame)))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
610 (error
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
611 (if (member fn '("italic" "bold" "bold-italic"))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
612 (message "no %s version found for face `%s'" fn name)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
613 (message "font `%s' not found for face `%s'" fn name)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
614 (if fg
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
615 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
616 (set-face-foreground face fg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
617 (error (message "color `%s' not allocated for face `%s'" fg name))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
618 (if bg
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
619 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
620 (set-face-background face bg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
621 (error (message "color `%s' not allocated for face `%s'" bg name))))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
622 (if bgp
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
623 (condition-case ()
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
624 (set-face-stipple face bgp frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
625 (error (message "pixmap `%s' not found for face `%s'" bgp name))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
626 (if (or ulp set-anyway)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
627 (set-face-underline-p face ulp frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
628 )))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
629 face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
630
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
631 (defun copy-face (old-face new-face &optional frame new-frame)
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
632 "Define a face just like OLD-FACE, with name NEW-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
633 If NEW-FACE already exists as a face, it is modified to be like OLD-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
634 If it doesn't already exist, it is created.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
635
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
636 If the optional argument FRAME is given as a frame,
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
637 NEW-FACE is changed on FRAME only.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
638 If FRAME is t, the frame-independent default specification for OLD-FACE
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
639 is copied to NEW-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
640 If FRAME is nil, copying is done for the frame-independent defaults
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
641 and for each existing frame.
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
642 If the optional fourth argument NEW-FRAME is given,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
643 copy the information from face OLD-FACE on frame FRAME
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
644 to NEW-FACE on frame NEW-FRAME."
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
645 (or new-frame (setq new-frame frame))
6145
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
646 (let ((inhibit-quit t))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
647 (if (null frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
648 (let ((frames (frame-list)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
649 (while frames
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
650 (copy-face old-face new-face (car frames))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
651 (setq frames (cdr frames)))
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
652 (copy-face old-face new-face t))
6145
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
653 (setq old-face (internal-get-face old-face frame))
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
654 (setq new-face (or (internal-find-face new-face new-frame)
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
655 (make-face new-face)))
8515
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
656 (condition-case nil
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
657 ;; A face that has a global symbolic font modifier such as `bold'
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
658 ;; might legitimately get an error here.
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
659 ;; Use the frame's default font in that case.
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
660 (set-face-font new-face (face-font old-face frame) new-frame)
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
661 (error
3043fef029a7 (copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents: 8377
diff changeset
662 (set-face-font new-face nil new-frame)))
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
663 (set-face-font-explicit new-face (face-font-explicit old-face frame)
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
664 new-frame)
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
665 (set-face-foreground new-face (face-foreground old-face frame) new-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
666 (set-face-background new-face (face-background old-face frame) new-frame)
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
667 (set-face-stipple new-face
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
668 (face-stipple old-face frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
669 new-frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
670 (set-face-underline-p new-face (face-underline-p old-face frame)
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
671 new-frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
672 new-face))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
673
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
674 (defun face-equal (face1 face2 &optional frame)
2906
ca9bf00d4b19 * xfaces.el (face-equal): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 2826
diff changeset
675 "True if the faces FACE1 and FACE2 display in the same way."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
676 (setq face1 (internal-get-face face1 frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
677 face2 (internal-get-face face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
678 (and (equal (face-foreground face1 frame) (face-foreground face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
679 (equal (face-background face1 frame) (face-background face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
680 (equal (face-font face1 frame) (face-font face2 frame))
8000
6d0a448be1ec (face-equal): Do check the underline attribute.
Richard M. Stallman <rms@gnu.org>
parents: 7936
diff changeset
681 (eq (face-underline-p face1 frame) (face-underline-p face2 frame))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
682 (equal (face-stipple face1 frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
683 (face-stipple face2 frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
684
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
685 (defun face-differs-from-default-p (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
686 "True if face FACE displays differently from the default face, on FRAME.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
687 A face is considered to be ``the same'' as the default face if it is
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
688 actually specified in the same way (equivalent fonts, etc) or if it is
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
689 fully unspecified, and thus inherits the attributes of any face it
10379
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
690 is displayed on top of.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
691
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
692 The optional argument FRAME specifies which frame to test;
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
693 if FRAME is t, test the default for new frames.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
694 If FRAME is nil or omitted, test the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
695 (let ((default (internal-get-face 'default frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
696 (setq face (internal-get-face face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
697 (not (and (or (equal (face-foreground default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
698 (face-foreground face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
699 (null (face-foreground face frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
700 (or (equal (face-background default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
701 (face-background face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
702 (null (face-background face frame)))
17160
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
703 (or (null (face-font face frame))
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
704 (equal (face-font face frame)
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
705 (or (face-font default frame)
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
706 (downcase
5bf55bb553f2 When testing FACE's non-nil face-font with the default face font, use the frame's font parameter if the default face's face-font is nil.
Simon Marshall <simon@gnu.org>
parents: 16841
diff changeset
707 (cdr (assq 'font (frame-parameters frame)))))))
9569
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
708 (or (equal (face-stipple default frame)
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
709 (face-stipple face frame))
943acba6d366 (set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9197
diff changeset
710 (null (face-stipple face frame)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
711 (equal (face-underline-p default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
712 (face-underline-p face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
713 ))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
714
10379
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
715 (defun face-nontrivial-p (face &optional frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
716 "True if face FACE has some non-nil attribute.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
717 The optional argument FRAME specifies which frame to test;
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
718 if FRAME is t, test the default for new frames.
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
719 If FRAME is nil or omitted, test the selected frame."
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
720 (setq face (internal-get-face face frame))
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
721 (or (face-foreground face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
722 (face-background face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
723 (face-font face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
724 (face-stipple face frame)
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
725 (face-underline-p face frame)))
f9d713e8c77c (face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10375
diff changeset
726
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
727
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
728 (defun invert-face (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
729 "Swap the foreground and background colors of face FACE.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
730 If the face doesn't specify both foreground and background, then
2800
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
731 set its foreground and background to the default background and foreground."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
732 (interactive (list (read-face-name "Invert face: ")))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
733 (setq face (internal-get-face face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
734 (let ((fg (face-foreground face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
735 (bg (face-background face frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
736 (if (or fg bg)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
737 (progn
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
738 (set-face-foreground face bg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
739 (set-face-background face fg frame))
16841
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
740 (let* ((frame-bg (cdr (assq 'background-color (frame-parameters frame))))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
741 (default-bg (or (face-background 'default frame)
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
742 frame-bg))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
743 (frame-fg (cdr (assq 'foreground-color (frame-parameters frame))))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
744 (default-fg (or (face-foreground 'default frame)
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
745 frame-fg)))
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
746 (set-face-foreground face default-bg frame)
5c964321c440 (invert-face): Handle inverting the default face better.
Richard M. Stallman <rms@gnu.org>
parents: 16687
diff changeset
747 (set-face-background face default-fg frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
748 face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
749
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
750
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
751 (defun internal-try-face-font (face font &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
752 "Like set-face-font, but returns nil on failure instead of an error."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
753 (condition-case ()
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
754 (set-face-font-auto face font frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
755 (error nil)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
756
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
757 ;; Manipulating font names.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
758
16687
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
759 (defvar x-font-regexp nil)
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
760 (defvar x-font-regexp-head nil)
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
761 (defvar x-font-regexp-weight nil)
049c87a96dca Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
762 (defvar x-font-regexp-slant nil)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
763
12668
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
764 (defconst x-font-regexp-weight-subnum 1)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
765 (defconst x-font-regexp-slant-subnum 2)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
766 (defconst x-font-regexp-swidth-subnum 3)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
767 (defconst x-font-regexp-adstyle-subnum 4)
7660e82d0346 (x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents: 12651
diff changeset
768
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
769 ;;; Regexps matching font names in "Host Portable Character Representation."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
770 ;;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
771 (let ((- "[-?]")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
772 (foundry "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
773 (family "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
774 (weight "\\(bold\\|demibold\\|medium\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
775 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
776 (weight\? "\\([^-]*\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
777 (slant "\\([ior]\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
778 ; (slant\? "\\([ior?*]?\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
779 (slant\? "\\([^-]?\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
780 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
781 (swidth "\\([^-]*\\)") ; 3
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
782 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4
12690
e2d3fa52d100 (x-font-regexp): Add \\(\\) for substring extraction.
Karl Heuer <kwzh@gnu.org>
parents: 12668
diff changeset
783 (adstyle "\\([^-]*\\)") ; 4
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
784 (pixelsize "[0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
785 (pointsize "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
786 (resx "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
787 (resy "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
788 (spacing "[cmp?*]")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
789 (avgwidth "[0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
790 (registry "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
791 (encoding "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
792 )
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
793 (setq x-font-regexp
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
794 (concat "\\`\\*?[-?*]"
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
795 foundry - family - weight\? - slant\? - swidth - adstyle -
12475
eb436b0c4ab3 (x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents: 12460
diff changeset
796 pixelsize - pointsize - resx - resy - spacing - avgwidth -
eb436b0c4ab3 (x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents: 12460
diff changeset
797 registry - encoding "\\*?\\'"
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
798 ))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
799 (setq x-font-regexp-head
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
800 (concat "\\`[-?*]" foundry - family - weight\? - slant\?
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
801 "\\([-*?]\\|\\'\\)"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
802 (setq x-font-regexp-slant (concat - slant -))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
803 (setq x-font-regexp-weight (concat - weight -))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
804 nil)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
805
3071
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
806 (defun x-resolve-font-name (pattern &optional face frame)
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
807 "Return a font name matching PATTERN.
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
808 All wildcards in PATTERN become substantiated.
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
809 If PATTERN is nil, return the name of the frame's base font, which never
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
810 contains wildcards.
10170
5fc240a3e4a0 (face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 10107
diff changeset
811 Given optional arguments FACE and FRAME, return a font which is
5fc240a3e4a0 (face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 10107
diff changeset
812 also the same size as FACE on FRAME, or fail."
3233
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
813 (or (symbolp face)
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
814 (setq face (face-name face)))
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
815 (and (eq frame t)
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
816 (setq frame nil))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
817 (if pattern
5092
36508a7c0a3f (x-resolve-font-name): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5081
diff changeset
818 ;; Note that x-list-fonts has code to handle a face with nil as its font.
16002
c8cbde1d3f11 (internal-set-face-1): When calling x-list-fonts, ask for just one match.
Richard M. Stallman <rms@gnu.org>
parents: 15884
diff changeset
819 (let ((fonts (x-list-fonts pattern face frame 1)))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
820 (or fonts
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
821 (if face
10584
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
822 (if (string-match "\\*" pattern)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
823 (if (null (face-font face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
824 (error "No matching fonts are the same height as the frame default font")
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
825 (error "No matching fonts are the same height as face `%s'" face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
826 (if (null (face-font face))
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
827 (error "Height of font `%s' doesn't match the frame default font"
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
828 pattern)
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
829 (error "Height of font `%s' doesn't match face `%s'"
f79a6ab2d0bd (facep): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10379
diff changeset
830 pattern face)))
3353
8cbd38886eef (x-resolve-font-name): Clean up error messages.
Richard M. Stallman <rms@gnu.org>
parents: 3298
diff changeset
831 (error "No fonts match `%s'" pattern)))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
832 (car fonts))
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
833 (cdr (assq 'font (frame-parameters (selected-frame))))))
3071
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
834
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
835 (defun x-frob-font-weight (font which)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
836 (let ((case-fold-search t))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
837 (cond ((string-match x-font-regexp font)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
838 (concat (substring font 0
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
839 (match-beginning x-font-regexp-weight-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
840 which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
841 (substring font (match-end x-font-regexp-weight-subnum)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
842 (match-beginning x-font-regexp-adstyle-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
843 ;; Replace the ADD_STYLE_NAME field with *
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
844 ;; because the info in it may not be the same
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
845 ;; for related fonts.
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
846 "*"
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
847 (substring font (match-end x-font-regexp-adstyle-subnum))))
14880
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
848 ((string-match x-font-regexp-head font)
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
849 (concat (substring font 0 (match-beginning 1)) which
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
850 (substring font (match-end 1))))
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
851 ((string-match x-font-regexp-weight font)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
852 (concat (substring font 0 (match-beginning 1)) which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
853 (substring font (match-end 1)))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
854
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
855 (defun x-frob-font-slant (font which)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
856 (let ((case-fold-search t))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
857 (cond ((string-match x-font-regexp font)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
858 (concat (substring font 0
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
859 (match-beginning x-font-regexp-slant-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
860 which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
861 (substring font (match-end x-font-regexp-slant-subnum)
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
862 (match-beginning x-font-regexp-adstyle-subnum))
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
863 ;; Replace the ADD_STYLE_NAME field with *
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
864 ;; because the info in it may not be the same
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
865 ;; for related fonts.
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
866 "*"
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
867 (substring font (match-end x-font-regexp-adstyle-subnum))))
14880
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
868 ((string-match x-font-regexp-head font)
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
869 (concat (substring font 0 (match-beginning 2)) which
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
870 (substring font (match-end 2))))
b405f39b5493 (x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents: 14409
diff changeset
871 ((string-match x-font-regexp-slant font)
13704
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
872 (concat (substring font 0 (match-beginning 1)) which
3dcaddea344a Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents: 13609
diff changeset
873 (substring font (match-end 1)))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
874
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
875 (defun x-make-font-bold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
876 "Given an X font specification, make a bold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
877 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
878 (x-frob-font-weight font "bold"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
879
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
880 (defun x-make-font-demibold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
881 "Given an X font specification, make a demibold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
882 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
883 (x-frob-font-weight font "demibold"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
884
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
885 (defun x-make-font-unbold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
886 "Given an X font specification, make a non-bold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
887 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
888 (x-frob-font-weight font "medium"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
889
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
890 (defun x-make-font-italic (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
891 "Given an X font specification, make an italic version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
892 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
893 (x-frob-font-slant font "i"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
894
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
895 (defun x-make-font-oblique (font) ; you say tomayto...
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
896 "Given an X font specification, make an oblique version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
897 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
898 (x-frob-font-slant font "o"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
899
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
900 (defun x-make-font-unitalic (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
901 "Given an X font specification, make a non-italic version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
902 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
903 (x-frob-font-slant font "r"))
17752
2687f3d7c191 (x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents: 17560
diff changeset
904
2687f3d7c191 (x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents: 17560
diff changeset
905 (defun x-make-font-bold-italic (font)
2687f3d7c191 (x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents: 17560
diff changeset
906 "Given an X font specification, make a bold and italic version of it.
2687f3d7c191 (x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents: 17560
diff changeset
907 If that can't be done, return nil."
2687f3d7c191 (x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents: 17560
diff changeset
908 (and (setq font (x-make-font-bold font))
2687f3d7c191 (x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents: 17560
diff changeset
909 (x-make-font-italic font)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
910
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
911 ;;; non-X-specific interface
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
912
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
913 (defun make-face-bold (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
914 "Make the font of the given face be bold, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
915 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
916 (interactive (list (read-face-name "Make which face bold: ")))
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
917 ;; Set the bold-p flag, first of all.
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
918 (internal-set-face-1 face nil t 10 frame)
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
919 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
920 (set-face-font face (if (memq 'italic (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
921 '(bold italic) '(bold))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
922 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
923 (let (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
924 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
925 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
926 ;; Make this face bold in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
927 (make-face-bold face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
928 ;; Make this face bold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
929 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
930 (make-face-bold face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
931 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
932 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
933 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
934 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
935 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
936 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
937 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
938 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
939 (cdr (assq 'font (frame-parameters frame)))))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
940 (or (and font (make-face-bold-internal face frame font))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
941 ;; We failed to find a bold version of the font.
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
942 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
943 (error "No bold version of %S" font))))))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
944
8109
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
945 (defun make-face-bold-internal (face frame font)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
946 (let (f2)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
947 (or (and (setq f2 (x-make-font-bold font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
948 (internal-try-face-font face f2 frame))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
949 (and (setq f2 (x-make-font-demibold font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
950 (internal-try-face-font face f2 frame)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
951
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
952 (defun make-face-italic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
953 "Make the font of the given face be italic, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
954 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
955 (interactive (list (read-face-name "Make which face italic: ")))
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
956 ;; Set the italic-p flag, first of all.
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
957 (internal-set-face-1 face nil t 11 frame)
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
958 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
959 (set-face-font face (if (memq 'bold (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
960 '(bold italic) '(italic))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
961 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
962 (let (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
963 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
964 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
965 ;; Make this face italic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
966 (make-face-italic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
967 ;; Make this face italic in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
968 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
969 (make-face-italic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
970 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
971 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
972 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
973 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
974 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
975 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
976 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
977 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
978 (cdr (assq 'font (frame-parameters frame)))))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
979 (or (and font (make-face-italic-internal face frame font))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
980 ;; We failed to find an italic version of the font.
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
981 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
982 (error "No italic version of %S" font))))))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
983
8109
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
984 (defun make-face-italic-internal (face frame font)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
985 (let (f2)
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
986 (or (and (setq f2 (x-make-font-italic font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
987 (internal-try-face-font face f2 frame))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
988 (and (setq f2 (x-make-font-oblique font))
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
989 (internal-try-face-font face f2 frame)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
990
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
991 (defun make-face-bold-italic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
992 "Make the font of the given face be bold and italic, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
993 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
994 (interactive (list (read-face-name "Make which face bold-italic: ")))
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
995 ;; Set the bold-p and italic-p flags, first of all.
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
996 (internal-set-face-1 face nil t 10 frame)
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
997 (internal-set-face-1 face nil t 11 frame)
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
998 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
999 (set-face-font face '(bold italic) t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1000 (let (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1001 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1002 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1003 ;; Make this face bold-italic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1004 (make-face-bold-italic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1005 ;; Make this face bold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1006 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1007 (make-face-bold-italic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1008 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1009 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1010 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1011 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1012 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1013 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1014 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1015 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1016 (cdr (assq 'font (frame-parameters frame)))))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1017 (or (and font (make-face-bold-italic-internal face frame font))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1018 ;; We failed to find a bold italic version.
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1019 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1020 (error "No bold italic version of %S" font))))))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1021
8109
9bc00e1f0f3e (make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents: 8107
diff changeset
1022 (defun make-face-bold-italic-internal (face frame font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1023 (let (f2 f3)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1024 (or (and (setq f2 (x-make-font-italic font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1025 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1026 (setq f3 (x-make-font-bold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1027 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1028 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1029 (and (setq f2 (x-make-font-oblique font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1030 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1031 (setq f3 (x-make-font-bold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1032 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1033 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1034 (and (setq f2 (x-make-font-italic font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1035 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1036 (setq f3 (x-make-font-demibold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1037 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1038 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1039 (and (setq f2 (x-make-font-oblique font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1040 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1041 (setq f3 (x-make-font-demibold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1042 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1043 (internal-try-face-font face f3 frame)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1044
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
1045 (defun make-face-unbold (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1046 "Make the font of the given face be non-bold, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
1047 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1048 (interactive (list (read-face-name "Make which face non-bold: ")))
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
1049 ;; Clear the bold-p flag, first of all.
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
1050 (internal-set-face-1 face nil nil 10 frame)
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
1051 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1052 (set-face-font face (if (memq 'italic (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1053 '(italic) nil)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1054 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1055 (let (font font1)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1056 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1057 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1058 ;; Make this face unbold in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1059 (make-face-unbold face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1060 ;; Make this face unbold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1061 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1062 (make-face-unbold face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1063 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1064 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1065 (setq font1 (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1066 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1067 (if (listp font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1068 (setq font1 nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1069 (setq font1 (or font1
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1070 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1071 (cdr (assq 'font (frame-parameters frame)))))
8732
58d6dc80af5c (make-face-unbold, make-face-unitalic, make-face-bold, make-face-italic,
Karl Heuer <kwzh@gnu.org>
parents: 8515
diff changeset
1072 (setq font (and font1 (x-make-font-unbold font1)))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1073 (or (if font (internal-try-face-font face font frame))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1074 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1075 (error "No unbold version of %S" font1))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1076
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
1077 (defun make-face-unitalic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1078 "Make the font of the given face be non-italic, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
1079 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1080 (interactive (list (read-face-name "Make which face non-italic: ")))
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
1081 ;; Clear the italic-p flag, first of all.
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
1082 (internal-set-face-1 face nil nil 11 frame)
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
1083 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1084 (set-face-font face (if (memq 'bold (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1085 '(bold) nil)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1086 t)
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1087 (let (font font1)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1088 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1089 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1090 ;; Make this face unitalic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1091 (make-face-unitalic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1092 ;; Make this face unitalic in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1093 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1094 (make-face-unitalic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1095 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1096 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1097 (setq font1 (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1098 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1099 (if (listp font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1100 (setq font1 nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1101 (setq font1 (or font1
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1102 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
1103 (cdr (assq 'font (frame-parameters frame)))))
8732
58d6dc80af5c (make-face-unbold, make-face-unitalic, make-face-bold, make-face-italic,
Karl Heuer <kwzh@gnu.org>
parents: 8515
diff changeset
1104 (setq font (and font1 (x-make-font-unitalic font1)))
12651
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1105 (or (if font (internal-try-face-font face font frame))
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1106 noerror
4bb00f26c714 (make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents: 12581
diff changeset
1107 (error "No unitalic version of %S" font1))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1108
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1109 (defvar list-faces-sample-text
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1110 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1111 "*Text string to display as the sample text for `list-faces-display'.")
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1112
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1113 ;; The name list-faces would be more consistent, but let's avoid a conflict
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1114 ;; with Lucid, which uses that name differently.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1115 (defun list-faces-display ()
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1116 "List all faces, using the same sample text in each.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1117 The sample text is a string that comes from the variable
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1118 `list-faces-sample-text'.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1119
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1120 It is possible to give a particular face name different appearances in
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1121 different frames. This command shows the appearance in the
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1122 selected frame."
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1123 (interactive)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1124 (let ((faces (sort (face-list) (function string-lessp)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1125 (face nil)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1126 (frame (selected-frame))
24045
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1127 disp-frame window
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1128 (face-name-max-length
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1129 (car (sort (mapcar (function string-width)
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1130 (mapcar (function symbol-name) (face-list)))
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1131 (function >)))))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1132 (with-output-to-temp-buffer "*Faces*"
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1133 (save-excursion
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1134 (set-buffer standard-output)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1135 (setq truncate-lines t)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1136 (while faces
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1137 (setq face (car faces))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1138 (setq faces (cdr faces))
24045
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1139 (insert (format
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1140 (format "%%-%ds "
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1141 face-name-max-length)
094765645c52 (list-faces-display): Improve the formatting
Richard M. Stallman <rms@gnu.org>
parents: 23621
diff changeset
1142 (symbol-name face)))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1143 (let ((beg (point)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1144 (insert list-faces-sample-text)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1145 (insert "\n")
8107
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
1146 (put-text-property beg (1- (point)) 'face face)
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
1147 ;; If the sample text has multiple lines, line up all of them.
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
1148 (goto-char beg)
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
1149 (forward-line 1)
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
1150 (while (not (eobp))
24174
4cd52e40cf31 (list-faces-display): Multiline case of previous fix.
Karl Heuer <kwzh@gnu.org>
parents: 24045
diff changeset
1151 (insert-char ? (1+ face-name-max-length))
8107
0885b28decc6 (list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents: 8011
diff changeset
1152 (forward-line 1))))
22996
c76b7dd7a823 (list-faces-display): Call print-help-return-message.
Richard M. Stallman <rms@gnu.org>
parents: 22670
diff changeset
1153 (goto-char (point-min)))
c76b7dd7a823 (list-faces-display): Call print-help-return-message.
Richard M. Stallman <rms@gnu.org>
parents: 22670
diff changeset
1154 (print-help-return-message))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1155 ;; If the *Faces* buffer appears in a different frame,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1156 ;; copy all the face definitions from FRAME,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1157 ;; so that the display will reflect the frame that was selected.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1158 (setq window (get-buffer-window (get-buffer "*Faces*") t))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1159 (setq disp-frame (if window (window-frame window)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1160 (car (frame-list))))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1161 (or (eq frame disp-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1162 (let ((faces (face-list)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1163 (while faces
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1164 (copy-face (car faces) (car faces) frame disp-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1165 (setq faces (cdr faces)))))))
12460
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1166
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1167 (defun describe-face (face)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1168 "Display the properties of face FACE."
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1169 (interactive (list (read-face-name "Describe face: ")))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1170 (with-output-to-temp-buffer "*Help*"
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1171 (princ "Properties of face `")
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1172 (princ (face-name face))
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1173 (princ "':") (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1174 (princ "Foreground: ") (princ (face-foreground face)) (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1175 (princ "Background: ") (princ (face-background face)) (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1176 (princ " Font: ") (princ (face-font face)) (terpri)
1e12a802df2b (describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12169
diff changeset
1177 (princ "Underlined: ") (princ (if (face-underline-p face) "yes" "no")) (terpri)
17560
1f4d7f741932 (describe-face): Add documentation.
Richard M. Stallman <rms@gnu.org>
parents: 17522
diff changeset
1178 (princ " Stipple: ") (princ (or (face-stipple face) "none")) (terpri)
1f4d7f741932 (describe-face): Add documentation.
Richard M. Stallman <rms@gnu.org>
parents: 17522
diff changeset
1179 (terpri)
1f4d7f741932 (describe-face): Add documentation.
Richard M. Stallman <rms@gnu.org>
parents: 17522
diff changeset
1180 (princ "Documentation:") (terpri)
18936
5aa5fcdc25c1 (face-documentation): Renamed from face-doc-string.
Richard M. Stallman <rms@gnu.org>
parents: 18919
diff changeset
1181 (let ((doc (face-documentation face)))
17560
1f4d7f741932 (describe-face): Add documentation.
Richard M. Stallman <rms@gnu.org>
parents: 17522
diff changeset
1182 (if doc
1f4d7f741932 (describe-face): Add documentation.
Richard M. Stallman <rms@gnu.org>
parents: 17522
diff changeset
1183 (princ doc)
22996
c76b7dd7a823 (list-faces-display): Call print-help-return-message.
Richard M. Stallman <rms@gnu.org>
parents: 22670
diff changeset
1184 (princ "not documented as a face.")))
c76b7dd7a823 (list-faces-display): Call print-help-return-message.
Richard M. Stallman <rms@gnu.org>
parents: 22670
diff changeset
1185 (print-help-return-message)))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
1186
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1187 ;;; Setting a face based on a SPEC.
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1188
19098
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1189 (defun face-attr-match-p (face attrs &optional frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1190 (or frame (setq frame (selected-frame)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1191 (and (face-attr-match-1 face frame attrs ':inverse-video
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1192 'face-inverse-video-p)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1193 (if (face-inverse-video-p face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1194 (and
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1195 (face-attr-match-1 face frame attrs
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1196 ':foreground 'face-background
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1197 (cdr (assq 'foreground-color
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1198 (frame-parameters frame))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1199 (face-attr-match-1 face frame attrs
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1200 ':background 'face-foreground
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1201 (cdr (assq 'background-color
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1202 (frame-parameters frame)))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1203 (and
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1204 (face-attr-match-1 face frame attrs ':foreground 'face-foreground)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1205 (face-attr-match-1 face frame attrs ':background 'face-background)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1206 (face-attr-match-1 face frame attrs ':stipple 'face-stipple)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1207 (face-attr-match-1 face frame attrs ':bold 'face-bold-p)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1208 (face-attr-match-1 face frame attrs ':italic 'face-italic-p)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1209 (face-attr-match-1 face frame attrs ':underline 'face-underline-p)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1210 ))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1211
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1212 (defun face-attr-match-1 (face frame plist property function
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1213 &optional defaultval)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1214 (while (and plist (not (eq (car plist) property)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1215 (setq plist (cdr (cdr plist))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1216 (eq (funcall function face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1217 (if plist
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1218 (nth 1 plist)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1219 (or defaultval
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1220 (funcall function 'default frame)))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1221
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1222 (defun face-spec-match-p (face spec &optional frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1223 "Return t if FACE, on FRAME, matches what SPEC says it should look like."
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1224 (face-attr-match-p face (face-spec-choose spec frame) frame))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1225
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1226 (defun face-attr-construct (face &optional frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1227 "Return a defface-style attribute list for FACE, as it exists on FRAME."
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1228 (let (result)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1229 (if (face-inverse-video-p face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1230 (progn
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1231 (setq result (cons ':inverse-video (cons t result)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1232 (or (face-attr-match-1 face frame nil
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1233 ':foreground 'face-background
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1234 (cdr (assq 'foreground-color
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1235 (frame-parameters frame))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1236 (setq result (cons ':foreground
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1237 (cons (face-foreground face frame) result))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1238 (or (face-attr-match-1 face frame nil
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1239 ':background 'face-foreground
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1240 (cdr (assq 'background-color
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1241 (frame-parameters frame))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1242 (setq result (cons ':background
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1243 (cons (face-background face frame) result)))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1244 (if (face-foreground face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1245 (setq result (cons ':foreground
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1246 (cons (face-foreground face frame) result))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1247 (if (face-background face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1248 (setq result (cons ':background
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1249 (cons (face-background face frame) result)))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1250 (if (face-stipple face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1251 (setq result (cons ':stipple
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1252 (cons (face-stipple face frame) result))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1253 (if (face-bold-p face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1254 (setq result (cons ':bold
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1255 (cons (face-bold-p face frame) result))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1256 (if (face-italic-p face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1257 (setq result (cons ':italic
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1258 (cons (face-italic-p face frame) result))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1259 (if (face-underline-p face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1260 (setq result (cons ':underline
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1261 (cons (face-underline-p face frame) result))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1262 result))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1263
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1264 ;; Choose the proper attributes for FRAME, out of SPEC.
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1265 (defun face-spec-choose (spec &optional frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1266 (or frame (setq frame (selected-frame)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1267 (let ((tail spec)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1268 result)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1269 (while tail
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1270 (let* ((entry (car tail))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1271 (display (nth 0 entry))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1272 (attrs (nth 1 entry)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1273 (setq tail (cdr tail))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1274 (when (face-spec-set-match-display display frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1275 (setq result attrs tail nil))))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1276 result))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1277
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1278 (defun face-spec-set (face spec &optional frame)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1279 "Set FACE's face attributes according to the first matching entry in SPEC.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1280 If optional FRAME is non-nil, set it for that frame only.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1281 If it is nil, then apply SPEC to each frame individually.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1282 See `defface' for information about SPEC."
19098
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1283 (if frame
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1284 (let ((attrs (face-spec-choose spec frame)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1285 (when attrs
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1286 ;; If the font was set automatically, clear it out
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1287 ;; to allow it to be set it again.
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1288 (unless (face-font-explicit face frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1289 (set-face-font face nil frame))
19479
3c201ec148a4 (modify-face): New arg INVERSE-P.
Richard M. Stallman <rms@gnu.org>
parents: 19403
diff changeset
1290 (modify-face face '(nil) '(nil) nil nil nil nil nil frame)
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1291 (face-spec-set-1 face frame attrs ':foreground 'set-face-foreground)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1292 (face-spec-set-1 face frame attrs ':background 'set-face-background)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1293 (face-spec-set-1 face frame attrs ':stipple 'set-face-stipple)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1294 (face-spec-set-1 face frame attrs ':bold 'set-face-bold-p)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1295 (face-spec-set-1 face frame attrs ':italic 'set-face-italic-p)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1296 (face-spec-set-1 face frame attrs ':underline 'set-face-underline-p)
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
1297 (face-spec-set-1 face frame attrs ':inverse-video
19098
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1298 'set-face-inverse-video-p)))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1299 (let ((frames (frame-list))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1300 frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1301 (while frames
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1302 (setq frame (car frames)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1303 frames (cdr frames))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1304 (face-spec-set face (or (get face 'saved-face)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1305 (get face 'face-defface-spec))
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1306 frame)
51fdd58dc112 (face-attr-match-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19050
diff changeset
1307 (face-spec-set face spec frame)))))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1308
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1309 (defun face-spec-set-1 (face frame plist property function)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1310 (while (and plist (not (eq (car plist) property)))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1311 (setq plist (cdr (cdr plist))))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1312 (if plist
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1313 (funcall function face (nth 1 plist) frame)))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1314
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1315 (defun face-spec-set-match-display (display frame)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1316 "Non-nil iff DISPLAY matches FRAME.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1317 DISPLAY is part of a spec such as can be used in `defface'.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1318 If FRAME is nil, the current FRAME is used."
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1319 (let* ((conjuncts display)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1320 conjunct req options
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1321 ;; t means we have succeeded against all
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1322 ;; the conjunts in DISPLAY that have been tested so far.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1323 (match t))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1324 (if (eq conjuncts t)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1325 (setq conjuncts nil))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1326 (while (and conjuncts match)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1327 (setq conjunct (car conjuncts)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1328 conjuncts (cdr conjuncts)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1329 req (car conjunct)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1330 options (cdr conjunct)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1331 match (cond ((eq req 'type)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1332 (memq window-system options))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1333 ((eq req 'class)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1334 (memq (frame-parameter frame 'display-type) options))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1335 ((eq req 'background)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1336 (memq (frame-parameter frame 'background-mode)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1337 options))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1338 (t
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1339 (error "Unknown req `%S' with options `%S'"
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1340 req options)))))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1341 match))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1342
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1343 ;; Like x-create-frame but also set up the faces.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1344
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1345 (defun x-create-frame-with-faces (&optional parameters)
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1346 ;; Read this frame's geometry resource, if it has an explicit name,
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1347 ;; and put the specs into PARAMETERS.
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1348 (let* ((name (or (cdr (assq 'name parameters))
12169
67f9dfb23d7c (x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents: 12168
diff changeset
1349 (cdr (assq 'name default-frame-alist))))
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1350 (x-resource-name name)
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1351 (res-geometry (if name (x-get-resource "geometry" "Geometry"))))
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1352 (if res-geometry
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1353 (let ((parsed (x-parse-geometry res-geometry)))
11927
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1354 ;; If the resource specifies a position,
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1355 ;; call the position and size "user-specified".
20eae371b3f0 (x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents: 11850
diff changeset
1356 (if (or (assq 'top parsed) (assq 'left parsed))
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1357 (setq parsed (append '((user-position . t) (user-size . t))
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1358 parsed)))
12169
67f9dfb23d7c (x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents: 12168
diff changeset
1359 ;; Put the geometry parameters at the end.
67f9dfb23d7c (x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents: 12168
diff changeset
1360 ;; Copy default-frame-alist so that they go after it.
17162
97232f50447f clean code.
Simon Marshall <simon@gnu.org>
parents: 17160
diff changeset
1361 (setq parameters (append parameters default-frame-alist parsed)))))
22670
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1362
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1363 (if default-enable-multibyte-characters
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1364 ;; If an ASCII font is specified in PARAMETERS, we try to create
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1365 ;; a fontset from it, and use it for the new frame.
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1366 (condition-case nil
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1367 (let ((font (cdr (assq 'font parameters))))
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1368 (if (and font
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1369 (not (query-fontset font)))
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1370 (setq parameters
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1371 (cons (cons 'font (create-fontset-from-ascii-font font))
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1372 parameters))))
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1373 (error nil)))
160c346d6192 (x-create-frame-with-faces): If an ASCII font is
Kenichi Handa <handa@m17n.org>
parents: 22624
diff changeset
1374
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1375 (let (frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1376 (if (null global-face-data)
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1377 (progn
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1378 (setq frame (x-create-frame parameters))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1379 (frame-set-background-mode frame))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1380 (let* ((visibility-spec (assq 'visibility parameters))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1381 success faces rest)
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1382 (setq frame (x-create-frame (cons '(visibility . nil) parameters)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1383 (unwind-protect
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1384 (progn
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1385 ;; Copy the face alist, copying the face vectors
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1386 ;; and emptying out their attributes.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1387 (setq faces
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1388 (mapcar '(lambda (elt)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1389 (cons (car elt)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1390 (vector 'face
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1391 (face-name (cdr elt))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1392 (face-id (cdr elt))
19403
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
1393 nil
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
1394 nil nil nil nil
11d21b4613cd Faces now have 2 more elements, bold-p and italic-p.
Richard M. Stallman <rms@gnu.org>
parents: 19238
diff changeset
1395 nil nil nil nil)))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1396 global-face-data))
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1397 (set-frame-face-alist frame faces)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1398
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1399 ;; Handle the reverse-video frame parameter
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1400 ;; and X resource. x-create-frame does not handle this one.
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1401 (if (cdr (or (assq 'reverse parameters)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1402 (assq 'reverse default-frame-alist)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1403 (let ((resource (x-get-resource "reverseVideo"
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1404 "ReverseVideo")))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1405 (if resource
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1406 (cons nil (member (downcase resource)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1407 '("on" "true")))))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1408 (let* ((params (frame-parameters frame))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1409 (bg (cdr (assq 'foreground-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1410 (fg (cdr (assq 'background-color params))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1411 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1412 (list (cons 'foreground-color fg)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1413 (cons 'background-color bg)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1414 (if (equal bg (cdr (assq 'border-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1415 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1416 (list (cons 'border-color fg))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1417 (if (equal bg (cdr (assq 'mouse-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1418 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1419 (list (cons 'mouse-color fg))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1420 (if (equal bg (cdr (assq 'cursor-color params)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1421 (modify-frame-parameters frame
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1422 (list (cons 'cursor-color fg))))))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1423
17950
4ef122a60b5a (x-create-frame-with-faces): Don't call frame-set-background-mode
Richard M. Stallman <rms@gnu.org>
parents: 17947
diff changeset
1424 (frame-set-background-mode frame)
4ef122a60b5a (x-create-frame-with-faces): Don't call frame-set-background-mode
Richard M. Stallman <rms@gnu.org>
parents: 17947
diff changeset
1425
18635
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1426 (face-set-after-frame-default frame)
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1427
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1428 ;; Make the frame visible, if desired.
12562
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1429 (if (null visibility-spec)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1430 (make-frame-visible frame)
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1431 (modify-frame-parameters frame (list visibility-spec)))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1432 (setq success t))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1433 (or success
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1434 (delete-frame frame)))))
a9b08e50d6ec (x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents: 12475
diff changeset
1435 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1436
18635
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1437 ;; Update a frame's faces after the frame font changes.
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1438 ;; This is called from modify-frame-parameters
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1439 ;; as well as from elsewhere in this file.
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1440 (defun face-set-after-frame-default (frame)
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1441 (let ((rest (frame-face-alist frame)))
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1442 (while rest
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1443 ;; Set up each face, first from the defface information,
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1444 ;; then the global face data, and then the X resources.
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1445 (let* ((face (car (car rest)))
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1446 (spec (or (get face 'saved-face)
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1447 (get face 'face-defface-spec)))
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1448 (global (cdr (assq face global-face-data)))
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1449 (local (cdr (car rest))))
18890
825fe2874454 (internal-facep): Length is now 10.
Richard M. Stallman <rms@gnu.org>
parents: 18635
diff changeset
1450 (when spec
18635
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1451 (face-spec-set face spec frame))
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1452 (face-fill-in face global frame)
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1453 (make-face-x-resource-internal local frame))
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1454 (setq rest (cdr rest)))))
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1455
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1456 (defcustom frame-background-mode nil
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1457 "*The brightness of the background.
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1458 Set this to the symbol dark if your background color is dark, light if
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1459 your background is light, or nil (default) if you want Emacs to
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1460 examine the brightness for you."
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1461 :group 'faces
22152
3aff676c3ea3 (frame-background-mode): Define a :set function
Richard M. Stallman <rms@gnu.org>
parents: 20126
diff changeset
1462 :set #'(lambda (var value)
3aff676c3ea3 (frame-background-mode): Define a :set function
Richard M. Stallman <rms@gnu.org>
parents: 20126
diff changeset
1463 (set var value)
3aff676c3ea3 (frame-background-mode): Define a :set function
Richard M. Stallman <rms@gnu.org>
parents: 20126
diff changeset
1464 (mapcar 'frame-set-background-mode (frame-list)))
3aff676c3ea3 (frame-background-mode): Define a :set function
Richard M. Stallman <rms@gnu.org>
parents: 20126
diff changeset
1465 :initialize 'custom-initialize-changed
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1466 :type '(choice (choice-item dark)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1467 (choice-item light)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1468 (choice-item :tag "default" nil)))
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1469
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1470 (defun frame-set-background-mode (frame)
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1471 "Set up the `background-mode' and `display-type' frame parameters for FRAME."
23499
57e5c9aadd19 (frame-set-background-mode): Enable the function for MSDOS frames.
Eli Zaretskii <eliz@gnu.org>
parents: 23494
diff changeset
1472 (unless (eq (framep frame) t)
23408
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1473 (let ((bg-resource (x-get-resource ".backgroundMode"
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1474 "BackgroundMode"))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1475 (params (frame-parameters frame))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1476 (bg-mode))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1477 (setq bg-mode
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1478 (cond (frame-background-mode)
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1479 (bg-resource (intern (downcase bg-resource)))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1480 ((< (apply '+ (x-color-values
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1481 (cdr (assq 'background-color params))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1482 frame))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1483 ;; Just looking at the screen,
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1484 ;; colors whose values add up to .6 of the white total
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1485 ;; still look dark to me.
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1486 (* (apply '+ (x-color-values "white" frame)) .6))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1487 'dark)
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1488 (t 'light)))
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1489 (modify-frame-parameters frame
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1490 (list (cons 'background-mode bg-mode)
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1491 (cons 'display-type
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1492 (cond ((x-display-color-p frame)
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1493 'color)
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1494 ((x-display-grayscale-p frame)
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1495 'grayscale)
063b2599a0fd (frame-set-background-mode): Don't do anythung for text-only or MSDOS frame.
Richard M. Stallman <rms@gnu.org>
parents: 22996
diff changeset
1496 (t 'mono))))))))
17522
209c61e51bd0 (frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 17386
diff changeset
1497
7019
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1498 ;; Update a frame's faces when we change its default font.
18635
d55ebf568fe7 (face-set-after-frame-default): New ubroutine,
Richard M. Stallman <rms@gnu.org>
parents: 18063
diff changeset
1499 (defun frame-update-faces (frame) nil)
7019
74edb669a7e9 (frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6873
diff changeset
1500
10193
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1501 ;; Update the colors of FACE, after FRAME's own colors have been changed.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1502 ;; This applies only to faces with global color specifications
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1503 ;; that are not simple constants.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1504 (defun frame-update-face-colors (frame)
22233
d06567759809 (frame-update-face-colors): Call frame-set-background-mode.
Richard M. Stallman <rms@gnu.org>
parents: 22152
diff changeset
1505 (frame-set-background-mode frame)
10193
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1506 (let ((faces global-face-data))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1507 (while faces
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1508 (condition-case nil
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1509 (let* ((data (cdr (car faces)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1510 (face (car (car faces)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1511 (foreground (face-foreground data))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1512 (background (face-background data)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1513 ;; If the global spec is a specific color,
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1514 ;; which doesn't depend on the frame's attributes,
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1515 ;; we don't need to recalculate it now.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1516 (or (listp foreground)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1517 (setq foreground nil))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1518 (or (listp background)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1519 (setq background nil))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1520 ;; If we are going to frob this face at all,
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1521 ;; reinitialize it first.
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1522 (if (or foreground background)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1523 (progn (set-face-foreground face nil frame)
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1524 (set-face-background face nil frame)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1525 (if foreground
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1526 (face-try-color-list 'set-face-foreground
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1527 face foreground frame))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1528 (if background
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1529 (face-try-color-list 'set-face-background
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1530 face background frame)))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1531 (error nil))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1532 (setq faces (cdr faces)))))
6efa61f222cb (frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10170
diff changeset
1533
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1534 ;; Fill in the face FACE from frame-independent face data DATA.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1535 ;; DATA should be the non-frame-specific ("global") face vector
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1536 ;; for the face. FACE should be a face name or face object.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1537 ;; FRAME is the frame to act on; it must be an actual frame, not nil or t.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1538 (defun face-fill-in (face data frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1539 (condition-case nil
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1540 (let ((foreground (face-foreground data))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1541 (background (face-background data))
11850
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1542 (font (face-font data))
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1543 (stipple (face-stipple data)))
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
1544 (if (face-underline-p data)
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
1545 (set-face-underline-p face (face-underline-p data) frame))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1546 (if foreground
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1547 (face-try-color-list 'set-face-foreground
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1548 face foreground frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1549 (if background
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1550 (face-try-color-list 'set-face-background
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1551 face background frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1552 (if (listp font)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1553 (let ((bold (memq 'bold font))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1554 (italic (memq 'italic font)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1555 (cond ((and bold italic)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1556 (make-face-bold-italic face frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1557 (bold
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1558 (make-face-bold face frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1559 (italic
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1560 (make-face-italic face frame))))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1561 (if font
11850
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1562 (set-face-font face font frame)))
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1563 (if stipple
f9174d73e755 Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents: 11464
diff changeset
1564 (set-face-stipple face stipple frame)))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1565 (error nil)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1566
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1567 ;; Assuming COLOR is a valid color name,
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1568 ;; return t if it can be displayed on FRAME.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1569 (defun face-color-supported-p (frame color background-p)
13609
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1570 (and window-system
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1571 (or (x-display-color-p frame)
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1572 ;; A black-and-white display can implement these.
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1573 (member color '("black" "white"))
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1574 ;; A black-and-white display can fake gray for background.
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1575 (and background-p
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1576 (face-color-gray-p color frame))
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1577 ;; A grayscale display can implement colors that are gray (more or less).
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1578 (and (x-display-grayscale-p frame)
eb141cf52779 (face-color-supported-p): Return nil if no window system.
Richard M. Stallman <rms@gnu.org>
parents: 13432
diff changeset
1579 (face-color-gray-p color frame)))))
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1580
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1581 ;; Use FUNCTION to store a color in FACE on FRAME.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1582 ;; COLORS is either a single color or a list of colors.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1583 ;; If it is a list, try the colors one by one until one of them
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1584 ;; succeeds. We signal an error only if all the colors failed.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1585 ;; t as COLORS or as an element of COLORS means to invert the face.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1586 ;; That can't fail, so any subsequent elements after the t are ignored.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1587 (defun face-try-color-list (function face colors frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1588 (if (stringp colors)
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1589 (if (face-color-supported-p frame colors
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1590 (eq function 'set-face-background))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1591 (funcall function face colors frame))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1592 (if (eq colors t)
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
1593 (set-face-inverse-video-p face t frame)
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1594 (let (done)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1595 (while (and colors (not done))
23494
e7be878041d5 (modify-face-read-string): Return (nil) for "none".
Richard M. Stallman <rms@gnu.org>
parents: 23408
diff changeset
1596 (if (or (memq (car colors) '(t underline nil))
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1597 (face-color-supported-p frame (car colors)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1598 (eq function 'set-face-background)))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1599 (if (cdr colors)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1600 ;; If there are more colors to try, catch errors
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1601 ;; and set `done' if we succeed.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1602 (condition-case nil
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1603 (progn
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1604 (cond ((eq (car colors) t)
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
1605 (set-face-inverse-video-p face t frame))
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1606 ((eq (car colors) 'underline)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1607 (set-face-underline-p face t frame))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1608 (t
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1609 (funcall function face (car colors) frame)))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1610 (setq done t))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1611 (error nil))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1612 ;; If this is the last color, let the error get out if it fails.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1613 ;; If it succeeds, we will exit anyway after this iteration.
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1614 (cond ((eq (car colors) t)
17945
874de6432f05 (modify-face): Don't call make-face-unbold
Richard M. Stallman <rms@gnu.org>
parents: 17752
diff changeset
1615 (set-face-inverse-video-p face t frame))
10022
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1616 ((eq (car colors) 'underline)
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1617 (set-face-underline-p face t frame))
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1618 (t
30e0dc7c07cd (face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 9665
diff changeset
1619 (funcall function face (car colors) frame)))))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
1620 (setq colors (cdr colors)))))))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
1621
17947
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1622 ;;; Make the standard faces.
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1623 ;;; The C code knows the default and modeline faces as faces 0 and 1,
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1624 ;;; so they must be the first two faces made.
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1625 (make-face 'default)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1626 (make-face 'modeline)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1627 (make-face 'highlight)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1628
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1629 ;; These aren't really special in any way, but they're nice to have around.
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1630
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1631 (make-face 'bold)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1632 (make-face 'italic)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1633 (make-face 'bold-italic)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1634 (make-face 'region)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1635 (make-face 'secondary-selection)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1636 (make-face 'underline)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1637
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1638 (setq region-face (face-id 'region))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1639
20126
0e8886335c4b (basic-faces): New group. Put the standard faces in it.
Karl Heuer <kwzh@gnu.org>
parents: 19770
diff changeset
1640 (defgroup basic-faces nil
0e8886335c4b (basic-faces): New group. Put the standard faces in it.
Karl Heuer <kwzh@gnu.org>
parents: 19770
diff changeset
1641 "The standard faces of Emacs."
0e8886335c4b (basic-faces): New group. Put the standard faces in it.
Karl Heuer <kwzh@gnu.org>
parents: 19770
diff changeset
1642 :prefix "huh"
0e8886335c4b (basic-faces): New group. Put the standard faces in it.
Karl Heuer <kwzh@gnu.org>
parents: 19770
diff changeset
1643 :group 'faces)
0e8886335c4b (basic-faces): New group. Put the standard faces in it.
Karl Heuer <kwzh@gnu.org>
parents: 19770
diff changeset
1644
17947
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1645 ;; Specify how these faces look, and their documentation.
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1646 (let ((all '((bold "Use bold font." ((t (:bold t))))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1647 (bold-italic "Use bold italic font." ((t (:bold t :italic t))))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1648 (italic "Use italic font." ((t (:italic t))))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1649 (underline "Underline text." ((t (:underline t))))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1650 (default "Used for text not covered by other faces." ((t nil)))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1651 (highlight "Highlight text in some way."
19114
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1652 ((((class color) (background light))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1653 (:background "darkseagreen2"))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1654 (((class color) (background dark))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1655 (:background "darkolivegreen"))
17947
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1656 (t (:inverse-video t))))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1657 (modeline "Used for displaying the modeline."
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1658 ((t (:inverse-video t))))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1659 (region "Used for displaying the region."
19114
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1660 ((((class color) (background dark))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1661 (:background "blue"))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1662 (t (:background "gray"))))
17947
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1663 (secondary-selection
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1664 "Used for displaying the secondary selection."
19114
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1665 ((((class color) (background light))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1666 (:background "paleturquoise"))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1667 (((class color) (background dark))
5e2c2c7ca25e Alternative colors for standard faces if dark background.
Richard M. Stallman <rms@gnu.org>
parents: 19098
diff changeset
1668 (:background "darkslateblue"))
17947
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1669 (t (:inverse-video t))))))
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1670 entry symbol doc spec)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1671 (while all
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1672 (setq entry (car all)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1673 all (cdr all)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1674 symbol (nth 0 entry)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1675 doc (nth 1 entry)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1676 spec (nth 2 entry))
20126
0e8886335c4b (basic-faces): New group. Put the standard faces in it.
Karl Heuer <kwzh@gnu.org>
parents: 19770
diff changeset
1677 (custom-add-to-group 'basic-faces symbol 'custom-face)
17947
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1678 (put symbol 'face-documentation doc)
057ea7eaaff3 Unconditionally create the standard faces at load time.
Richard M. Stallman <rms@gnu.org>
parents: 17945
diff changeset
1679 (put symbol 'face-defface-spec spec)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1680
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
1681 (provide 'faces)
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
1682
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1683 ;;; faces.el ends here