comparison lisp/find-paths.el @ 4092:9c0151d05116

[xemacs-hg @ 2007-08-02 06:33:04 by michaels] 2007-07-31 Mike Sperber <mike@xemacs.org> * configure.ac: Don't divert `share' to `lib' for datadir. Also, define AC_DATAROOTDIR_CHECKED to shut up autoconf. 2007-07-31 Mike Sperber <mike@xemacs.org> * find-paths.el (paths-for-each-site-directory): (paths-find-site-directory): (paths-find-site-directories): (paths-for-each-version-directory): (paths-find-version-directory): (paths-find-version-directories): Add `arch-dependent-p' argument to distinguish between `lib' and `share'. (paths-find-architecture-directory): Follow above change. * packages.el (packages-find-installation-package-directories): Ditto. * setup-paths.el (paths-find-site-lisp-directory): (paths-find-site-module-directory): (paths-find-lisp-directory): (paths-find-mule-lisp-directory): (paths-find-module-directory): (paths-find-data-directory): Ditto.
author michaels
date Thu, 02 Aug 2007 06:33:59 +0000
parents a452d2a78a4e
children 5da4cc7d5968
comparison
equal deleted inserted replaced
4091:7b78a0e97947 4092:9c0151d05116
205 (throw 'gotcha dir)) 205 (throw 'gotcha dir))
206 roots 206 roots
207 suffix base 207 suffix base
208 envvar default keep-suffix))) 208 envvar default keep-suffix)))
209 209
210 (defun paths-for-each-site-directory (func roots base &optional envvar default) 210 (defun paths-for-each-site-directory (func roots base arch-dependent-p &optional envvar default)
211 "Iterate over the site-specific directories in the XEmacs hierarchy. 211 "Iterate over the site-specific directories in the XEmacs hierarchy.
212 FUNC is a function that called for each directory, with the directory 212 FUNC is a function that called for each directory, with the directory
213 as the only argument. 213 as the only argument.
214 ROOTS must be a list of installation roots. 214 ROOTS must be a list of installation roots.
215 BASE is the base to look for. 215 BASE is the base to look for.
216 ARCH-DEPENDENT-P says whether the file is architecture-specific.
216 ENVVAR is the name of the environment variable that might also 217 ENVVAR is the name of the environment variable that might also
217 specify the directory. 218 specify the directory.
218 DEFAULT is the preferred value." 219 DEFAULT is the preferred value."
219 (paths-for-each-emacs-directory func 220 (paths-for-each-emacs-directory func
220 roots 221 roots
221 (file-name-as-directory 222 (file-name-as-directory
222 (paths-construct-path (list 223 (paths-construct-path (list
223 "lib" 224 (if arch-dependent-p "lib" "share")
224 emacs-program-name))) 225 emacs-program-name)))
225 base 226 base
226 envvar default)) 227 envvar default))
227 228
228 (defun paths-find-site-directory (roots base &optional envvar default) 229 (defun paths-find-site-directory (roots base arch-dependent-p &optional envvar default)
229 "Find a site-specific directory in the XEmacs hierarchy. 230 "Find a site-specific directory in the XEmacs hierarchy.
230 ROOTS must be a list of installation roots. 231 ROOTS must be a list of installation roots.
231 BASE is the base to look for. 232 BASE is the base to look for.
233 ARCH-DEPENDENT-P says whether the file is architecture-specific.
232 ENVVAR is the name of the environment variable that might also 234 ENVVAR is the name of the environment variable that might also
233 specify the directory. 235 specify the directory.
234 DEFAULT is the preferred value." 236 DEFAULT is the preferred value."
235 (catch 'gotcha 237 (catch 'gotcha
236 (paths-for-each-site-directory #'(lambda (dir) 238 (paths-for-each-site-directory #'(lambda (dir)
237 (throw 'gotcha dir)) 239 (throw 'gotcha dir))
238 roots base 240 roots base arch-dependent-p
239 envvar default))) 241 envvar default)))
240 242
241 (defun paths-find-site-directories (roots base &optional envvar default) 243 (defun paths-find-site-directories (roots base arch-dependent-p &optional envvar default)
242 "Find a list of site-specific directories in the XEmacs hierarchy. 244 "Find a list of site-specific directories in the XEmacs hierarchy.
243 ROOTS must be a list of installation roots. 245 ROOTS must be a list of installation roots.
244 BASE is the base to look for. 246 BASE is the base to look for.
247 ARCH-DEPENDENT-P says whether the file is architecture-specific.
245 ENVVAR is the name of the environment variable that might also 248 ENVVAR is the name of the environment variable that might also
246 specify the directory. 249 specify the directory.
247 DEFAULT is the preferred value." 250 DEFAULT is the preferred value."
248 (let ((l '())) 251 (let ((l '()))
249 (paths-for-each-site-directory #'(lambda (dir) 252 (paths-for-each-site-directory #'(lambda (dir)
250 (setq l (cons dir l))) 253 (setq l (cons dir l)))
251 roots base 254 roots base arch-dependent-p
252 envvar default) 255 envvar default)
253 (reverse l))) 256 (reverse l)))
254 257
255 (defun paths-for-each-version-directory (func roots base 258 (defun paths-for-each-version-directory (func roots base arch-dependent-p
256 &optional envvar default enforce-version) 259 &optional envvar default enforce-version)
257 "Iterate over version-specific directories in the XEmacs hierarchy. 260 "Iterate over version-specific directories in the XEmacs hierarchy.
258 FUNC is a function that called for each directory, with the directory 261 FUNC is a function that called for each directory, with the directory
259 as the only argument. 262 as the only argument.
260 ROOTS must be a list of installation roots. 263 ROOTS must be a list of installation roots.
261 BASE is the base to look for. 264 BASE is the base to look for.
265 ARCH-DEPENDENT-P says whether the file is architecture-specific.
262 ENVVAR is the name of the environment variable that might also 266 ENVVAR is the name of the environment variable that might also
263 specify the directory. 267 specify the directory.
264 DEFAULT is the preferred value. 268 DEFAULT is the preferred value.
265 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version." 269 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version."
266 (paths-for-each-emacs-directory func 270 (paths-for-each-emacs-directory func
267 roots 271 roots
268 (file-name-as-directory 272 (file-name-as-directory
269 (paths-construct-path 273 (paths-construct-path
270 (list "lib" 274 (list (if arch-dependent-p "lib" "share")
271 (construct-emacs-version-name)))) 275 (construct-emacs-version-name))))
272 base 276 base
273 envvar default)) 277 envvar default))
274 278
275 (defun paths-find-version-directory (roots base 279 (defun paths-find-version-directory (roots base arch-dependent-p
276 &optional envvar default enforce-version) 280 &optional envvar default enforce-version)
277 "Find a version-specific directory in the XEmacs hierarchy. 281 "Find a version-specific directory in the XEmacs hierarchy.
278 ROOTS must be a list of installation roots. 282 ROOTS must be a list of installation roots.
279 BASE is the base to look for. 283 BASE is the base to look for.
284 ARCH-DEPENDENT-P says whether the file is architecture-specific.
280 ENVVAR is the name of the environment variable that might also 285 ENVVAR is the name of the environment variable that might also
281 specify the directory. 286 specify the directory.
282 DEFAULT is the preferred value. 287 DEFAULT is the preferred value.
283 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version." 288 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version."
284 (catch 'gotcha 289 (catch 'gotcha
285 (paths-for-each-version-directory #'(lambda (dir) 290 (paths-for-each-version-directory #'(lambda (dir)
286 (throw 'gotcha dir)) 291 (throw 'gotcha dir))
287 roots base 292 roots base arch-dependent-p
288 envvar default))) 293 envvar default)))
289 294
290 (defun paths-find-version-directories (roots base 295 (defun paths-find-version-directories (roots base arch-dependent-p
291 &optional envvar default enforce-version) 296 &optional envvar default enforce-version)
292 "Find a list of version-specific directories in the XEmacs hierarchy. 297 "Find a list of version-specific directories in the XEmacs hierarchy.
293 ROOTS must be a list of installation roots. 298 ROOTS must be a list of installation roots.
294 BASE is the base to look for. 299 BASE is the base to look for.
300 ARCH-DEPENDENT-P says whether the file is architecture-specific.
295 ENVVAR is the name of the environment variable that might also 301 ENVVAR is the name of the environment variable that might also
296 specify the directory. 302 specify the directory.
297 DEFAULT is the preferred value. 303 DEFAULT is the preferred value.
298 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version." 304 If ENFORCE-VERSION is non-nil, the directory must contain the XEmacs version."
299 (let ((l '())) 305 (let ((l '()))
300 (paths-for-each-site-directory #'(lambda (dir) 306 (paths-for-each-version-directory #'(lambda (dir)
301 (setq l (cons dir l))) 307 (setq l (cons dir l)))
302 roots base 308 roots base arch-dependent-p
303 envvar default) 309 envvar default)
304 (reverse l))) 310 (reverse l)))
305 311
306 (defun paths-find-architecture-directory (roots base &optional envvar default) 312 (defun paths-find-architecture-directory (roots base &optional envvar default)
307 "Find an architecture-specific directory in the XEmacs hierarchy. 313 "Find an architecture-specific directory in the XEmacs hierarchy.
308 ROOTS must be a list of installation roots. 314 ROOTS must be a list of installation roots.
313 (or 319 (or
314 ;; from more to less specific 320 ;; from more to less specific
315 (paths-find-version-directory roots 321 (paths-find-version-directory roots
316 (paths-construct-path 322 (paths-construct-path
317 (list system-configuration base)) 323 (list system-configuration base))
324 t
318 envvar default) 325 envvar default)
319 (paths-find-version-directory roots 326 (paths-find-version-directory roots
320 base 327 base t
321 envvar) 328 envvar)
322 (paths-find-version-directory roots 329 (paths-find-version-directory roots
323 system-configuration 330 system-configuration t
324 envvar))) 331 envvar)))
325 332
326 (defun construct-emacs-version-name () 333 (defun construct-emacs-version-name ()
327 "Construct a string from the raw XEmacs version number." 334 "Construct a string from the raw XEmacs version number."
328 (concat emacs-program-name "-" emacs-program-version)) 335 (concat emacs-program-name "-" emacs-program-version))