annotate lisp/packages.el @ 215:1f0dabaa0855 r20-4b6

Import from CVS: tag r20-4b6
author cvs
date Mon, 13 Aug 2007 10:07:35 +0200
parents 78f53ef88e17
children d44af0c54775
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
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Author: Steven L Baur <steve@altair.xemacs.org>
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6 ;; Keywords: internal, lisp, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29 ;; This file is dumped with XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31 ;; This file provides low level facilities for XEmacs startup --
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;; particularly regarding the package setup. This code has to run in
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33 ;; what we call "bare temacs" -- i.e. XEmacs without the usual Lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 ;; environment. Pay special attention:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36 ;; - not to use the `lambda' macro. Use #'(lambda ...) instead.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 ;; (this goes for any package loaded before `subr.el'.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 ;; - not to use macros, because they are not yet available (and this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 ;; file must be loadable uncompiled.) This rules out CL-style
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 ;; macros like `when', for instance.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 ;; - not to use `defcustom'. If you must add user-customizable
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
44 ;; variables here, use `defvar', and add the variable to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 ;; `cus-start.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47 ;; Because of all this, make sure that the stuff you put here really
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 ;; belongs here.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 (defvar autoload-file-name "auto-autoloads.el"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 "Filename that autoloads are expected to be found in.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 (defvar packages-hardcoded-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57 '(
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 ;; "startup"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60 "Lisp packages that are always dumped with XEmacs")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 (defvar packages-useful-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 '("bytecomp"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 "byte-optimize"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 "advice"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 "shadow"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 "cl-macs")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 "Lisp packages that need early byte compilation.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 (defvar packages-unbytecompiled-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71 '("paths.el"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 "version.el")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 "Lisp packages that should not be byte compiled.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 ;; Copied from help.el, could possibly move it to here permanently.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
77 ;; Unlike the FSF version, our `locate-library' uses the `locate-file'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78 ;; primitive, which should make it lightning-fast.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 (defun locate-library (library &optional nosuffix path interactive-call)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81 "Show the precise file name of Emacs library LIBRARY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82 This command searches the directories in `load-path' like `M-x load-library'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
83 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
84 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
85 to the specified name LIBRARY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 If the optional third arg PATH is specified, that list of directories
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 is used instead of `load-path'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 (interactive (list (read-string "Locate library: ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90 nil nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92 (let ((result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93 (locate-file
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 library
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 (or path load-path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97 (and (boundp 'find-file-hooks)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 (member 'crypt-find-file-hook find-file-hooks)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99 ;; Compression involved.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100 (if nosuffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 ":.gz:.Z"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102 ".elc:.elc.gz:elc.Z:.el:.el.gz:.el.Z::.gz:.Z"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 ;; No compression.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 (if nosuffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 ".elc:.el:")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108 4)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 (and interactive-call
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110 (if result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 (message "Library is file %s" result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112 (message "No library %s in search path" library)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 (defun packages-add-suffix (str)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 (if (null (string-match "\\.el\\'" str))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
117 (concat str ".elc")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118 str))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120 (defun list-autoloads-path ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
121 "List autoloads from precomputed load-path."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 (let ((path load-path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 autoloads)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 (while path
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125 (if (file-exists-p (concat (car path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 autoload-file-name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 (setq autoloads (cons (concat (car path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 autoload-file-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 autoloads)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 (setq path (cdr path)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131 autoloads))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133 (defun list-autoloads ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 "List autoload files in (what will be) the normal lisp search path.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 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
136 they can be perused for their useful information."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 ;; Source directory may not be initialized yet.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 ;; (print (prin1-to-string load-path))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 (if (null source-directory)
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
140 (setq source-directory (concat (car load-path) "./")))
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
141 (let ((files (directory-files (file-name-as-directory source-directory) t ".*"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 file autolist)
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
143 ;; (print (prin1-to-string source-directory))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
144 ;; (print (prin1-to-string files))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145 (while (setq file (car-safe files))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (if (and (file-directory-p file)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 (file-exists-p (concat file "/" autoload-file-name)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 (setq autolist (cons (concat file "/" autoload-file-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 autolist)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 (setq files (cdr files)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 autolist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 ;; The following function is called from temacs
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
154 (defun packages-find-packages-1 (package path-only append-p user-package)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 "Search the supplied directory for associated directories.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 The top level is assumed to look like:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 info/ Contain texinfo files for lisp installed in this hierarchy
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158 etc/ Contain data files for lisp installled in this hiearchy
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 lisp/ Contain directories which either have straight lisp code
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160 or are self-contained packages of their own.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
162 If the argument `append-p' is non-nil, the found directories will be
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
163 appended to the paths, otherwise, they will be prepended.
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
164
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 This is an internal function. Do not call it after startup."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 ;; Info files
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 (if (and (null path-only) (file-directory-p (concat package "/info")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 (let ((dir (concat package "/info/")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 (if (not (member dir Info-default-directory-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 (nconc Info-default-directory-list (list dir)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171 ;; Data files
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172 (if (and (null path-only) (file-directory-p (concat package "/etc")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 (setq data-directory-list
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
174 (if append-p
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
175 (append data-directory-list (list (concat package "/etc/")))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
176 (cons (concat package "/etc/") data-directory-list))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 ;; Lisp files
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178 (if (file-directory-p (concat package "/lisp"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 ; (print (concat "DIR: "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181 ; (if user-package "[USER]" "")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182 ; package
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 ; "/lisp/"))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
184 (setq load-path
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
185 (if append-p
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
186 (append load-path (list (concat package "/lisp/")))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
187 (cons (concat package "/lisp/") load-path)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 (if user-package
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190 (load (concat package "/lisp/"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191 (file-name-sans-extension autoload-file-name)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192 (t nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
193 (let ((dirs (directory-files (concat package "/lisp/")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
194 t "^[^-.]" nil 'dirs-only))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
195 dir)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196 (while dirs
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 (setq dir (car dirs))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 ; (print (concat "DIR: " dir "/"))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
199 (setq load-path
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
200 (if append-p
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
201 (append load-path (list (concat dir "/")))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
202 (cons (concat dir "/") load-path)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 (if user-package
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
206 ; (print
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 ; (concat dir "/"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 ; (file-name-sans-extension autoload-file-name)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 (load
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 (concat dir "/"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211 (file-name-sans-extension autoload-file-name))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 (t nil)))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
213 (packages-find-packages-1 dir path-only append-p user-package)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214 (setq dirs (cdr dirs)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 ;; The following function is called from temacs
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
217 (defun packages-find-packages-2 (path path-only append-p suppress-user)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
218 "Search the supplied path for associated directories.
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
219 If the argument `append-p' is non-nil, the found directories will be
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
220 appended to the paths, otherwise, they will be prepended.
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
221
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
222 This is an internal function. Do not call it after startup."
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
223 (let (dir)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
224 (while path
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
225 (setq dir (car path))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
226 ;; (prin1 (concat "Find: " (expand-file-name dir) "\n"))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
227 (if (null (and (or suppress-user inhibit-package-init)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
228 (string-match "^~" dir)))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
229 (progn
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
230 ;; (print dir)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
231 (packages-find-packages-1 (expand-file-name dir)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
232 path-only
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
233 append-p
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
234 (string-match "^~" dir))))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
235 (setq path (cdr path)))))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
236
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
237 ;; The following function is called from temacs
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 (defun packages-find-packages (pkg-path path-only &optional suppress-user)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239 "Search the supplied path for additional info/etc/lisp directories.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240 Lisp directories if configured prior to build time will have equivalent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 status as bundled packages.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 If the argument `path-only' is non-nil, only the `load-path' will be set,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 otherwise data directories and info directories will be added.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 If the optional argument `suppress-user' is non-nil, package directories
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 rooted in a user login directory (like ~/.xemacs) will not be searched.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 This is used at dump time to suppress the builder's local environment."
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
247 (let ((prefix-path nil))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
248 (while (and pkg-path (car pkg-path))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
249 (setq prefix-path (cons (car pkg-path) prefix-path)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
250 pkg-path (cdr pkg-path)))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
251 (packages-find-packages-2 (cdr pkg-path) path-only t suppress-user)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
252 (packages-find-packages-2 prefix-path path-only nil suppress-user)))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
253
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 ;; Data-directory is really a list now. Provide something to search it for
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256 ;; directories.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 (defun locate-data-directory (name &optional dir-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
259 "Locate a directory in a search path DIR-LIST (a list of directories).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
261 (unless dir-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
262 (setq dir-list data-directory-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
263 (let (found found-dir)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
264 (while (and (null found-dir) dir-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
265 (setq found (concat (car dir-list) name "/")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
266 found-dir (file-directory-p found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267 (or found-dir
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268 (setq found nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269 (setq dir-list (cdr dir-list)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
272 ;; 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
273 ;; files.
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
274
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
275 (defun locate-data-file (name &optional dir-list)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
276 "Locate a file in a search path DIR-LIST (a list of directories).
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
277 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
278 (unless dir-list
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
279 (setq dir-list data-directory-list))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
280 (let (found found-file)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
281 (while (and (null found-file) dir-list)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
282 (setq found (concat (car dir-list) name)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
283 found-file (and (file-exists-p found)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
284 (not (file-directory-p found))))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
285 (or found-file
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
286 (setq found nil))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
287 (setq dir-list (cdr dir-list)))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
288 found))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
289
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290 ;; If we are being loaded as part of being dumped, bootstrap the rest of the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291 ;; load-path for loaddefs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
292 (if (fboundp 'load-gc)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 (packages-find-packages package-path t t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 (provide 'packages)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
296
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 ;;; packages.el ends here