Mercurial > emacs
annotate lisp/cus-face.el @ 18199:15177bdb2fcf
(describe-coding-system): Change format of output.
(describe-current-coding-system-briefly): Likewise.
(describe-current-coding-system): Likewise.
(print-coding-system-briefly): Likewise.
(print-coding-system): Likewise.
(list-coding-systems): Likewise. Make it interactive.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 10 Jun 1997 00:56:19 +0000 |
parents | 2b225f00d308 |
children | 34f1f8c5eda3 |
rev | line source |
---|---|
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
1 ;;; cus-face.el -- customization support for faces. |
17334 | 2 ;; |
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. | |
4 ;; | |
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | |
6 ;; Keywords: help, faces | |
17568
65f85125b4f2
Changed version number.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17567
diff
changeset
|
7 ;; Version: Emacs |
17334 | 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ |
9 | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
11 |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
15 ;; any later version. |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
16 |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
20 ;; GNU General Public License for more details. |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
21 |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
25 ;; Boston, MA 02111-1307, USA. |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
26 |
17334 | 27 ;;; Commentary: |
28 ;; | |
29 ;; See `custom.el'. | |
30 | |
31 ;;; Code: | |
32 | |
17856
1e5f1a1f0db3
(custom-facep): Defined (once again).
Richard M. Stallman <rms@gnu.org>
parents:
17568
diff
changeset
|
33 (defalias 'custom-facep |
1e5f1a1f0db3
(custom-facep): Defined (once again).
Richard M. Stallman <rms@gnu.org>
parents:
17568
diff
changeset
|
34 (if (fboundp 'facep) 'facep |
1e5f1a1f0db3
(custom-facep): Defined (once again).
Richard M. Stallman <rms@gnu.org>
parents:
17568
diff
changeset
|
35 '(lambda (face) nil))) |
1e5f1a1f0db3
(custom-facep): Defined (once again).
Richard M. Stallman <rms@gnu.org>
parents:
17568
diff
changeset
|
36 |
17334 | 37 ;;; Declaring a face. |
38 | |
39 ;;;###autoload | |
40 (defun custom-declare-face (face spec doc &rest args) | |
41 "Like `defface', but FACE is evaluated as a normal argument." | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
42 (unless (get face 'face-defface-spec) |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
43 (put face 'face-defface-spec spec) |
17334 | 44 (when (fboundp 'facep) |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
45 (unless (facep face) |
17334 | 46 ;; If the user has already created the face, respect that. |
47 (let ((value (or (get face 'saved-face) spec)) | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
48 (frames (frame-list)) |
17334 | 49 frame) |
50 ;; Create global face. | |
51 (make-empty-face face) | |
52 ;; Create frame local faces | |
53 (while frames | |
54 (setq frame (car frames) | |
55 frames (cdr frames)) | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
56 (face-spec-set face value frame))))) |
17334 | 57 (when (and doc (null (face-doc-string face))) |
58 (set-face-doc-string face doc)) | |
59 (custom-handle-all-keywords face args 'custom-face) | |
60 (run-hooks 'custom-define-hook)) | |
61 face) | |
62 | |
63 ;;; Font Attributes. | |
64 | |
65 (defconst custom-face-attributes | |
17567
71dfc9f61821
*** empty log message ***
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17524
diff
changeset
|
66 '((:bold (toggle :format "%[Bold%]: %v\n" |
17334 | 67 :help-echo "Control whether a bold font should be used.") |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
68 set-face-bold-p |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
69 face-bold-p) |
17567
71dfc9f61821
*** empty log message ***
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17524
diff
changeset
|
70 (:italic (toggle :format "%[Italic%]: %v\n" |
17334 | 71 :help-echo "\ |
72 Control whether an italic font should be used.") | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
73 set-face-italic-p |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
74 face-italic-p) |
17567
71dfc9f61821
*** empty log message ***
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17524
diff
changeset
|
75 (:underline (toggle :format "%[Underline%]: %v\n" |
17334 | 76 :help-echo "\ |
77 Control whether the text should be underlined.") | |
78 set-face-underline-p | |
79 face-underline-p) | |
17946
2b225f00d308
(custom-face-attributes): Add :inverse-video.
Richard M. Stallman <rms@gnu.org>
parents:
17856
diff
changeset
|
80 (:inverse-video (toggle :format "%[Inverse-Video%]: %v\n" |
2b225f00d308
(custom-face-attributes): Add :inverse-video.
Richard M. Stallman <rms@gnu.org>
parents:
17856
diff
changeset
|
81 :help-echo "\ |
2b225f00d308
(custom-face-attributes): Add :inverse-video.
Richard M. Stallman <rms@gnu.org>
parents:
17856
diff
changeset
|
82 Control whether the text should be in inverse video.") |
2b225f00d308
(custom-face-attributes): Add :inverse-video.
Richard M. Stallman <rms@gnu.org>
parents:
17856
diff
changeset
|
83 set-face-inverse-video-p |
2b225f00d308
(custom-face-attributes): Add :inverse-video.
Richard M. Stallman <rms@gnu.org>
parents:
17856
diff
changeset
|
84 face-inverse-video-p) |
17334 | 85 (:foreground (color :tag "Foreground" |
86 :value "black" | |
87 :help-echo "Set foreground color.") | |
88 set-face-foreground | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
89 face-foreground) |
17334 | 90 (:background (color :tag "Background" |
91 :value "white" | |
92 :help-echo "Set background color.") | |
93 set-face-background | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
94 face-background) |
17334 | 95 (:stipple (editable-field :format "Stipple: %v" |
96 :help-echo "Name of background bitmap file.") | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
97 set-face-stipple |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
98 face-stipple)) |
17334 | 99 "Alist of face attributes. |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
100 The elements are of the form (KEY TYPE SET GET), |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
101 where KEY is the name of the attribute, |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
102 TYPE is a widget type for editing the attibute, |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
103 SET is a function for setting the attribute value, |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
104 and GET is a function for getiing the attribute value. |
17334 | 105 |
106 The SET function should take three arguments, the face to modify, the | |
107 value of the attribute, and optionally the frame where the face should | |
108 be changed. | |
109 | |
110 The GET function should take two arguments, the face to examine, and | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
111 optionally the frame where the face should be examined.") |
17334 | 112 |
113 (defun custom-face-attributes-get (face frame) | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
114 "For FACE on FRAME, return an alternating list describing its attributes. |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
115 The list has the form (KEYWORD VALUE KEYWORD VALUE...). |
17334 | 116 Each keyword should be listed in `custom-face-attributes'. |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
117 We include only those attributes that differ from the default face. |
17334 | 118 |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
119 If FRAME is nil, use the global defaults for FACE." |
17334 | 120 (let ((atts custom-face-attributes) |
121 att result get) | |
122 (while atts | |
123 (setq att (car atts) | |
124 atts (cdr atts) | |
125 get (nth 3 att)) | |
126 (when get | |
127 (let ((answer (funcall get face frame))) | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
128 (if (and (not (equal answer (funcall get 'default frame))) |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
129 (widget-apply (nth 1 att) :match answer)) |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
130 (setq result (cons (nth 0 att) (cons answer result))))))) |
17334 | 131 result)) |
132 | |
133 ;;; Initializing. | |
134 | |
135 ;;;###autoload | |
136 (defun custom-set-faces (&rest args) | |
137 "Initialize faces according to user preferences. | |
138 The arguments should be a list where each entry has the form: | |
139 | |
140 (FACE SPEC [NOW]) | |
141 | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
142 SPEC is stored as the saved value for FACE. |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
143 If NOW is present and non-nil, FACE is created now, according to SPEC. |
17334 | 144 |
145 See `defface' for the format of SPEC." | |
146 (while args | |
147 (let ((entry (car args))) | |
148 (if (listp entry) | |
149 (let ((face (nth 0 entry)) | |
150 (spec (nth 1 entry)) | |
151 (now (nth 2 entry))) | |
152 (put face 'saved-face spec) | |
153 (when now | |
154 (put face 'force-face t)) | |
17524
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
155 (when (or now (facep face)) |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
156 (make-empty-face face) |
8ba505704d9d
Major simplification; most of file contents deleted.
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
157 (face-spec-set face spec)) |
17334 | 158 (setq args (cdr args))) |
159 ;; Old format, a plist of FACE SPEC pairs. | |
160 (let ((face (nth 0 args)) | |
161 (spec (nth 1 args))) | |
162 (put face 'saved-face spec)) | |
163 (setq args (cdr (cdr args))))))) | |
164 | |
165 ;;; The End. | |
166 | |
167 (provide 'cus-face) | |
168 | |
169 ;; cus-face.el ends here |