Contents in release-21-2 at 1999-06-30-19.
[chise/xemacs-chise.git.1] / lisp / packages.el
index 974bdd3..1e374bf 100644 (file)
@@ -63,6 +63,9 @@
 (defvar packages-load-path-depth 1
   "Depth of load-path search in package hierarchies.")
 
+(defvar packages-data-path-depth 1
+  "Depth of data-path search in package hierarchies.")
+
 (defvar early-packages nil
   "Packages early in the load path.")
 
 
 (defvar package-locations
   (list
-   (list (paths-construct-path '("~" ".xemacs"))
+   (list (paths-construct-path '("~" ".xemacs" "mule-packages"))
+                             'early #'(lambda () (featurep 'mule)))
+   (list (paths-construct-path '("~" ".xemacs" "xemacs-packages"))
                              'early #'(lambda () t))
    (list "site-packages"     'late  #'(lambda () t))
    (list "infodock-packages" 'late  #'(lambda () (featurep 'infodock)))
    (list "mule-packages"     'late  #'(lambda () (featurep 'mule)))
-   (list "xemacs-packages"   'late  #'(lambda () t))
-   (list "packages"          'late  #'(lambda () t)))
+   (list "xemacs-packages"   'late  #'(lambda () t)))
   "Locations of the various package directories.
 This is a list each of whose elements describes one directory.
 A directory description is a three-element list.
@@ -133,6 +137,18 @@ the directory to be ignored.")
                  version name (cdr pkg)))
          (t t))))
 
+(defun package-delete-name (name)
+  (let (pkg)
+    ;; Delete ALL versions of package.
+    ;; This is pretty memory-intensive, as we use copy-alist when deleting
+    ;; package entries, to prevent side-effects in functions that call this
+    ;; one.
+    (while (setq pkg (assq name packages-package-list))
+      (setq packages-package-list (delete pkg (copy-alist
+                                              packages-package-list)))
+      )
+    ))
+
 ;;; Build time stuff
 
 (defvar autoload-file-name "auto-autoloads.el"
@@ -158,8 +174,7 @@ in dumped-lisp.el and is not itself listed.")
     "dumped-lisp.el"
     "dumped-pkg-lisp.el"
     "version.el"
-    "very-early-lisp.el"
-    "Installation.el")
+    "very-early-lisp.el")
   "Lisp packages that should not be byte compiled.")
 
 
@@ -188,14 +203,13 @@ is used instead of `load-path'."
                          (member 'crypt-find-file-hook find-file-hooks)))
                 ;; Compression involved.
                 (if nosuffix
-                    ":.gz:.Z"
-                  ".elc:.elc.gz:elc.Z:.el:.el.gz:.el.Z::.gz:.Z"))
+                    '("" ".gz" ".Z")
+                  '(".elc" ".elc.gz" "elc.Z" ".el" ".el.gz" ".el.Z" "" ".gz" ".Z")))
                (t
                 ;; No compression.
                 (if nosuffix
                     ""
-                  ".elc:.el:")))
-         4)))
+                  '(".elc" ".el" "")))))))
     (and interactive-call
         (if result
             (message "Library is file %s" result)
@@ -220,14 +234,10 @@ is used instead of `load-path'."
       (setq path (cdr path)))
     autoloads))
 
-(defun packages-list-autoloads ()
+(defun packages-list-autoloads (source-directory)
   "List autoload files in (what will be) the normal lisp search path.
 This function is used during build to find where the global symbol files so
 they can be perused for their useful information."
-  ;; Source directory may not be initialized yet.
-  ;; (print (prin1-to-string load-path))
-  (if (null source-directory)
-      (setq source-directory (car load-path)))
   (let ((files (directory-files (file-name-as-directory source-directory)
                                t ".*"))
        file autolist)
@@ -294,6 +304,23 @@ is run.  Don't call it or you'll be sorry."
 ;; Data-directory is really a list now.  Provide something to search it for
 ;; directories.
 
+(defun locate-data-directory-list (name &optional dir-list)
+  "Locate the matching list of directories in a search path DIR-LIST.
+If no DIR-LIST is supplied, it defaults to `data-directory-list'."
+  (unless dir-list
+    (setq dir-list data-directory-list))
+  (let (found found-dir found-dir-list)
+    (while dir-list
+      (setq found (file-name-as-directory (concat (car dir-list) name))
+           found-dir (file-directory-p found))
+      (and found-dir
+          (setq found-dir-list (cons found found-dir-list)))
+      (setq dir-list (cdr dir-list)))
+    (nreverse found-dir-list)))
+
+;; Data-directory is really a list now.  Provide something to search it for
+;; a directory.
+
 (defun locate-data-directory (name &optional dir-list)
   "Locate a directory in a search path DIR-LIST (a list of directories).
 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
@@ -315,9 +342,7 @@ If no DIR-LIST is supplied, it defaults to `data-directory-list'."
   "Locate a file in a search path DIR-LIST (a list of directories).
 If no DIR-LIST is supplied, it defaults to `data-directory-list'.
 This function is basically a wrapper over `locate-file'."
-  (unless dir-list
-    (setq dir-list data-directory-list))
-  (locate-file name dir-list))
+  (locate-file name (or dir-list data-directory-list)))
 
 ;; Path setup
 
@@ -331,7 +356,7 @@ This function is basically a wrapper over `locate-file'."
      (and version-directory (list version-directory))
      (and site-directory (list site-directory)))))
 
-(defvar packages-special-base-regexp "^\\(etc\\|info\\|lisp\\|lib-src\\|bin\\)$"
+(defvar packages-special-base-regexp "^\\(etc\\|info\\|lisp\\|lib-src\\|bin\\|pkginfo\\)$"
   "Special subdirectories of packages.")
 
 (defvar packages-no-package-hierarchy-regexp
@@ -445,16 +470,25 @@ PACKAGES is a list of package directories."
    packages-load-path-depth))
 
 (defun packages-find-package-exec-path (packages)
+  "Construct the exec-path component for packages.
+PACKAGES is a list of package directories."
   (packages-find-package-library-path packages
                                      (list (paths-construct-path
                                             (list "bin" system-configuration))
                                            "lib-src")))
 
 (defun packages-find-package-info-path (packages)
+  "Construct the info-path component for packages.
+PACKAGES is a list of package directories."
   (packages-find-package-library-path packages '("info")))
 
 (defun packages-find-package-data-path (packages)
-  (packages-find-package-library-path packages '("etc")))
+  "Construct the data-path component for packages.
+PACKAGES is a list of package directories."
+  (paths-find-recursive-load-path
+   (packages-find-package-library-path packages
+                                      '("etc"))
+   packages-data-path-depth))
 
 ;; Loading package initialization files