annotate lisp/packages.el @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 6240c7796c7a
children 501cfd01ee6d
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 ;;; packages.el --- Low level support for XEmacs packages
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
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
5 ;; Author: Steven L Baur <steve@xemacs.org>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
6 ;; Maintainer: Steven L Baur <steve@xemacs.org>
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Keywords: internal, lisp, 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 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF
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 ;; This file provides low level facilities for XEmacs startup --
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33 ;; particularly regarding the package setup. This code has to run in
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 ;; what we call "bare temacs" -- i.e. XEmacs without the usual Lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 ;; environment. Pay special attention:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 ;; - not to use the `lambda' macro. Use #'(lambda ...) instead.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 ;; (this goes for any package loaded before `subr.el'.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 ;; - not to use macros, because they are not yet available (and this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 ;; file must be loadable uncompiled.) This rules out CL-style
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 ;; macros like `when', for instance.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
44 ;; - not to use `defcustom'. If you must add user-customizable
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 ;; variables here, use `defvar', and add the variable to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 ;; `cus-start.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 ;; Because of all this, make sure that the stuff you put here really
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 ;; belongs here.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
51 ;; This file requires find-paths.el.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
55 ;;; Package versioning
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
56
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
57 (defvar packages-package-list nil
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
58 "Database of loaded packages and version numbers")
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
59
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
60 (defvar packages-hierarchy-depth 1
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
61 "Depth of package hierarchies.")
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
62
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
63 (defvar packages-load-path-depth 1
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
64 "Depth of load-path search in package hierarchies.")
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
65
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
66 (defvar packages-data-path-depth 1
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
67 "Depth of data-path search in package hierarchies.")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
68
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
69 (defvar early-packages nil
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
70 "Packages early in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
71
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
72 (defvar early-package-load-path nil
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
73 "Load path for packages early in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
74
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
75 (defvar late-packages nil
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
76 "Packages late in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
77
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
78 (defvar late-package-load-path nil
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
79 "Load path for packages late in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
80
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
81 (defvar last-packages nil
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
82 "Packages last in the load path.")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
83
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
84 (defvar last-package-load-path nil
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
85 "Load path for packages last in the load path.")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
86
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
87 (defun packages-compute-package-locations (user-init-directory)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
88 "Compute locations of the various package directories.
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
89 This is a list each of whose elements describes one directory.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
90 A directory description is a three-element list.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
91 The first element is either an absolute path or a subdirectory
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
92 in the XEmacs hierarchy.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
93 The second component is one of the symbols EARLY, LATE, LAST,
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
94 depending on the load-path segment the hierarchy is supposed to
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
95 show up in.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
96 The third component is a thunk which, if it returns NIL, causes
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
97 the directory to be ignored."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
98 (list
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
99 (list (paths-construct-path (list user-init-directory "mule-packages"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
100 'early #'(lambda () (featurep 'mule)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
101 (list (paths-construct-path (list user-init-directory "xemacs-packages"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
102 'early #'(lambda () t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
103 (list "site-packages" 'late #'(lambda () t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
104 (list "infodock-packages" 'late #'(lambda () (featurep 'infodock)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
105 (list "mule-packages" 'late #'(lambda () (featurep 'mule)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
106 (list "xemacs-packages" 'late #'(lambda () t))))
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
107
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
108 (defun package-get-key-1 (info key)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
109 "Locate keyword `key' in list."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
110 (cond ((null info)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
111 nil)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
112 ((eq (car info) key)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
113 (nth 1 info))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
114 (t (package-get-key-1 (cddr info) key))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
115
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
116 (defun package-get-key (name key)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
117 "Get info `key' from package `name'."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
118 (let ((info (assq name packages-package-list)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
119 (when info
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
120 (package-get-key-1 (cdr info) key))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
121
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
122 (defun package-provide (name &rest attributes)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
123 (let ((info (if (and attributes (floatp (car attributes)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
124 (list :version (car attributes))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
125 attributes)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
126 (setq packages-package-list
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
127 (cons (cons name info) (remassq name packages-package-list)))))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
128
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
129 (defun package-require (name version)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
130 (let ((pkg (assq name packages-package-list)))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
131 (cond ((null pkg)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
132 (error "Package %s has not been loaded into this XEmacsen"
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
133 name))
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 237
diff changeset
134 ((< (package-get-key name :version) version)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
135 (error "Need version %g of package %s, got version %g"
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
136 version name (cdr pkg)))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
137 (t t))))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
138
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
139 (defun package-delete-name (name)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
140 (let (pkg)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
141 ;; Delete ALL versions of package.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
142 ;; This is pretty memory-intensive, as we use copy-alist when deleting
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
143 ;; package entries, to prevent side-effects in functions that call this
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
144 ;; one.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
145 (while (setq pkg (assq name packages-package-list))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
146 (setq packages-package-list (delete pkg (copy-alist
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
147 packages-package-list)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
148 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
149 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
150
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
151 ;;; Build time stuff
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
152
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 (defvar autoload-file-name "auto-autoloads.el"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 "Filename that autoloads are expected to be found in.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 (defvar packages-hardcoded-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 '(
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
158 ;; Nothing at this time
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 )
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
160 "Lisp packages that are always dumped with XEmacs.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
161 This includes every package that is loaded directly by a package listed
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
162 in dumped-lisp.el and is not itself listed.")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
164 (defvar packages-useful-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 '("bytecomp"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 "byte-optimize"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 "shadow"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 "cl-macs")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 "Lisp packages that need early byte compilation.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171 (defvar packages-unbytecompiled-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172 '("paths.el"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
173 "dumped-lisp.el"
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
174 "dumped-pkg-lisp.el"
261
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 253
diff changeset
175 "version.el"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
176 "very-early-lisp.el")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 "Lisp packages that should not be byte compiled.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 ;; Copied from help.el, could possibly move it to here permanently.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181 ;; Unlike the FSF version, our `locate-library' uses the `locate-file'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182 ;; primitive, which should make it lightning-fast.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184 (defun locate-library (library &optional nosuffix path interactive-call)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185 "Show the precise file name of Emacs library LIBRARY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 This command searches the directories in `load-path' like `M-x load-library'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 to find the file that `M-x load-library RET LIBRARY RET' would load.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 to the specified name LIBRARY.
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 the optional third arg PATH is specified, that list of directories
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192 is used instead of `load-path'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
193 (interactive (list (read-string "Locate library: ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
194 nil nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
195 t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196 (let ((result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 (locate-file
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 library
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 (or path load-path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 (and (boundp 'find-file-hooks)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
202 (member 'crypt-find-file-hook find-file-hooks)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 ;; Compression involved.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204 (if nosuffix
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
205 '("" ".gz" ".Z")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
206 '(".elc" ".elc.gz" "elc.Z" ".el" ".el.gz" ".el.Z" "" ".gz" ".Z")))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 ;; No compression.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 (if nosuffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 ""
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
211 '(".elc" ".el" "")))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 (and interactive-call
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 (if result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214 (message "Library is file %s" result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215 (message "No library %s in search path" library)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 (defun packages-add-suffix (str)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219 (if (null (string-match "\\.el\\'" str))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
220 (concat str ".elc")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
221 str))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
222
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
223 (defun packages-list-autoloads-path ()
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
224 "List autoloads from precomputed load-path."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
225 (let ((path load-path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226 autoloads)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
227 (while path
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
228 (if (file-exists-p (concat (car path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
229 autoload-file-name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
230 (setq autoloads (cons (concat (car path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231 autoload-file-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
232 autoloads)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
233 (setq path (cdr path)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
234 autoloads))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
235
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
236 (defun packages-list-autoloads (source-directory)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
237 "List autoload files in (what will be) the normal lisp search path.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 This function is used during build to find where the global symbol files so
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239 they can be perused for their useful information."
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
240 (let ((files (directory-files (file-name-as-directory source-directory)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
241 t ".*"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 file autolist)
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
243 ;; (print (prin1-to-string source-directory))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
244 ;; (print (prin1-to-string files))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 (while (setq file (car-safe files))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 (if (and (file-directory-p file)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
247 (file-exists-p (concat (file-name-as-directory file)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
248 autoload-file-name)))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
249 (setq autolist (cons (concat (file-name-as-directory file)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
250 autoload-file-name)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
251 autolist)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252 (setq files (cdr files)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253 autolist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
255 ;; The following function cannot be called from a bare temacs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
256 (defun packages-new-autoloads ()
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
257 "Return autoloads files that have been added or modified since XEmacs dump."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
258 (require 'loadhist)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
259 (let ((me (concat invocation-directory invocation-name))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
260 (path load-path)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
261 result dir)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
262 (while path
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
263 (setq dir (file-truename (car path)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
264 (let ((autoload-file (file-name-sans-extension (concat
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
265 dir
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
266 autoload-file-name))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
267 ;; Check for:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
268 ;; 1. An auto-autoload file that hasn't provided a feature (because
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
269 ;; it has been installed since XEmacs was dumped).
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
270 ;; 2. auto-autoload.el being newer than the executable
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
271 ;; 3. auto-autoload.elc being newer than the executable (the .el
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
272 ;; could be missing or compressed)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
273 (when (or (and (null (file-provides autoload-file))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
274 (or (file-exists-p (concat autoload-file ".elc"))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
275 (file-exists-p (concat autoload-file ".el"))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
276 (and (file-newer-than-file-p (concat autoload-file ".el") me)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
277 (setq autoload-file (concat autoload-file ".el")))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
278 (and (file-newer-than-file-p (concat autoload-file
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
279 ".elc")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
280 me)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
281 (setq autoload-file (concat autoload-file ".elc"))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
282 (push autoload-file result)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
283 (setq path (cdr path)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
284 result))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
285
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
286 ;; The following function cannot be called from a bare temacs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
287 (defun packages-reload-autoloads ()
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
288 "Reload new or updated auto-autoloads files.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
289 This is an extremely dangerous function to call after the user-init-files
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
290 is run. Don't call it or you'll be sorry."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
291 (let ((autoload-list (packages-new-autoloads)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
292 (while autoload-list
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
293 (let* ((autoload-file (car autoload-list))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
294 (feature (car-safe (file-provides autoload-file))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
295 (when feature
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
296 ;; (message "(unload-feature %S)" feature)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
297 (unload-feature feature))
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
298 (condition-case nil
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
299 (load autoload-file)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
300 (t nil)))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
301 (setq autoload-list (cdr autoload-list)))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
302
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 ;; Data-directory is really a list now. Provide something to search it for
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 ;; directories.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
306 (defun locate-data-directory-list (name &optional dir-list)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
307 "Locate the matching list of directories in a search path DIR-LIST.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
308 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
309 (unless dir-list
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
310 (setq dir-list data-directory-list))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
311 (let (found found-dir found-dir-list)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
312 (while dir-list
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
313 (setq found (file-name-as-directory (concat (car dir-list) name))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
314 found-dir (file-directory-p found))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
315 (and found-dir
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
316 (setq found-dir-list (cons found found-dir-list)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
317 (setq dir-list (cdr dir-list)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
318 (nreverse found-dir-list)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
319
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
320 ;; Data-directory is really a list now. Provide something to search it for
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
321 ;; a directory.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
322
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
323 (defun locate-data-directory (name &optional dir-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 "Locate a directory in a search path DIR-LIST (a list of directories).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326 (unless dir-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 (setq dir-list data-directory-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 (let (found found-dir)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329 (while (and (null found-dir) dir-list)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
330 (setq found (file-name-as-directory (concat (car dir-list) name))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
331 found-dir (file-directory-p found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332 (or found-dir
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 (setq found nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334 (setq dir-list (cdr dir-list)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335 found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
337 ;; Data-directory is really a list now. Provide something to search it for
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
338 ;; files.
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
339
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
340 (defun locate-data-file (name &optional dir-list)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
341 "Locate a file in a search path DIR-LIST (a list of directories).
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 237
diff changeset
342 If no DIR-LIST is supplied, it defaults to `data-directory-list'.
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 237
diff changeset
343 This function is basically a wrapper over `locate-file'."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
344 (locate-file name (or dir-list data-directory-list)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
345
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
346 ;; Path setup
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
347
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
348 (defun packages-find-package-directories (roots base)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
349 "Find a set of package directories."
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
350 ;; make sure paths-find-version-directory and paths-find-site-directory
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
351 ;; don't both pick up version-independent directories ...
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
352 (let ((version-directory (paths-find-version-directory roots base nil nil t))
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
353 (site-directory (paths-find-site-directory roots base)))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
354 (paths-uniq-append
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
355 (and version-directory (list version-directory))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
356 (and site-directory (list site-directory)))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
357
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
358 (defvar packages-special-base-regexp "^\\(etc\\|info\\|lisp\\|lib-src\\|bin\\|pkginfo\\)$"
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
359 "Special subdirectories of packages.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
360
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 280
diff changeset
361 (defvar packages-no-package-hierarchy-regexp
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 280
diff changeset
362 (concat "\\(" paths-version-control-filename-regexp "\\)"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 280
diff changeset
363 "\\|"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 280
diff changeset
364 "\\(" packages-special-base-regexp "\\)")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 280
diff changeset
365 "Directories which can't be the roots of package hierarchies.")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 280
diff changeset
366
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
367 (defun packages-find-packages-in-directories (directories)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
368 "Find all packages underneath directories in DIRECTORIES."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
369 (paths-find-recursive-path directories
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
370 packages-hierarchy-depth
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 280
diff changeset
371 packages-no-package-hierarchy-regexp))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
372
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
373 (defun packages-split-path (path)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
374 "Split PATH at \"\", return pair with two components.
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
375 The second component is shared with PATH."
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
376 (let ((reverse-tail '())
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
377 (rest path))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
378 (while (and rest (null (string-equal "" (car rest))))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
379 (setq reverse-tail (cons (car rest) reverse-tail))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
380 (setq rest (cdr rest)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
381 (if (null rest)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
382 (cons path nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
383 (cons (nreverse reverse-tail) (cdr rest)))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
384
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
385 (defun packages-split-package-path (package-path)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
386 "Split up PACKAGE-PATH into early, late and last components.
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
387 The separation is by \"\" components.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
388 This returns (LIST EARLY-PACKAGES LATE-PACKAGES LAST-PACKAGES)."
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
389 ;; When in doubt, it's late
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
390 (let* ((stuff (packages-split-path package-path))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
391 (early (and (cdr stuff) (car stuff)))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
392 (late+last (or (cdr stuff) (car stuff)))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
393 (stuff (packages-split-path late+last))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
394 (late (car stuff))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
395 (last (cdr stuff)))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
396 (list (packages-find-packages-in-directories early)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
397 (packages-find-packages-in-directories late)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
398 (packages-find-packages-in-directories last))))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
399
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
400 (defun packages-deconstruct (list consumer)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
401 "Deconstruct LIST and feed it to CONSUMER."
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
402 (apply consumer list))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
403
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
404 (defun packages-find-packages-by-name (roots name)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
405 "Find a package hierarchy by its name."
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
406 (packages-find-packages-in-directories
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
407 (if (and (file-name-absolute-p name)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
408 (file-name-directory (expand-file-name name)))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
409 (list (file-name-as-directory (expand-file-name name)))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
410 (packages-find-package-directories roots name))))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
411
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
412 (defun packages-find-packages-at-time
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
413 (roots package-locations time &optional default)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
414 "Find packages at given time.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
415 For the format of PACKAGE-LOCATIONS, see the global variable of the same name.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
416 TIME is either 'EARLY, 'LATE, or 'LAST.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
417 DEFAULT is a default list of packages."
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
418 (or default
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
419 (let ((packages '()))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
420 (while package-locations
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
421 (packages-deconstruct
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
422 (car package-locations)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
423 #'(lambda (name a-time thunk)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
424 (if (and (eq time a-time)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
425 (funcall thunk))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
426 (setq packages
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
427 (nconc packages
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
428 (packages-find-packages-by-name roots name))))))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
429 (setq package-locations (cdr package-locations)))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
430 packages)))
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
431
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
432 (defun packages-find-packages (roots package-locations)
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
433 "Find the packages."
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
434 (let ((envvar-value (getenv "EMACSPACKAGEPATH")))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
435 (if envvar-value
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
436 (packages-split-package-path (paths-decode-directory-path envvar-value))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
437 (packages-deconstruct
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
438 (packages-split-package-path configure-package-path)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
439 #'(lambda (configure-early-packages
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
440 configure-late-packages
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
441 configure-last-packages)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
442 (list (packages-find-packages-at-time roots package-locations 'early
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
443 configure-early-packages)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
444 (packages-find-packages-at-time roots package-locations 'late
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
445 configure-late-packages)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
446 (packages-find-packages-at-time roots package-locations 'last
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
447 configure-last-packages)))))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
448
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
449 (defun packages-find-package-library-path (packages suffixes)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
450 "Construct a path into a component of the packages hierarchy.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
451 PACKAGES is a list of package directories.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
452 SUFFIXES is a list of names of package subdirectories to look for."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
453 (let ((directories
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
454 (apply
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
455 #'nconc
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
456 (mapcar #'(lambda (package)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
457 (mapcar #'(lambda (suffix)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
458 (file-name-as-directory (concat package suffix)))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
459 suffixes))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
460 packages))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
461 (paths-directories-which-exist directories)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
462
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
463 (defun packages-find-package-load-path (packages)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
464 "Construct the load-path component for packages.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
465 PACKAGES is a list of package directories."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
466 (paths-find-recursive-load-path
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
467 (packages-find-package-library-path packages
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
468 '("lisp"))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
469 packages-load-path-depth))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
470
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
471 (defun packages-find-package-exec-path (packages)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
472 "Construct the exec-path component for packages.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
473 PACKAGES is a list of package directories."
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
474 (packages-find-package-library-path packages
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
475 (list (paths-construct-path
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
476 (list "bin" system-configuration))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
477 "lib-src")))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
478
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
479 (defun packages-find-package-info-path (packages)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
480 "Construct the info-path component for packages.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
481 PACKAGES is a list of package directories."
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
482 (packages-find-package-library-path packages '("info")))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
483
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
484 (defun packages-find-package-data-path (packages)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
485 "Construct the data-path component for packages.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
486 PACKAGES is a list of package directories."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
487 (paths-find-recursive-load-path
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
488 (packages-find-package-library-path packages
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
489 '("etc"))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
490 packages-data-path-depth))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
491
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
492 ;; Loading package initialization files
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
493
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
494 (defun packages-load-package-lisps (package-load-path base)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
495 "Load all Lisp files of a certain name along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
496 BASE is the base name of the files."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
497 (mapcar #'(lambda (dir)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
498 (let ((file-name (expand-file-name base dir)))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
499 (condition-case error
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
500 (load file-name t t)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
501 (error
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
502 (warn (format "Autoload error in: %s:\n\t%s"
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
503 file-name
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
504 (with-output-to-string
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
505 (display-error error nil))))))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
506 package-load-path))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
507
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
508 (defun packages-load-package-auto-autoloads (package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
509 "Load auto-autoload files along a load path."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
510 (packages-load-package-lisps package-load-path
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
511 (file-name-sans-extension autoload-file-name)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
512
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
513 (defun packages-handle-package-dumped-lisps (handle package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
514 "Load dumped-lisp.el files along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
515 Call HANDLE on each file off definitions of PACKAGE-LISP there."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
516 (mapcar #'(lambda (dir)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
517 (let ((file-name (expand-file-name "dumped-lisp.el" dir)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
518 (if (file-exists-p file-name)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
519 (let (package-lisp
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
520 ;; 20.4 packages could set this
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
521 preloaded-file-list)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
522 (load file-name)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
523 ;; dumped-lisp.el could have set this ...
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
524 (if package-lisp
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 373
diff changeset
525 (mapcar #'(lambda (base)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
526 (funcall handle base))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
527 package-lisp))))))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
528 package-load-path))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
529
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
530 (defun packages-load-package-dumped-lisps (package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
531 "Load dumped-lisp.el files along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
532 Also load files off PACKAGE-LISP definitions there"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
533 (packages-handle-package-dumped-lisps #'load package-load-path))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
534
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
535 (defun packages-collect-package-dumped-lisps (package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
536 "Load dumped-lisp.el files along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
537 Return list of files off PACKAGE-LISP definitions there"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
538 (let ((*files* '()))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
539 (packages-handle-package-dumped-lisps
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
540 #'(lambda (file)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
541 (setq *files* (cons file *files*)))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
542 package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
543 (reverse *files*)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
544
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
545 (provide 'packages)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
546
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
547 ;;; packages.el ends here