annotate lisp/prim/packages.el @ 163:0132846995bd r20-3b8

Import from CVS: tag r20-3b8
author cvs
date Mon, 13 Aug 2007 09:43:35 +0200
parents
children 929b76928fce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
1 ;;; packages.el --- Low level support for XEmacs packages
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
2
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
4
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
5 ;; Author: Steven L Baur <steve@altair.xemacs.org>
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
6 ;; Keywords: internal, lisp
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
7
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
9
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
13 ;; any later version.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
14
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
18 ;; General Public License for more details.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
19
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
24
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
26
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
27 ;;; Commentary:
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
28
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
29 ;; This file provides low level facilities for XEmacs startup. Special
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
30 ;; requirements apply to some of these functions because they can be called
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
31 ;; during build from temacs and much of the usual lisp environment may
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
32 ;; be missing.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
33
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
34 ;;; Code:
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
35
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
36 (defvar autoload-file-name "auto-autoloads.el"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
37 "Filename that autoloads are expected to be found in.")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
38
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
39 (defvar packages-hardcoded-lisp
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
40 '("cl-defs"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
41 "startup"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
42 )
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
43 "Lisp packages that are always dumped with XEmacs")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
44
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
45 (defvar packages-useful-lisp
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
46 '("bytecomp"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
47 "byte-optimize"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
48 "advice")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
49 "Lisp packages that need early byte compilation.")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
50
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
51 (defvar packages-unbytecompiled-lisp
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
52 '("paths.el"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
53 "version.el")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
54 "Lisp packages that should not be byte compiled.")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
55
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
56 ;; Copied from subr.el
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
57 (if (null (fboundp 'lambda))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
58 (defmacro lambda (&rest cdr)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
59 (list 'function (cons 'lambda cdr))))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
60
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
61 ;; Copied from help.el, could possibly move it to here permanently.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
62 ;; This is taken directly from Emacs 19.34.94.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
63
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
64 (defun locate-library (library &optional nosuffix path interactive-call)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
65 "Show the precise file name of Emacs library LIBRARY.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
66 This command searches the directories in `load-path' like `M-x load-library'
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
67 to find the file that `M-x load-library RET LIBRARY RET' would load.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
68 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
69 to the specified name LIBRARY.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
70
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
71 If the optional third arg PATH is specified, that list of directories
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
72 is used instead of `load-path'."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
73 (interactive (list (read-string "Locate library: ")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
74 nil nil
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
75 t))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
76 (let (result)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
77 (catch 'answer
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
78 (mapcar
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
79 (lambda (dir)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
80 (mapcar
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
81 (lambda (suf)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
82 (let ((try (expand-file-name (concat library suf) dir)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
83 (and (file-readable-p try)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
84 (null (file-directory-p try))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
85 (progn
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
86 (setq result try)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
87 (throw 'answer try)))))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
88 (if nosuffix
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
89 '("")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
90 (let ((basic '(".elc" ".el" ""))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
91 (compressed '(".Z" ".gz" "")))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
92 ;; If autocompression mode is on,
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
93 ;; consider all combinations of library suffixes
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
94 ;; and compression suffixes.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
95 (if (rassq 'jka-compr-handler file-name-handler-alist)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
96 (apply 'nconc
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
97 (mapcar (lambda (compelt)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
98 (mapcar (lambda (baselt)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
99 (concat baselt compelt))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
100 basic))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
101 compressed))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
102 basic)))))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
103 (or path load-path)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
104 (and interactive-call
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
105 (if result
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
106 (message "Library is file %s" result)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
107 (message "No library %s in search path" library)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
108 result))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
109
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
110 (defun packages-add-suffix (str)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
111 (if (null (string-match "\\.el\\'" str))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
112 (concat str ".elc")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
113 str))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
114
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
115 (defun list-autoloads ()
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
116 "List autoload files in (what will be) the normal lisp search path.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
117 This function is used during build to find where the global symbol files so
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
118 they can be perused for their useful information."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
119 ;; Source directory may not be initialized yet.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
120 ;; (print (prin1-to-string load-path))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
121 (if (null source-directory)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
122 (setq source-directory (concat (car load-path) "/..")))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
123 (let ((files (directory-files source-directory t ".*"))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
124 file autolist)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
125 (while (setq file (car-safe files))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
126 (if (and (file-directory-p file)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
127 (file-exists-p (concat file "/" autoload-file-name)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
128 (setq autolist (cons (concat file "/" autoload-file-name)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
129 autolist)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
130 (setq files (cdr files)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
131 autolist))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
132
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
133 (provide 'packages)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
134
0132846995bd Import from CVS: tag r20-3b8
cvs
parents:
diff changeset
135 ;;; packages.el ends here