Mercurial > hg > xemacs-beta
comparison lisp/packages.el @ 235:85a06df23a9a r20-5b16
Import from CVS: tag r20-5b16
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:14:40 +0200 |
parents | 52952cbfc5b5 |
children | 89ec2bb86eea |
comparison
equal
deleted
inserted
replaced
234:946e7f6ce379 | 235:85a06df23a9a |
---|---|
1 ;;; packages.el --- Low level support for XEmacs packages | 1 ;;; packages.el --- Low level support for XEmacs packages |
2 | 2 |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1997 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Steven L Baur <steve@altair.xemacs.org> | 5 ;; Author: Steven L Baur <steve@altair.xemacs.org> |
6 ;; Maintainer: Steven L Baur <steve@altair.xemacs.org> | |
6 ;; Keywords: internal, lisp, dumped | 7 ;; Keywords: internal, lisp, dumped |
7 | 8 |
8 ;; This file is part of XEmacs. | 9 ;; This file is part of XEmacs. |
9 | 10 |
10 ;; XEmacs is free software; you can redistribute it and/or modify it | 11 ;; XEmacs is free software; you can redistribute it and/or modify it |
53 ;;; Package versioning | 54 ;;; Package versioning |
54 | 55 |
55 (defvar packages-package-list nil | 56 (defvar packages-package-list nil |
56 "database of loaded packages and version numbers") | 57 "database of loaded packages and version numbers") |
57 | 58 |
58 (defun package-provide (name version) | 59 (defun package-get-key-1 (info key) |
59 (if (not (assq name packages-package-list)) | 60 "Locate keyword `key' in list." |
60 (setq packages-package-list | 61 (cond ((null info) |
61 (cons (cons name version) packages-package-list)))) | 62 nil) |
63 ((eq (car info) key) | |
64 (nth 1 info)) | |
65 (t (package-get-key-1 (cddr info) key)))) | |
66 | |
67 (defun package-get-key (name key) | |
68 "Get info `key' from package `name'." | |
69 (let ((info (assq name packages-package-list))) | |
70 (when info | |
71 (package-get-key-1 (cdr info) key)))) | |
72 | |
73 (defun package-provide (name &rest attributes) | |
74 (let ((info (if (and attributes (floatp (car attributes))) | |
75 (list :version (car attributes)) | |
76 attributes))) | |
77 (remassq name packages-package-list) | |
78 (setq packages-package-list | |
79 (cons (cons name info) packages-package-list)))) | |
62 | 80 |
63 (defun package-require (name version) | 81 (defun package-require (name version) |
64 (let ((pkg (assq name packages-package-list))) | 82 (let ((pkg (assq name packages-package-list))) |
65 (cond ((null pkg) | 83 (cond ((null pkg) |
66 (error "Package %s has not been loaded into this XEmacsen" | 84 (error "Package %s has not been loaded into this XEmacsen" |
138 (defun packages-add-suffix (str) | 156 (defun packages-add-suffix (str) |
139 (if (null (string-match "\\.el\\'" str)) | 157 (if (null (string-match "\\.el\\'" str)) |
140 (concat str ".elc") | 158 (concat str ".elc") |
141 str)) | 159 str)) |
142 | 160 |
143 (defun list-autoloads-path () | 161 (defun packages-list-autoloads-path () |
144 "List autoloads from precomputed load-path." | 162 "List autoloads from precomputed load-path." |
145 (let ((path load-path) | 163 (let ((path load-path) |
146 autoloads) | 164 autoloads) |
147 (while path | 165 (while path |
148 (if (file-exists-p (concat (car path) | 166 (if (file-exists-p (concat (car path) |
151 autoload-file-name) | 169 autoload-file-name) |
152 autoloads))) | 170 autoloads))) |
153 (setq path (cdr path))) | 171 (setq path (cdr path))) |
154 autoloads)) | 172 autoloads)) |
155 | 173 |
156 (defun list-autoloads () | 174 (defun packages-list-autoloads () |
157 "List autoload files in (what will be) the normal lisp search path. | 175 "List autoload files in (what will be) the normal lisp search path. |
158 This function is used during build to find where the global symbol files so | 176 This function is used during build to find where the global symbol files so |
159 they can be perused for their useful information." | 177 they can be perused for their useful information." |
160 ;; Source directory may not be initialized yet. | 178 ;; Source directory may not be initialized yet. |
161 ;; (print (prin1-to-string load-path)) | 179 ;; (print (prin1-to-string load-path)) |
162 (if (null source-directory) | 180 (if (null source-directory) |
163 (setq source-directory (concat (car load-path) "./"))) | 181 (setq source-directory (concat (car load-path) "./"))) |
164 (let ((files (directory-files (file-name-as-directory source-directory) t ".*")) | 182 (let ((files (directory-files (file-name-as-directory source-directory) |
183 t ".*")) | |
165 file autolist) | 184 file autolist) |
166 ;; (print (prin1-to-string source-directory)) | 185 ;; (print (prin1-to-string source-directory)) |
167 ;; (print (prin1-to-string files)) | 186 ;; (print (prin1-to-string files)) |
168 (while (setq file (car-safe files)) | 187 (while (setq file (car-safe files)) |
169 (if (and (file-directory-p file) | 188 (if (and (file-directory-p file) |
170 (file-exists-p (concat file "/" autoload-file-name))) | 189 (file-exists-p (concat file "/" autoload-file-name))) |
171 (setq autolist (cons (concat file "/" autoload-file-name) | 190 (setq autolist (cons (concat file "/" autoload-file-name) |
172 autolist))) | 191 autolist))) |
173 (setq files (cdr files))) | 192 (setq files (cdr files))) |
174 autolist)) | 193 autolist)) |
194 | |
195 ;; The following function cannot be called from a bare temacs | |
196 (defun packages-new-autoloads () | |
197 "Return autoloads files that have been added or modified since XEmacs dump." | |
198 (require 'loadhist) | |
199 (let ((me (concat invocation-directory invocation-name)) | |
200 (path load-path) | |
201 result dir) | |
202 (while path | |
203 (setq dir (file-truename (car path))) | |
204 (let ((autoload-file (file-name-sans-extension (concat | |
205 dir | |
206 autoload-file-name)))) | |
207 ;; Check for: | |
208 ;; 1. An auto-autoload file that hasn't provided a feature (because | |
209 ;; it has been installed since XEmacs was dumped). | |
210 ;; 2. auto-autoload.el being newer than the executable | |
211 ;; 3. auto-autoload.elc being newer than the executable (the .el | |
212 ;; could be missing or compressed) | |
213 (when (or (and (null (file-provides autoload-file)) | |
214 (or (file-exists-p (concat autoload-file ".elc")) | |
215 (file-exists-p (concat autoload-file ".el")))) | |
216 (and (file-newer-than-file-p (concat autoload-file ".el") me) | |
217 (setq autoload-file (concat autoload-file ".el"))) | |
218 (and (file-newer-than-file-p (concat autoload-file | |
219 ".elc") | |
220 me) | |
221 (setq autoload-file (concat autoload-file ".elc")))) | |
222 (push autoload-file result))) | |
223 (setq path (cdr path))) | |
224 result)) | |
225 | |
226 ;; The following function cannot be called from a bare temacs | |
227 (defun packages-reload-autoloads () | |
228 "Reload new or updated auto-autoloads files. | |
229 This is an extremely dangerous function to call after the user-init-files | |
230 is run. Don't call it or you'll be sorry." | |
231 (let ((autoload-list (packages-new-autoloads))) | |
232 (while autoload-list | |
233 (let* ((autoload-file (car autoload-list)) | |
234 (feature (car-safe (file-provides autoload-file)))) | |
235 (when feature | |
236 ;; (message "(unload-feature %S)" feature) | |
237 (unload-feature feature)) | |
238 (load autoload-file)) | |
239 (setq autoload-list (cdr autoload-list))))) | |
240 | |
241 ;; The following function cannot be called from a bare temacs | |
242 (defun packages-reload-dumped-lisp () | |
243 "Reload new or updated dumped lisp files (with exceptions). | |
244 This is an extremely dangerous function to call at any time." | |
245 ;; Nothing for the moment | |
246 nil) | |
175 | 247 |
176 ;; The following function is called from temacs | 248 ;; The following function is called from temacs |
177 (defun packages-find-packages-1 (package path-only append-p user-package) | 249 (defun packages-find-packages-1 (package path-only append-p user-package) |
178 "Search the supplied directory for associated directories. | 250 "Search the supplied directory for associated directories. |
179 The top level is assumed to look like: | 251 The top level is assumed to look like: |
254 (if (boundp 'preloaded-file-list) | 326 (if (boundp 'preloaded-file-list) |
255 (setq preloaded-file-list | 327 (setq preloaded-file-list |
256 (append preloaded-file-list package-lisp))) | 328 (append preloaded-file-list package-lisp))) |
257 (if (fboundp 'load-gc) | 329 (if (fboundp 'load-gc) |
258 (setq dumped-lisp-packages | 330 (setq dumped-lisp-packages |
259 (append dumped-lisp-packages package-lisp))))))) | 331 (append dumped-lisp-packages |
332 package-lisp))))))) | |
260 | 333 |
261 (if user-package | 334 (if user-package |
262 (condition-case error | 335 (condition-case error |
263 (progn | 336 (progn |
264 ; (print | 337 ; (print |