annotate lisp/setup-paths.el @ 265:8efd647ea9ca r20-5b31

Import from CVS: tag r20-5b31
author cvs
date Mon, 13 Aug 2007 10:25:37 +0200
parents
children 966663fcf606
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
1 ;;; setup-paths.el --- setup various XEmacs paths
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
2
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985-1986, 1990, 1992-1997 Free Software Foundation, Inc.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
4 ;; Copyright (c) 1993, 1994 Sun Microsystems, Inc.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
5 ;; Copyright (C) 1995 Board of Trustees, University of Illinois
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
6
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
7 ;; Author: Mike Sperber <sperber@informatik.uni-tuebingen.de>
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
8 ;; Maintainer: XEmacs Development Team
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
9 ;; Keywords: internal, dumped
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
10
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
12
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
16 ;; any later version.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
17
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
21 ;; General Public License for more details.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
22
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
25 ;; Free Software Foundation, 59 Temple Place - Suite 330,
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
27
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
28 ;;; Synched up with: Not in FSF.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
29
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
30 ;;; Commentary:
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
31
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
32 ;; This file is dumped with XEmacs.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
33
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
34 ;; This file contains the machinery necessary to find the various
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
35 ;; paths into the XEmacs hierarchy.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
36
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
37 (defvar paths-version-control-bases '("RCS" "CVS" "SCCS")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
38 "File bases associated with version control.")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
39
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
40 (defun paths-find-recursive-path (directories &optional exclude)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
41 "Return a list of the directory hierarchy underneath DIRECTORIES.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
42 The returned list is sorted by pre-order and lexicographically."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
43 (let ((path '()))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
44 (while directories
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
45 (let ((directory (file-name-as-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
46 (expand-file-name
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
47 (car directories)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
48 (if (file-directory-p directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
49 (let ((raw-dirs (directory-files directory nil "^[^-.]" nil 'dirs-only))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
50 (reverse-dirs '()))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
51
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
52 (while raw-dirs
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
53 (if (null (member (car raw-dirs) exclude))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
54 (setq reverse-dirs
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
55 (cons (expand-file-name (car raw-dirs) directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
56 reverse-dirs)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
57 (setq raw-dirs (cdr raw-dirs)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
58
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
59 (let ((sub-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
60 (paths-find-recursive-path (reverse reverse-dirs) exclude)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
61 (setq path (nconc path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
62 (list directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
63 sub-path))))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
64 (setq directories (cdr directories)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
65 path))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
66
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
67 (defun paths-find-recursive-load-path (directories)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
68 "Construct a recursive load path underneath DIRECTORIES."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
69 (paths-find-recursive-path directories paths-version-control-bases))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
70
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
71 (defun paths-emacs-root-p (directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
72 "Check if DIRECTORY is a plausible installation root for XEmacs."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
73 (or
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
74 ;; installed
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
75 (and (boundp 'emacs-version)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
76 (file-directory-p
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
77 (concat directory "lib/xemacs-" (construct-emacs-version))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
78 ;; in-place
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
79 (and
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
80 (file-directory-p (concat directory "lib-src"))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
81 (file-directory-p (concat directory "lisp"))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
82 (file-directory-p (concat directory "src")))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
83
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
84 (defun paths-find-emacs-root
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
85 (invocation-directory invocation-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
86 "Find the run-time root of XEmacs."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
87 (let ((maybe-root-1 (file-name-as-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
88 (expand-file-name ".." invocation-directory)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
89 (maybe-root-2 (file-name-as-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
90 (expand-file-name "../.." invocation-directory))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
91 (cond
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
92 ((paths-emacs-root-p maybe-root-1)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
93 maybe-root-1)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
94 ((paths-emacs-root-p maybe-root-2)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
95 maybe-root-2)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
96 (t
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
97 (let ((maybe-symlink (file-symlink-p (concat invocation-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
98 invocation-name))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
99 (if maybe-symlink
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
100 (let ((directory (file-name-directory maybe-symlink)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
101 (paths-find-emacs-root directory invocation-name))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
102 nil))))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
103
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
104 (defun paths-construct-emacs-directory (root suffix base)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
105 "Construct a directory name within the XEmacs hierarchy."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
106 (file-name-as-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
107 (expand-file-name
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
108 (concat
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
109 (file-name-as-directory root)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
110 suffix
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
111 base))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
112
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
113 (defun paths-find-emacs-directory (roots suffix base &optional envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
114 "Find a directory in the XEmacs hierarchy.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
115 ROOTS must be a list of installation roots.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
116 SUFFIX is the subdirectory from there.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
117 BASE is the base to look for.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
118 ENVVAR is the name of the environment variable that might also
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
119 specify the directory.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
120 DEFAULT is a fall-back value."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
121 (let ((envvar-value (and envvar (getenv envvar))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
122 (if (and envvar-value
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
123 (file-directory-p envvar-value))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
124 (file-name-as-directory envvar-value)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
125 (catch 'gotcha
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
126 (while roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
127 (let* ((root (car roots))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
128 (path (paths-construct-emacs-directory root suffix base)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
129 ;; installed
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
130 (if (file-directory-p path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
131 (throw 'gotcha path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
132 (let ((path (paths-construct-emacs-directory root "" base)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
133 ;; in-place
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
134 (if (file-directory-p path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
135 (throw 'gotcha path)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
136 (setq roots (cdr roots)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
137 (if (and default
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
138 (file-directory-p default))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
139 (file-name-as-directory default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
140 nil)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
141
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
142 (defun paths-find-site-directory (roots base &optional envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
143 "Find a site-specific directory in the XEmacs hierarchy."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
144 (paths-find-emacs-directory roots "lib/xemacs/" base envvar default))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
145
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
146 (defun paths-find-version-directory (roots base &optional envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
147 "Find a version-specific directory in the XEmacs hierarchy."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
148 (paths-find-emacs-directory roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
149 (concat "lib/xemacs-" (construct-emacs-version) "/")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
150 base
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
151 envvar default))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
152
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
153 (defun paths-find-architecture-directory (roots base &optional envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
154 "Find an architecture-specific directory in the XEmacs hierarchy."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
155 (or
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
156 ;; from more to less specific
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
157 (paths-find-version-directory roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
158 (concat base system-configuration)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
159 envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
160 (paths-find-version-directory roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
161 system-configuration
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
162 envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
163 (paths-find-version-directory roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
164 base
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
165 envvar default)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
166
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
167 (defvar paths-path-emacs-version nil
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
168 "Emacs version as it appears in paths.")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
169
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
170 (defun construct-emacs-version ()
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
171 "Construct the raw version number of XEmacs in the form XX.XX."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
172 ;; emacs-version isn't available early, but we really don't care then
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
173 (if (null (boundp 'emacs-version))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
174 ""
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
175 (or paths-path-emacs-version ; cache
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
176 (progn
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
177 (string-match "\\`[^0-9]*\\([0-9]+\\.[0-9]+\\)" emacs-version)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
178 (let ((version (substring emacs-version
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
179 (match-beginning 1) (match-end 1))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
180 (if (string-match "(beta *\\([0-9]+\\))" emacs-version)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
181 (setq version (concat version
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
182 "-b"
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
183 (substring emacs-version
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
184 (match-beginning 1) (match-end 1)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
185 (setq paths-path-emacs-version version)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
186 version)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
187
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
188 (defun paths-find-emacs-path (roots suffix base &optional envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
189 "Find a path in the XEmacs hierarchy.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
190 ROOTS must be a list of installation roots.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
191 SUFFIX is the subdirectory from there.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
192 BASE is the base to look for.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
193 ENVVAR is the name of the environment variable that might also
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
194 specify the path.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
195 DEFAULT is a fall-back value."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
196 (let ((envvar-value (and envvar (getenv envvar))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
197 (if (and (fboundp 'parse-colon-path) envvar-value)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
198 (parse-colon-path envvar-value)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
199 (let ((directory (paths-find-emacs-directory roots base suffix)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
200 (if (and directory (file-directory-p directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
201 (list directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
202 (paths-directories-which-exist default))))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
203
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
204 (defun paths-directories-which-exist (directories)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
205 "Return the directories among DIRECTORIES."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
206 (let ((reverse-directories '()))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
207 (while directories
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
208 (if (file-directory-p (car directories))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
209 (setq reverse-directories
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
210 (cons (car directories)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
211 reverse-directories)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
212 (setq directories (cdr directories)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
213 (reverse reverse-directories)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
214
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
215 (defun paths-find-site-path (roots base &optional envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
216 "Find a path underneath the site hierarchy."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
217 (paths-find-emacs-path roots "lib/xemacs/" base envvar default))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
218
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
219 (defun paths-find-version-path (roots base &optional envvar default)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
220 "Find a path underneath the site hierarchy."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
221 (paths-find-emacs-path roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
222 (concat "lib/xemacs-" (construct-emacs-version) "/")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
223 base
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
224 envvar default))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
225
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
226 ; Packages are special ...
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
227
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
228 (defun paths-find-package-path (roots)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
229 "Construct the package path underneath installation roots ROOTS."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
230 (let ((envvar-value (getenv "EMACSPACKAGEPATH")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
231 (if (and (fboundp 'parse-colon-path) envvar-value)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
232 (parse-colon-path envvar-value)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
233 (let ((base-directory (paths-find-site-directory roots "packages")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
234 (if base-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
235 (let ((mule-directory (and (featurep 'mule)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
236 (paths-find-site-directory roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
237 "mule-packages"))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
238 (append '("~/.xemacs/")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
239 '(nil)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
240 (and mule-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
241 (list mule-directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
242 (list base-directory)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
243 configure-package-path)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
244
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
245 (defvar paths-package-special-bases '("etc" "info" "lisp" "lib-src" "bin")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
246 "Special subdirectories of packages.")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
247
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
248 (defun paths-find-packages-in-directories (directories)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
249 "Find all packages underneath directories in DIRECTORIES."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
250 (paths-find-recursive-path directories
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
251 (append paths-version-control-bases
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
252 paths-package-special-bases)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
253
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
254 (defun paths-split-path (path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
255 "Split PATH at NIL, return pair with two components.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
256 The second component is shared with PATH."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
257 (let ((reverse-early '()))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
258 (while (and path (null (null (car path))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
259 (setq reverse-early (cons (car path) reverse-early))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
260 (setq path (cdr path)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
261 (if (null path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
262 (cons nil path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
263 (cons (reverse reverse-early) (cdr path)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
264
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
265 (defun paths-find-packages (package-path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
266 "Search for all packages in PACKAGE-PATH.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
267 PACKAGE-PATH may distinguish (by NIL-separation) between early
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
268 and late packages.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
269 This returns (CONS EARLY-PACKAGES LATE-PACKAGES)."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
270 (let* ((stuff (paths-split-path package-path))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
271 (early (car stuff))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
272 (late (cdr stuff)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
273 (cons (paths-find-packages-in-directories early)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
274 (paths-find-packages-in-directories late))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
275
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
276 (defun paths-find-package-library-path (packages suffixes)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
277 "Construct a path into a component of the packages hierarchy.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
278 PACKAGES is a list of package directories.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
279 SUFFIXES is a list of names of package subdirectories to look for."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
280 (let ((directories
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
281 (apply
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
282 #'append
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
283 (mapcar #'(lambda (package)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
284 (mapcar #'(lambda (suffix)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
285 (concat package suffix))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
286 suffixes))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
287 packages))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
288 (paths-directories-which-exist directories)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
289
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
290 (defun paths-find-package-load-path (packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
291 "Construct the load-path component for packages.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
292 PACKAGES is a list of package directories."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
293 (paths-find-recursive-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
294 (paths-find-package-library-path packages '("lisp/"))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
295
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
296 (defun paths-find-package-exec-path (packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
297 (paths-find-package-library-path packages
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
298 (list (concat "bin/" system-configuration "/")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
299 "lib-src/")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
300
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
301 (defun paths-find-package-info-path (packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
302 (paths-find-package-library-path packages '("info/")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
303
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
304 (defun paths-find-package-data-path (packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
305 (paths-find-package-library-path packages '("etc/")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
306
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
307 (defun paths-find-emacs-roots (invocation-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
308 invocation-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
309 "Find all plausible installation roots for XEmacs."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
310 (let ((invocation-root
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
311 (paths-find-emacs-root invocation-directory invocation-name))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
312 (installation-root
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
313 (if (and configure-prefix-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
314 (file-directory-p configure-prefix-directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
315 configure-prefix-directory)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
316 (append (and invocation-root
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
317 (list invocation-root))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
318 (and installation-root
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
319 (list installation-root)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
320
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
321 (defun paths-find-load-path (roots early-package-load-path late-package-load-path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
322 "Construct the load path."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
323 (let ((envvar-value (getenv "EMACSLOADPATH")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
324 (if (and (fboundp 'parse-colon-path) envvar-value)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
325 (parse-colon-path envvar-value)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
326 (let* ((site-lisp-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
327 (and allow-site-lisp
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
328 (paths-find-site-directory roots "site-lisp"
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
329 nil
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
330 configure-site-directory)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
331 (site-lisp-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
332 (and site-lisp-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
333 (paths-find-recursive-load-path (list site-lisp-directory))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
334 (lisp-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
335 (paths-find-version-directory roots "lisp"
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
336 nil
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
337 configure-lisp-directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
338 (lisp-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
339 (paths-find-recursive-load-path (list lisp-directory))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
340 (nconc early-package-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
341 site-lisp-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
342 late-package-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
343 lisp-load-path)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
344
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
345 (defun paths-find-info-path (roots early-packages late-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
346 "Construct the info path."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
347 (append
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
348 (paths-find-package-info-path early-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
349 (paths-find-package-info-path late-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
350 (let ((info-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
351 (paths-find-version-directory roots "info"
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
352 nil
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
353 (append
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
354 (and configure-info-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
355 (list configure-info-directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
356 configure-info-path))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
357 (and info-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
358 (list info-directory)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
359 (let ((info-path-envval (getenv "INFOPATH")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
360 (if (and (fboundp 'parse-colon-path) info-path-envval)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
361 (parse-colon-path info-path-envval)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
362
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
363 (defun paths-find-doc-directory (roots)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
364 "Find the documentation directory."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
365 (paths-find-architecture-directory roots "lib-src"))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
366
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
367 (defun paths-find-lock-directory (roots)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
368 "Find the lock directory."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
369 (paths-find-site-path roots "lock" "EMACSLOCKDIR" configure-lock-directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
370
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
371 (defun paths-find-superlock-file (lock-directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
372 "Find the superlock file."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
373 (cond
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
374 ((null lock-directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
375 nil)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
376 ((and configure-superlock-file
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
377 (file-directory-p (file-name-directory configure-superlock-file)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
378 configure-superlock-file)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
379 (t
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
380 (expand-file-name "!!!SuperLock!!!" lock-directory))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
381
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
382 (defun paths-find-exec-directory (roots)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
383 "Find the binary directory."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
384 (paths-find-architecture-directory roots "lib-src"))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
385
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
386 (defun paths-find-exec-path (roots exec-directory early-packages late-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
387 "Find the binary path."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
388 (append
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
389 (let ((path-envval (getenv "PATH")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
390 (and (fboundp 'parse-colon-path) path-envval
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
391 (parse-colon-path path-envval)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
392 (paths-find-package-exec-path early-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
393 (paths-find-package-exec-path late-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
394 (let ((emacspath-envval (getenv "EMACSPATH")))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
395 (if (and (fboundp 'parse-colon-path) emacspath-envval)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
396 (parse-colon-path path-envval)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
397 (paths-directories-which-exist configure-exec-path)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
398 (and exec-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
399 (list exec-directory))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
400
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
401 (defun paths-find-data-directory (roots)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
402 "Find the data directory."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
403 (paths-find-version-directory roots "etc" "EMACSDATA" configure-data-directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
404
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
405 (defun paths-find-data-directory-list (data-directory early-packages late-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
406 "Find the data path."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
407 (append
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
408 (paths-find-package-data-path early-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
409 (paths-find-package-data-path late-packages)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
410 (list data-directory)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
411
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
412 (defun paths-setup-paths ()
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
413 "Setup all the various paths.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
414 Call this as often as you like!"
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
415 ;; XEmacs -- Steven Baur says invocation directory is nil if you
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
416 ;; try to use XEmacs as a login shell.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
417 (or invocation-directory (setq invocation-directory default-directory))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
418 (if (fboundp 'abbreviate-file-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
419 ;; No abbreviate-file-name in temacs
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
420 (setq invocation-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
421 ;; don't let /tmp_mnt/... get into the load-path or exec-path.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
422 (abbreviate-file-name invocation-directory)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
423
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
424 (let ((roots (paths-find-emacs-roots invocation-directory invocation-name)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
425
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
426 (setq package-path (paths-find-package-path roots))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
427
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
428 (let ((stuff (paths-find-packages package-path)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
429 (setq early-packages (car stuff))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
430 (setq late-packages (cdr stuff)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
431
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
432 (setq early-package-load-path (paths-find-package-load-path early-packages))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
433 (setq late-package-load-path (paths-find-package-load-path late-packages))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
434
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
435 (setq load-path (paths-find-load-path roots
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
436 early-package-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
437 late-package-load-path))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
438
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
439 (setq info-path (paths-find-info-path roots early-packages late-packages))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
440
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
441 (if (boundp 'lock-directory)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
442 (progn
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
443 (setq lock-directory (paths-find-lock-directory roots))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
444 (setq superlock-file (paths-find-superlock-file lock-directory))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
445
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
446 (setq exec-directory (paths-find-exec-directory roots))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
447
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
448 (setq exec-path (paths-find-exec-path roots exec-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
449 early-packages late-packages))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
450
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
451 (setq doc-directory (paths-find-doc-directory roots))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
452
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
453 (setq data-directory (paths-find-data-directory roots))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
454
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
455 (setq data-directory-list (paths-find-data-directory-list data-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
456 early-packages
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
457 late-packages))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
458
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
459 (defun paths-setup-paths-warning ()
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
460 (let ((lock (if (boundp 'lock-directory) lock-directory 't))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
461 warnings message guess)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
462 (if (and (stringp lock) (null (file-directory-p lock)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
463 (setq lock nil))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
464 (cond
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
465 ((null (and exec-directory data-directory doc-directory load-path lock))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
466 (save-excursion
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
467 (set-buffer (get-buffer-create " *warning-tmp*"))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
468 (erase-buffer)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
469 (buffer-disable-undo (current-buffer))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
470 (if (null lock) (push "lock-directory" warnings))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
471 (if (null exec-directory) (push "exec-directory" warnings))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
472 (if (null data-directory) (push "data-directory" warnings))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
473 (if (null doc-directory) (push "doc-directory" warnings))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
474 (if (null load-path) (push "load-path" warnings))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
475 (cond ((cdr (cdr warnings))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
476 (setq message (apply 'format "%s, %s, and %s" warnings)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
477 ((cdr warnings)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
478 (setq message (apply 'format "%s and %s" warnings)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
479 (t (setq message (format "variable %s" (car warnings)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
480 (insert "couldn't find an obvious default for " message
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
481 ", and there were no defaults specified in paths.h when "
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
482 "XEmacs was built. Perhaps some directories don't exist, "
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
483 "or the XEmacs executable, " (concat invocation-directory
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
484 invocation-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
485 " is in a strange place?")
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
486
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
487 (if (fboundp 'fill-region)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
488 ;; Might not be bound in the cold load environment...
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
489 (let ((fill-column 76))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
490 (fill-region (point-min) (point-max))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
491 (goto-char (point-min))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
492 (princ "\nWARNING:\n" 'external-debugging-output)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
493 (princ (buffer-string) 'external-debugging-output)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
494 (erase-buffer)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
495 t)))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
496
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
497 (defun paths-load-package-lisps (package-load-path base)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
498 "Load all Lisp files of a certain name along a load path.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
499 BASE is the base name of the files."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
500 (mapc #'(lambda (dir)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
501 (let ((file-name (expand-file-name base dir)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
502 (if (file-exists-p file-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
503 (condition-case error
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
504 (load file-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
505 (error
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
506 (warn (format "Autoload error in: %s:\n\t%s"
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
507 file-name
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
508 (with-output-to-string
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
509 (display-error error nil)))))))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
510 package-load-path))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
511
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
512 (defun paths-load-package-auto-autoloads (package-load-path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
513 "Load auto-autoload files along a load path."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
514 (paths-load-package-lisps package-load-path
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
515 (file-name-sans-extension autoload-file-name)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
516
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
517 (defun paths-load-package-dumped-lisps (package-load-path)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
518 "Load dumped-lisp.el files along a load path."
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
519 (mapc #'(lambda (dir)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
520 (let ((file-name (expand-file-name "dumped-lisp.el" dir)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
521 (if (file-exists-p file-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
522 (let (package-lisp
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
523 ;; 20.4 packages could set this
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
524 preloaded-file-list)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
525 (load file-name)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
526 ;; dumped-lisp.el could have set this ...
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
527 (if package-lisp
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
528 (mapc #'(lambda (base)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
529 (load (expand-file-name base dir)))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
530 package-lisp))))))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
531 package-load-path))
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
532
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
533 ;;; setup-paths.el ends here