Mercurial > hg > xemacs-beta
comparison lisp/find-paths.el @ 2481:505a24c07ba9
[xemacs-hg @ 2005-01-15 15:17:32 by michaels]
2005-01-08 Mike Sperber <mike@xemacs.org>
* packages.el (packages-find-installation-package-directories): Add.
* find-paths.el (paths-for-each-emacs-directory): Abstract FUNC
parameter out of `paths-find-emacs-directory'.
(paths-find-emacs-directories): Add.
(paths-find-emacs-directory): Redefine in terms of
`paths-for-each-emacs-directory'.
(paths-for-each-site-directory): Add.
(paths-find-site-directory): Redefine in terms of
`paths-for-each-site-directory'.
(paths-find-site-directories): Add.
(paths-for-each-version-directory): Add.
(paths-find-version-directory): Redefine in terms of
`paths-for-each-version-directory'.
(paths-find-version-directories): Add.
author | michaels |
---|---|
date | Sat, 15 Jan 2005 15:17:36 +0000 |
parents | f4e405a9d18d |
children | a452d2a78a4e |
comparison
equal
deleted
inserted
replaced
2480:6acae43a57f1 | 2481:505a24c07ba9 |
---|---|
134 (concat | 134 (concat |
135 (file-name-as-directory root) | 135 (file-name-as-directory root) |
136 suffix | 136 suffix |
137 base)))) | 137 base)))) |
138 | 138 |
139 (defun paths-find-emacs-directory (roots suffix base | 139 |
140 &optional envvar default keep-suffix) | 140 (defun paths-for-each-emacs-directory (func |
141 "Find a directory in the XEmacs hierarchy. | 141 roots suffix base |
142 &optional envvar default keep-suffix) | |
143 "Iterate over directories in the XEmacs hierarchy. | |
144 FUNC is a function that called for each directory, with the directory | |
145 as the only argument. | |
142 ROOTS must be a list of installation roots. | 146 ROOTS must be a list of installation roots. |
143 SUFFIX is the subdirectory from there. | 147 SUFFIX is the subdirectory from there. |
144 BASE is the base to look for. | 148 BASE is the base to look for. |
145 ENVVAR is the name of the environment variable that might also | 149 ENVVAR is the name of the environment variable that might also |
146 specify the directory. | 150 specify the directory. |
150 (let ((preferred-value (or (and envvar (getenv envvar)) | 154 (let ((preferred-value (or (and envvar (getenv envvar)) |
151 default))) | 155 default))) |
152 (if (and preferred-value | 156 (if (and preferred-value |
153 (paths-file-readable-directory-p preferred-value)) | 157 (paths-file-readable-directory-p preferred-value)) |
154 (file-name-as-directory preferred-value) | 158 (file-name-as-directory preferred-value) |
155 (catch 'gotcha | 159 (while roots |
156 (while roots | 160 (let* ((root (car roots)) |
157 (let* ((root (car roots)) | 161 ;; installed |
158 ;; installed | 162 (path (paths-construct-emacs-directory root suffix base))) |
159 (path (paths-construct-emacs-directory root suffix base))) | 163 (if (paths-file-readable-directory-p path) |
160 (if (paths-file-readable-directory-p path) | 164 (funcall func path) |
161 (throw 'gotcha path) | 165 ;; in-place |
162 ;; in-place | 166 (if (null keep-suffix) |
163 (if (null keep-suffix) | 167 (let ((path (paths-construct-emacs-directory root "" base))) |
164 (let ((path (paths-construct-emacs-directory root "" base))) | 168 (if (paths-file-readable-directory-p path) |
165 (if (paths-file-readable-directory-p path) | 169 (funcall func path)))))) |
166 (throw 'gotcha path)))))) | 170 (setq roots (cdr roots)))))) |
167 (setq roots (cdr roots))) | 171 |
168 nil)))) | 172 (defun paths-find-emacs-directories (roots |
173 suffix base | |
174 &optional envvar default keep-suffix) | |
175 "Find a list of directories in the XEmacs hierarchy. | |
176 ROOTS must be a list of installation roots. | |
177 SUFFIX is the subdirectory from there. | |
178 BASE is the base to look for. | |
179 ENVVAR is the name of the environment variable that might also | |
180 specify the directory. | |
181 DEFAULT is the preferred value. | |
182 If KEEP-SUFFIX is non-nil, the suffix must be respected in searching | |
183 the directory." | |
184 (let ((l '())) | |
185 (paths-for-each-emacs-directory #'(lambda (dir) | |
186 (setq l (cons dir l))) | |
187 roots | |
188 suffix base | |
189 envvar default keep-suffix) | |
190 (reverse l))) | |
191 | |
192 (defun paths-find-emacs-directory (roots suffix base | |
193 &optional envvar default keep-suffix) | |
194 "Find a directory in the XEmacs hierarchy. | |
195 ROOTS must be a list of installation roots. | |
196 SUFFIX is the subdirectory from there. | |
197 BASE is the base to look for. | |
198 ENVVAR is the name of the environment variable that might also | |
199 specify the directory. | |
200 DEFAULT is the preferred value. | |
201 If KEEP-SUFFIX is non-nil, the suffix must be respected in searching | |
202 the directory." | |
203 (catch 'gotcha | |
204 (paths-for-each-emacs-directory #'(lambda (dir) | |
205 (throw 'gotcha dir)) | |
206 roots | |
207 suffix base | |
208 envvar default keep-suffix))) | |
209 | |
210 (defun paths-for-each-site-directory (func roots base &optional envvar default) | |
211 "Iterate over the site-specific directories in the XEmacs hierarchy. | |
212 FUNC is a function that called for each directory, with the directory | |
213 as the only argument. | |
214 ROOT must be a an installation root. | |
215 BASE is the base to look for. | |
216 ENVVAR is the name of the environment variable that might also | |
217 specify the directory. | |
218 DEFAULT is the preferred value." | |
219 (paths-for-each-emacs-directory func | |
220 roots | |
221 (file-name-as-directory | |
222 (paths-construct-path (list | |
223 "lib" | |
224 emacs-program-name))) | |
225 base | |
226 envvar default)) | |
169 | 227 |
170 (defun paths-find-site-directory (roots base &optional envvar default) | 228 (defun paths-find-site-directory (roots base &optional envvar default) |
171 "Find a site-specific directory in the XEmacs hierarchy. | 229 "Find a site-specific directory in the XEmacs hierarchy. |
172 ROOT must be a an installation root. | 230 ROOT must be a an installation root. |
173 BASE is the base to look for. | 231 BASE is the base to look for. |
174 ENVVAR is the name of the environment variable that might also | 232 ENVVAR is the name of the environment variable that might also |
175 specify the directory. | 233 specify the directory. |
176 DEFAULT is the preferred value." | 234 DEFAULT is the preferred value." |
177 (paths-find-emacs-directory roots | 235 (catch 'gotcha |
178 (file-name-as-directory | 236 (paths-for-each-site-directory #'(lambda (dir) |
179 (paths-construct-path (list | 237 (throw 'gotcha dir)) |
180 "lib" | 238 roots base |
181 emacs-program-name))) | 239 envvar default))) |
182 base | 240 |
183 envvar default)) | 241 (defun paths-find-site-directories (roots base &optional envvar default) |
242 "Find a list of site-specific directories in the XEmacs hierarchy. | |
243 ROOT must be a an installation root. | |
244 BASE is the base to look for. | |
245 ENVVAR is the name of the environment variable that might also | |
246 specify the directory. | |
247 DEFAULT is the preferred value." | |
248 (let ((l '())) | |
249 (paths-for-each-site-directory #'(lambda (dir) | |
250 (setq l (cons dir l))) | |
251 roots base | |
252 envvar default) | |
253 (reverse l))) | |
254 | |
255 (defun paths-for-each-version-directory (func roots base | |
256 &optional envvar default enforce-version) | |
257 "Iterate over version-specific directories in the XEmacs hierarchy. | |
258 FUNC is a function that called for each directory, with the directory | |
259 as the only argument. | |
260 ROOT must be a an installation root. | |
261 BASE is the base to look for. | |
262 ENVVAR is the name of the environment variable that might also | |
263 specify the directory. | |
264 DEFAULT is the preferred value. | |
265 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version." | |
266 (paths-for-each-emacs-directory func | |
267 roots | |
268 (file-name-as-directory | |
269 (paths-construct-path | |
270 (list "lib" | |
271 (construct-emacs-version-name)))) | |
272 base | |
273 envvar default)) | |
184 | 274 |
185 (defun paths-find-version-directory (roots base | 275 (defun paths-find-version-directory (roots base |
186 &optional envvar default enforce-version) | 276 &optional envvar default enforce-version) |
187 "Find a version-specific directory in the XEmacs hierarchy. | 277 "Find a version-specific directory in the XEmacs hierarchy. |
188 | |
189 ROOT must be a an installation root. | 278 ROOT must be a an installation root. |
190 BASE is the base to look for. | 279 BASE is the base to look for. |
191 ENVVAR is the name of the environment variable that might also | 280 ENVVAR is the name of the environment variable that might also |
192 specify the directory. | 281 specify the directory. |
193 DEFAULT is the preferred value. | 282 DEFAULT is the preferred value. |
194 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version." | 283 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version." |
195 (paths-find-emacs-directory roots | 284 (catch 'gotcha |
196 (file-name-as-directory | 285 (paths-for-each-version-directory #'(lambda (dir) |
197 (paths-construct-path | 286 (throw 'gotcha dir)) |
198 (list "lib" | 287 roots base |
199 (construct-emacs-version-name)))) | 288 envvar default))) |
200 base | 289 |
201 envvar default | 290 (defun paths-find-version-directories (roots base |
202 enforce-version)) | 291 &optional envvar default enforce-version) |
292 "Find a list of version-specific directories in the XEmacs hierarchy. | |
293 ROOT must be a an installation root. | |
294 BASE is the base to look for. | |
295 ENVVAR is the name of the environment variable that might also | |
296 specify the directory. | |
297 DEFAULT is the preferred value. | |
298 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version." | |
299 (let ((l '())) | |
300 (paths-for-each-site-directory #'(lambda (dir) | |
301 (setq l (cons dir l))) | |
302 roots base | |
303 envvar default) | |
304 (reverse l))) | |
203 | 305 |
204 (defun paths-find-architecture-directory (roots base &optional envvar default) | 306 (defun paths-find-architecture-directory (roots base &optional envvar default) |
205 "Find an architecture-specific directory in the XEmacs hierarchy. | 307 "Find an architecture-specific directory in the XEmacs hierarchy. |
206 ROOT must be a an installation root. | 308 ROOT must be a an installation root. |
207 BASE is the base to look for. | 309 BASE is the base to look for. |