annotate lisp/specifier.el @ 408:501cfd01ee6d r21-2-34

Import from CVS: tag r21-2-34
author cvs
date Mon, 13 Aug 2007 11:18:11 +0200
parents 2f8bb876ab1d
children 697ef44129c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; specifier.el --- Lisp interface to specifiers
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
4 ;; Copyright (C) 1995, 1996, 2000 Ben Wing.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
6 ;; Author: Ben Wing <ben@xemacs.org>
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Keywords: internal, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9 ;;; Synched up with: Not in FSF.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;; Free Software Foundation, 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 (defun make-specifier-and-init (type spec-list &optional dont-canonicalize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 "Create and initialize a new specifier.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 This is a front-end onto `make-specifier' that allows you to create a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 specifier and add specs to it at the same time. TYPE specifies the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 specifier type. SPEC-LIST supplies the specification(s) to be added
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 to the specifier. Normally, almost any reasonable abbreviation of the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 full spec-list form is accepted, and is converted to the full form;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 however, if optional argument DONT-CANONICALIZE is non-nil, this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 conversion is not performed, and the SPEC-LIST must already be in full
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
44 form. See `canonicalize-spec-list'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 (let ((sp (make-specifier type)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 (if (not dont-canonicalize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47 (setq spec-list (canonicalize-spec-list spec-list type)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 (add-spec-list-to-specifier sp spec-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 sp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 ;; God damn, do I hate dynamic scoping.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 (defun map-specifier (ms-specifier ms-func &optional ms-locale ms-maparg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 "Apply MS-FUNC to the specification(s) for MS-LOCALE in MS-SPECIFIER.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 If MS-LOCALE is a locale, MS-FUNC will be called for that locale.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57 If MS-LOCALE is a locale type, MS-FUNC will be mapped over all locales
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 of that type. If MS-LOCALE is 'all or nil, MS-FUNC will be mapped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 over all locales in MS-SPECIFIER.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 MS-FUNC is called with four arguments: the MS-SPECIFIER, the locale
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 being mapped over, the inst-list for that locale, and the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 optional MS-MAPARG. If any invocation of MS-FUNC returns non-nil,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 the mapping will stop and the returned value becomes the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 value returned from `map-specifier'. Otherwise, `map-specifier'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 returns nil."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 (let ((ms-specs (specifier-spec-list ms-specifier ms-locale))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 ms-result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69 (while (and ms-specs (not ms-result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 (let ((ms-this-spec (car ms-specs)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71 (setq ms-result (funcall ms-func ms-specifier (car ms-this-spec)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 (cdr ms-this-spec) ms-maparg))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 (setq ms-specs (cdr ms-specs))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74 ms-result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 (defun canonicalize-inst-pair (inst-pair specifier-type &optional noerror)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
77 "Canonicalize the given INST-PAIR.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79 SPECIFIER-TYPE specifies the type of specifier that this SPEC-LIST
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 will be used for.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82 Canonicalizing means converting to the full form for an inst-pair, i.e.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
83 `(TAG-SET . INSTANTIATOR)'. A single, untagged instantiator is given
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
84 a tag set of nil (the empty set), and a single tag is converted into
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
85 a tag set consisting only of that tag.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 If NOERROR is non-nil, signal an error if the inst-pair is invalid;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 otherwise return t."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 ;; OK, the possibilities are:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 ;; a) a single instantiator
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92 ;; b) a cons of a tag and an instantiator
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93 ;; c) a cons of a tag set and an instantiator
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 (cond ((valid-instantiator-p inst-pair specifier-type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 ;; case (a)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (cons nil inst-pair))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 ((not (consp inst-pair))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99 ;; not an inst-pair
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100 (if noerror t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 ;; this will signal an appropriate error.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102 (check-valid-instantiator inst-pair specifier-type)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 ((and (valid-specifier-tag-p (car inst-pair))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 (valid-instantiator-p (cdr inst-pair) specifier-type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 ;; case (b)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 (cons (list (car inst-pair)) (cdr inst-pair)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 ((and (valid-specifier-tag-set-p (car inst-pair))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110 (valid-instantiator-p (cdr inst-pair) specifier-type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 ;; case (c)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112 inst-pair)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 (if noerror t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 (signal 'error (list "Invalid specifier tag set"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
117 (car inst-pair)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 (defun canonicalize-inst-list (inst-list specifier-type &optional noerror)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120 "Canonicalize the given INST-LIST (a list of inst-pairs).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
121
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 SPECIFIER-TYPE specifies the type of specifier that this INST-LIST
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 will be used for.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125 Canonicalizing means converting to the full form for an inst-list, i.e.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 `((TAG-SET . INSTANTIATOR) ...)'. This function accepts a single
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 inst-pair or any abbreviation thereof or a list of (possibly
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 abbreviated) inst-pairs. (See `canonicalize-inst-pair'.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 If NOERROR is non-nil, signal an error if the inst-list is invalid;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131 otherwise return t."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133 ;; OK, the possibilities are:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 ;; a) an inst-pair or various abbreviations thereof
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 ;; b) a list of (a)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 (let ((result (canonicalize-inst-pair inst-list specifier-type t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 (if (not (eq result t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 ;; case (a)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 (list result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 (if (not (consp inst-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143 ;; not an inst-list.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
144 (if noerror t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145 ;; this will signal an appropriate error.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (check-valid-instantiator inst-list specifier-type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 ;; case (b)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 (catch 'cann-inst-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 ;; don't use mapcar here; we need to catch the case of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 ;; an invalid list.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152 (let ((rest inst-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 (result nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 (while rest
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 (if (not (consp rest))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 (if noerror (throw 'cann-inst-list t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 (signal 'error (list "Invalid list format" inst-list)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158 (let ((res2 (canonicalize-inst-pair (car rest) specifier-type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 noerror)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160 (if (eq res2 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161 ;; at this point, we know we're noerror because
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162 ;; otherwise canonicalize-inst-pair would have
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163 ;; signalled an error.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
164 (throw 'cann-inst-list t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 (setq result (cons res2 result)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 (setq rest (cdr rest)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 (nreverse result)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 (defun canonicalize-spec (spec specifier-type &optional noerror)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 "Canonicalize the given SPEC (a specification).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172 SPECIFIER-TYPE specifies the type of specifier that this SPEC-LIST
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 will be used for.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
174
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
175 Canonicalizing means converting to the full form for a spec, i.e.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
176 `(LOCALE (TAG-SET . INSTANTIATOR) ...)'. This function accepts a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 possibly abbreviated inst-list or a cons of a locale and a possibly
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178 abbreviated inst-list. (See `canonicalize-inst-list'.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 If NOERROR is nil, signal an error if the specification is invalid;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181 otherwise return t."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182 ;; OK, the possibilities are:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184 ;; a) an inst-list or some abbreviation thereof
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185 ;; b) a cons of a locale and an inst-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 (let ((result (canonicalize-inst-list spec specifier-type t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 (if (not (eq result t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 ;; case (a)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 (cons 'global result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191 (if (not (consp spec))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192 ;; not a spec.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
193 (if noerror t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
194 ;; this will signal an appropriate error.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
195 (check-valid-instantiator spec specifier-type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 (if (not (valid-specifier-locale-p (car spec)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 ;; invalid locale.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 (if noerror t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200 (signal 'error (list "Invalid specifier locale" (car spec))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
202 ;; case (b)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 (let ((result (canonicalize-inst-list (cdr spec) specifier-type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204 noerror)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 (if (eq result t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
206 ;; at this point, we know we're noerror because
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 ;; otherwise canonicalize-inst-list would have
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 ;; signalled an error.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 (cons (car spec) result))))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 (defun canonicalize-spec-list (spec-list specifier-type &optional noerror)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 "Canonicalize the given SPEC-LIST (a list of specifications).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215 SPECIFIER-TYPE specifies the type of specifier that this SPEC-LIST
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 will be used for.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 Canonicalizing means converting to the full form for a spec-list, i.e.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219 `((LOCALE (TAG-SET . INSTANTIATOR) ...) ...)'. This function accepts
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
220 a possibly abbreviated specification or a list of such things. (See
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
221 `canonicalize-spec'.) This is the function used to convert spec-lists
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
222 accepted by `set-specifier' and such into a form suitable for
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
223 `add-spec-list-to-specifier'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
224
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
225 This function tries extremely hard to resolve any ambiguities,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226 and the built-in specifier types (font, image, toolbar, etc.) are
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
227 designed so that there won't be any ambiguities.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
228
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
229 If NOERROR is nil, signal an error if the spec-list is invalid;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
230 otherwise return t."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231 ;; OK, the possibilities are:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
232 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
233 ;; a) a spec or various abbreviations thereof
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
234 ;; b) a list of (a)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
235 (let ((result (canonicalize-spec spec-list specifier-type t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
236 (if (not (eq result t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
237 ;; case (a)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 (list result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240 (if (not (consp spec-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 ;; not a spec-list.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 (if noerror t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 ;; this will signal an appropriate error.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 (check-valid-instantiator spec-list specifier-type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 ;; case (b)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
247 (catch 'cann-spec-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248 ;; don't use mapcar here; we need to catch the case of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
249 ;; an invalid list.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
250 (let ((rest spec-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
251 (result nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252 (while rest
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253 (if (not (consp rest))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254 (if noerror (throw 'cann-spec-list t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 (signal 'error (list "Invalid list format" spec-list)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256 (let ((res2 (canonicalize-spec (car rest) specifier-type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257 noerror)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 (if (eq res2 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
259 ;; at this point, we know we're noerror because
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260 ;; otherwise canonicalize-spec would have
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
261 ;; signalled an error.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
262 (throw 'cann-spec-list t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
263 (setq result (cons res2 result)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
264 (setq rest (cdr rest)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
265 (nreverse result)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
266
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267 (defun set-specifier (specifier value &optional locale tag-set how-to-add)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268 "Add a specification or specifications to SPECIFIER.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 This function adds a specification of VALUE in locale LOCALE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271 LOCALE indicates where this specification is active, and should be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272 a buffer, a window, a frame, a device, or the symbol `global' to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273 indicate that it applies everywhere. LOCALE usually defaults to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 `global' if omitted.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
276 VALUE is usually what is called an \"instantiator\" (which, roughly
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
277 speaking, corresponds to the \"value\" of the property governed by
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
278 SPECIFIER). The valid instantiators for SPECIFIER depend on the type
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
279 of SPECIFIER (which you can determine using `specifier-type'). The
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
280 specifier `scrollbar-width', for example, is of type `integer',
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
281 meaning its valid instantiators are integers. The specifier governing
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
282 the background color of the `default' face (you can retrieve this
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
283 specifier using `(face-background 'default)') is of type `color',
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
284 meaning its valid instantiators are strings naming colors and
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
285 color-instance objects. For some types of specifiers, such as `image'
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
286 and `toolbar', the instantiators can be very complex. Generally this
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
287 is documented in the appropriate creation function --
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
288 e.g. `make-color-specifier', `make-font-specifier',
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
289 `make-image-specifier' -- or in the global variable holding the most
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
290 common specifier for that type (`default-toolbar', `default-gutter',
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
291 `current-display-table').
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
292
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 NOTE: It does *not* work to give a VALUE of nil as a way of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 removing the specifications for a locale. Use `remove-specifier'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 instead. (And keep in mind that, if you omit the LOCALE argument
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
296 to `remove-specifier', it removes *all* specifications! If you
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 want to remove just the `global' specification, make sure to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 specify a LOCALE of `global'.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
299
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
300 VALUE can also be a list of instantiators. This means basically,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301 \"try each one in turn until you get one that works\". This allows
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302 you to give funky instantiators that may only work in some cases,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 and provide more normal backups for the other cases. (For example,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 you might like the color \"darkseagreen2\", but some X servers
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 don't recognize this color, so you could provide a backup
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
306 \"forest green\". Color TTY devices probably won't recognize this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307 either, so you could provide a second backup \"green\". You'd
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
308 do this by specifying this list of instantiators:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
309
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310 '(\"darkseagreen2\" \"forest green\" \"green\")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 VALUE can also be various more complicated forms; see below.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
313
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 Optional argument TAG-SET is a tag or a list of tags, to be associated
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315 with the VALUE. Tags are symbols (usually naming device types, such
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316 as `x' and `tty', or device classes, such as `color', `mono', and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 `grayscale'); specifying a TAG-SET restricts the scope of VALUE to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 devices that match all specified tags. (You can also create your
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
319 own tags using `define-specifier-tag', and use them to identify
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 specifications added by you, so you can remove them later.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
321
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
322 Optional argument HOW-TO-ADD should be either nil or one of the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
323 symbols `prepend', `append', `remove-tag-set-prepend',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 `remove-tag-set-append', `remove-locale', `remove-locale-type',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 or `remove-all'. This specifies what to do with existing
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326 specifications in LOCALE (and possibly elsewhere in the specifier).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 Most of the time, you do not need to worry about this argument;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 the default behavior of `remove-tag-set-prepend' is usually fine.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329 See `copy-specifier' and `add-spec-to-specifier' for a full
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
330 description of what each of these means.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
331
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332 VALUE can actually be anything acceptable to `canonicalize-spec-list';
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 this includes, among other things:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335 -- a cons of a locale and an instantiator (or list of instantiators)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336 -- a cons of a tag or tag-set and an instantiator (or list of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337 instantiators)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
338 -- a cons of a locale and the previous type of item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
339 -- a list of one or more of any of the previous types of items
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
340
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
341 However, in these cases, you cannot give a LOCALE or TAG-SET,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
342 because they do not make sense. (You will probably get an error if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
343 you try this.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
344
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
345 Finally, VALUE can itself be a specifier (of the same type as
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
346 SPECIFIER), if you want to copy specifications from one specifier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
347 to another; this is equivalent to calling `copy-specifier', and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
348 LOCALE, TAG-SET, and HOW-TO-ADD have the same semantics as with
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
349 that function.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
350
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
351 Note that `set-specifier' is exactly complementary to `specifier-specs'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
352 except in the case where SPECIFIER has no specs at all in it but nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
353 is a valid instantiator (in that case, `specifier-specs' will return
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
354 nil (meaning no specs) and `set-specifier' will interpret the `nil'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
355 as meaning \"I'm adding a global instantiator and its value is `nil'\"),
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
356 or in strange cases where there is an ambiguity between a spec-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
357 and an inst-list, etc. (The built-in specifier types are designed
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
358 in such a way as to avoid any such ambiguities.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
359
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 NOTE: If you want to work with spec-lists, you should probably not
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
361 use either `set-specifier' or `specifier-specs', but should use the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362 lower-level functions `add-spec-list-to-specifier' and `specifier-spec-list'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 These functions always work with fully-qualified spec-lists; thus, there
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364 is no possibility for ambiguity and no need to go through the function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365 `canonicalize-spec-list', which is potentially time-consuming."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 ;; backward compatibility: the old function had HOW-TO-ADD as the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368 ;; third argument and no arguments after that.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
369 ;; #### this should disappear at some point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
370 (if (and (null how-to-add)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
371 (memq locale '(prepend append remove-tag-set-prepend
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
372 remove-tag-set-append remove-locale
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
373 remove-locale-type remove-all)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
374 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
375 (setq how-to-add locale)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
376 (setq locale nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
377
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
378 ;; proper beginning of the function.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
379 (let ((is-valid (valid-instantiator-p value (specifier-type specifier)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
380 (nval value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
381 (cond ((and (not is-valid) (specifierp nval))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
382 (copy-specifier nval specifier locale tag-set nil how-to-add))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384 (if tag-set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 (if (not (listp tag-set))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 (setq tag-set (list tag-set)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 ;; You tend to get more accurate errors
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 ;; for a variety of cases if you call
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390 ;; canonicalize-tag-set here.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391 (setq tag-set (canonicalize-tag-set tag-set))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 (if (and (not is-valid) (consp nval))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393 (setq nval
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394 (mapcar #'(lambda (x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395 (check-valid-instantiator
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 x (specifier-type specifier))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 (cons tag-set x))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 nval))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399 (setq nval (cons tag-set nval)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400 (if locale
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401 (setq nval (cons locale nval)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
402 (add-spec-list-to-specifier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 specifier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404 (canonicalize-spec-list nval (specifier-type specifier))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405 how-to-add))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
406 value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
407
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
408 (defun modify-specifier-instances (specifier func &optional args force default
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
409 locale tag-set)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
410 "Modify all specifications that match LOCALE and TAG-SET by FUNC.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
411
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
412 For each specification that exists for SPECIFIER, in locale LOCALE
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
413 that matches TAG-SET, call the function FUNC with the instance as its
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
414 first argument and with optional arguments ARGS. The result is then
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
415 used as the new value of the instantiator.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
416
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
417 If there is no specification in the domain LOCALE matching TAG-SET and
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
418 FORCE is non-nil, an explicit one is created from the matching
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
419 specifier instance if that exists or DEFAULT otherwise. If LOCALE is
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
420 not a domain (i.e. a buffer), DEFAULT is always used. FUNC is then
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
421 applied like above and the resulting specification is added."
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
422
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
423 (let ((spec-list (specifier-spec-list specifier locale tag-set)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
424 (cond
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
425 (spec-list
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
426 ;; Destructively edit the spec-list
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
427 (mapc #'(lambda (spec)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
428 (mapc #'(lambda (inst-pair)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
429 (setcdr inst-pair
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
430 (apply func (cdr inst-pair) args)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
431 (cdr spec)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
432 spec-list)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
433 (add-spec-list-to-specifier specifier spec-list))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
434 (force
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
435 (set-specifier specifier
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
436 (apply func
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
437 (or (and (valid-specifier-domain-p locale)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
438 (specifier-instance specifier))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
439 default) args)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
440 locale tag-set)))))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 298
diff changeset
441
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
442 (defmacro let-specifier (specifier-list &rest body)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
443 "Add specifier specs, evaluate forms in BODY and restore the specifiers.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
444 \(let-specifier SPECIFIER-LIST BODY...)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
445
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
446 Each element of SPECIFIER-LIST should look like this:
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
447 \(SPECIFIER VALUE &optional LOCALE TAG-SET HOW-TO-ADD).
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 263
diff changeset
448
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
449 SPECIFIER is the specifier to be temporarily modified. VALUE is the
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
450 instantiator to be temporarily added to SPECIFIER in LOCALE. LOCALE,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
451 TAG-SET and HOW-TO-ADD have the same meaning as in
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
452 `add-spec-to-specifier'.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
453
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
454 The code resulting from macro expansion will add specifications to
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
455 specifiers using `add-spec-to-specifier'. After BODY is finished, the
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
456 temporary specifications are removed and old spec-lists are restored.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
457
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
458 LOCALE, TAG-SET and HOW-TO-ADD may be omitted, and default to nil.
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
459 The value of the last form in BODY is returned.
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
460
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
461 NOTE: If you want the specifier's instance to change in all
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
462 circumstances, use (selected-window) as the LOCALE. If LOCALE is nil
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
463 or omitted, it defaults to `global'.
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
464
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
465 Example:
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
466 (let-specifier ((modeline-shadow-thickness 0 (selected-window)))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
467 (sit-for 1))"
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
468 (check-argument-type 'listp specifier-list)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
469 (flet ((gensym-frob (x name)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
470 (if (or (atom x) (eq (car x) 'quote))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
471 (list x)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
472 (list (gensym name) x))))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
473 ;; VARLIST is a list of
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
474 ;; ((SPECIFIERSYM SPECIFIER) (VALUE) (LOCALESYM LOCALE)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
475 ;; (TAG-SET) (HOW-TO-ADD))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
476 ;; If any of these is an atom, then a separate symbol is
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
477 ;; unnecessary, the CAR will contain the atom and CDR will be nil.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
478 (let* ((varlist (mapcar #'(lambda (listel)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
479 (or (and (consp listel)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
480 (<= (length listel) 5)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
481 (> (length listel) 1))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
482 (signal 'error
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
483 (list
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
484 "should be a list of 2-5 elements"
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
485 listel)))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
486 ;; VALUE, TAG-SET and HOW-TO-ADD are
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
487 ;; referenced only once, so we needn't
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
488 ;; frob them with gensym.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
489 (list (gensym-frob (nth 0 listel) "specifier-")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
490 (list (nth 1 listel))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
491 (gensym-frob (nth 2 listel) "locale-")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
492 (list (nth 3 listel))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
493 (list (nth 4 listel))))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
494 specifier-list))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
495 ;; OLDVALLIST is a list of (OLDVALSYM OLDVALFORM)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
496 (oldvallist (mapcar #'(lambda (varel)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
497 (list (gensym "old-")
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
498 `(specifier-spec-list
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
499 ,(car (nth 0 varel))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
500 ,(car (nth 2 varel)))))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
501 varlist)))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
502 ;; Bind the appropriate variables.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
503 `(let* (,@(mapcan #'(lambda (varel)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
504 (delq nil (mapcar
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
505 #'(lambda (varcons)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
506 (and (cdr varcons) varcons))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
507 varel)))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
508 varlist)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
509 ,@oldvallist)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
510 (unwind-protect
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
511 (progn
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
512 ,@(mapcar #'(lambda (varel)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
513 `(add-spec-to-specifier
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
514 ,(car (nth 0 varel)) ,(car (nth 1 varel))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
515 ,(car (nth 2 varel)) ,(car (nth 3 varel))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
516 ,(car (nth 4 varel))))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
517 varlist)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
518 ,@body)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
519 ;; Reverse the unwinding order, so that using the same
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
520 ;; specifier multiple times works.
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
521 ,@(apply #'nconc (nreverse (mapcar*
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
522 #'(lambda (oldval varel)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
523 `((remove-specifier
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
524 ,(car (nth 0 varel))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
525 ,(car (nth 2 varel)))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
526 (add-spec-list-to-specifier
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
527 ,(car (nth 0 varel))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
528 ,(car oldval))))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
529 oldvallist varlist))))))))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 263
diff changeset
530
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
531 (defun make-integer-specifier (spec-list)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
532 "Return a new `integer' specifier object with the given specification list.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
533 SPEC-LIST can be a list of specifications (each of which is a cons of a
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
534 locale and a list of instantiators), a single instantiator, or a list
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
535 of instantiators. See `make-specifier' for more information about
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
536 specifiers.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
537
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
538 Valid instantiators for integer specifiers are integers."
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
539 (make-specifier-and-init 'integer spec-list))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
540
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
541 (defun make-boolean-specifier (spec-list)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
542 "Return a new `boolean' specifier object with the given specification list.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
543 SPEC-LIST can be a list of specifications (each of which is a cons of a
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
544 locale and a list of instantiators), a single instantiator, or a list
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
545 of instantiators. See `make-specifier' for more information about
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
546 specifiers.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
547
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
548 Valid instantiators for boolean specifiers are t and nil."
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
549 (make-specifier-and-init 'boolean spec-list))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
550
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
551 (defun make-natnum-specifier (spec-list)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
552 "Return a new `natnum' specifier object with the given specification list.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
553 SPEC-LIST can be a list of specifications (each of which is a cons of a
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
554 locale and a list of instantiators), a single instantiator, or a list
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
555 of instantiators. See `make-specifier' for more information about
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
556 specifiers.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
557
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
558 Valid instantiators for natnum specifiers are non-negative integers."
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
559 (make-specifier-and-init 'natnum spec-list))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
560
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
561 (defun make-generic-specifier (spec-list)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
562 "Return a new `generic' specifier object with the given specification list.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
563 SPEC-LIST can be a list of specifications (each of which is a cons of a
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
564 locale and a list of instantiators), a single instantiator, or a list
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
565 of instantiators. See `make-specifier' for more information about
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
566 specifiers.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
567
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
568 Valid instantiators for generic specifiers are all Lisp values.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
569 They are returned back unchanged when a specifier is instantiated."
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
570 (make-specifier-and-init 'generic spec-list))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
571
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
572 (defun make-display-table-specifier (spec-list)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
573 "Return a new `display-table' specifier object with the given spec list.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
574 SPEC-LIST can be a list of specifications (each of which is a cons of a
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
575 locale and a list of instantiators), a single instantiator, or a list
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
576 of instantiators. See `make-specifier' for more information about
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
577 specifiers.
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
578
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
579 Valid instantiators for display-table specifiers are described in
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
580 detail in the doc string for `current-display-table'."
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
581 (make-specifier-and-init 'display-table spec-list))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 404
diff changeset
582
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
583 ;; Evaluate this for testing:
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
584 ; (cl-prettyexpand '(let-specifier ((modeline-shadow-thickness 0 (selected-window) 'x) (fubar (value) baz)) (sit-for 1)))
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
585
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
586 (define-specifier-tag 'win 'device-on-window-system-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
587
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
588 ;; Add tags for device types that don't have support compiled
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
589 ;; into the binary that we're about to dump. This will prevent
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
590 ;; code like
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
591 ;;
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
592 ;; (set-face-foreground 'default "black" nil '(x color))
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
593 ;;
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
594 ;; from producing an error if no X support was compiled in.
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
595
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
596 (or (valid-specifier-tag-p 'x)
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
597 (define-specifier-tag 'x (lambda (dev) (eq (device-type dev) 'x))))
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
598 (or (valid-specifier-tag-p 'tty)
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
599 (define-specifier-tag 'tty (lambda (dev) (eq (device-type dev) 'tty))))
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
600 (or (valid-specifier-tag-p 'mswindows)
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
601 (define-specifier-tag 'mswindows (lambda (dev)
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
602 (eq (device-type dev) 'mswindows))))
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
603
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
604 ;; Add special tag for use by initialization code. Code that
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
605 ;; sets up default specs should use this tag. Code that needs to
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
606 ;; override default specs (e.g. the X resource initialization
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
607 ;; code) can safely clear specs with this tag without worrying
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
608 ;; about clobbering user settings.
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
609
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
610 (define-specifier-tag 'default)
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 211
diff changeset
611
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
612 ;;; specifier.el ends here