annotate lisp/specifier.el @ 209:41ff10fd062f r20-4b3

Import from CVS: tag r20-4b3
author cvs
date Mon, 13 Aug 2007 10:04:58 +0200
parents
children 78478c60bfcd
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.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6 ;; Author: Ben Wing <wing@666.com>
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
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
278 SPECIFIER). The valid instantiators for SPECIFIER depend on the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
279 type of SPECIFIER (which you can determine using `specifier-type').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
280 The specifier `scrollbar-width', for example, is of type `integer',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
281 meaning its valid instantiators are integers. The specifier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282 governing the background color of the `default' face (you can
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 retrieve this specifier using `(face-background 'default)') is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284 of type `color', meaning its valid instantiators are strings naming
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 colors and color-instance objects. For some types of specifiers,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286 such as `image' and `toolbar', the instantiators can be very
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287 complex. Generally this is documented in the appropriate predicate
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
288 function -- `color-specifier-p', `image-specifier-p',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
289 `toolbar-specifier-p', etc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291 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
292 removing the specifications for a locale. Use `remove-specifier'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 instead. (And keep in mind that, if you omit the LOCALE argument
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 to `remove-specifier', it removes *all* specifications! If you
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 want to remove just the `global' specification, make sure to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
296 specify a LOCALE of `global'.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 VALUE can also be a list of instantiators. This means basically,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
299 \"try each one in turn until you get one that works\". This allows
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
300 you to give funky instantiators that may only work in some cases,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301 and provide more normal backups for the other cases. (For example,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302 you might like the color \"darkseagreen2\", but some X servers
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 don't recognize this color, so you could provide a backup
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 \"forest green\". Color TTY devices probably won't recognize this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 either, so you could provide a second backup \"green\". You'd
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
306 do this by specifying this list of instantiators:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
308 '(\"darkseagreen2\" \"forest green\" \"green\")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
309
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310 VALUE can also be various more complicated forms; see below.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 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
313 with the VALUE. Tags are symbols (usually naming device types, such
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 as `x' and `tty', or device classes, such as `color', `mono', and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315 `grayscale'); specifying a TAG-SET restricts the scope of VALUE to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316 devices that match all specified tags. (You can also create your
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 own tags using `define-specifier-tag', and use them to identify
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 specifications added by you, so you can remove them later.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
319
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 Optional argument HOW-TO-ADD should be either nil or one of the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
321 symbols `prepend', `append', `remove-tag-set-prepend',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
322 `remove-tag-set-append', `remove-locale', `remove-locale-type',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
323 or `remove-all'. This specifies what to do with existing
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 specifications in LOCALE (and possibly elsewhere in the specifier).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 Most of the time, you do not need to worry about this argument;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326 the default behavior of `remove-tag-set-prepend' is usually fine.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 See `copy-specifier' and `add-spec-to-specifier' for a full
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 description of what each of these means.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
330 VALUE can actually be anything acceptable to `canonicalize-spec-list';
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
331 this includes, among other things:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 -- a cons of a locale and an instantiator (or list of instantiators)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334 -- 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
335 instantiators)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336 -- a cons of a locale and the previous type of item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337 -- 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
338
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
339 However, in these cases, you cannot give a LOCALE or TAG-SET,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
340 because they do not make sense. (You will probably get an error if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
341 you try this.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
342
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
343 Finally, VALUE can itself be a specifier (of the same type as
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
344 SPECIFIER), if you want to copy specifications from one specifier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
345 to another; this is equivalent to calling `copy-specifier', and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
346 LOCALE, TAG-SET, and HOW-TO-ADD have the same semantics as with
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
347 that function.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
348
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
349 Note that `set-specifier' is exactly complementary to `specifier-specs'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
350 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
351 is a valid instantiator (in that case, `specifier-specs' will return
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
352 nil (meaning no specs) and `set-specifier' will interpret the `nil'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
353 as meaning \"I'm adding a global instantiator and its value is `nil'\"),
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
354 or in strange cases where there is an ambiguity between a spec-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
355 and an inst-list, etc. (The built-in specifier types are designed
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
356 in such a way as to avoid any such ambiguities.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
357
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
358 NOTE: If you want to work with spec-lists, you should probably not
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
359 use either `set-specifier' or `specifier-specs', but should use the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 lower-level functions `add-spec-list-to-specifier' and `specifier-spec-list'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
361 These functions always work with fully-qualified spec-lists; thus, there
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362 is no possibility for ambiguity and no need to go through the function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 `canonicalize-spec-list', which is potentially time-consuming."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365 ;; backward compatibility: the old function had HOW-TO-ADD as the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366 ;; third argument and no arguments after that.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 ;; #### this should disappear at some point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368 (if (and (null how-to-add)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
369 (memq locale '(prepend append remove-tag-set-prepend
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
370 remove-tag-set-append remove-locale
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
371 remove-locale-type remove-all)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
372 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
373 (setq how-to-add locale)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
374 (setq locale nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
375
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
376 ;; proper beginning of the function.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
377 (let ((is-valid (valid-instantiator-p value (specifier-type specifier)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
378 (nval value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
379 (cond ((and (not is-valid) (specifierp nval))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
380 (copy-specifier nval specifier locale tag-set nil how-to-add))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
381 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
382 (if tag-set
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384 (if (not (listp tag-set))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 (setq tag-set (list tag-set)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 ;; You tend to get more accurate errors
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 ;; for a variety of cases if you call
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 ;; canonicalize-tag-set here.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 (setq tag-set (canonicalize-tag-set tag-set))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390 (if (and (not is-valid) (consp nval))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391 (setq nval
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 (mapcar #'(lambda (x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393 (check-valid-instantiator
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394 x (specifier-type specifier))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395 (cons tag-set x))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 nval))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 (setq nval (cons tag-set nval)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 (if locale
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399 (setq nval (cons locale nval)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400 (add-spec-list-to-specifier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401 specifier
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
402 (canonicalize-spec-list nval (specifier-type specifier))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 how-to-add))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404 value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
406 (define-specifier-tag 'win 'device-on-window-system-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
407
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
408 ;;; specifier.el ends here