summaryrefslogtreecommitdiff
path: root/lisp/startup.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2010-10-30 20:06:18 -0400
committerChong Yidong <cyd@stupidchicken.com>2010-10-30 20:06:18 -0400
commit8a500a91a222c6c8e9ae6c72e233f1512520504a (patch)
tree961b0b9b802b5f0c5b42817fa013e6f34ca2e08e /lisp/startup.el
parent837ba704f88ac7d2b1935d1810d1574ec811a94f (diff)
downloademacs-8a500a91a222c6c8e9ae6c72e233f1512520504a.tar.gz
Check more carefully for packages before loading package.el.
* startup.el (command-line): Search for package directories, and don't load package.el if none are found. * emacs-lisp/package.el (describe-package, list-packages): Call package-initialize if it has not been called yet.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r--lisp/startup.el26
1 files changed, 24 insertions, 2 deletions
diff --git a/lisp/startup.el b/lisp/startup.el
index 7626dcfac16..31fb7507295 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1172,8 +1172,30 @@ the `--debug-init' option to view a complete error backtrace."
(eq face-ignored-fonts old-face-ignored-fonts))
(clear-face-cache)))
- ;; Load ELPA packages.
- (and user-init-file package-enable-at-startup (package-initialize))
+ ;; If any package directory exists, initialize the package system.
+ (and user-init-file
+ package-enable-at-startup
+ (catch 'package-dir-found
+ (let (dirs)
+ (if (boundp 'package-directory-list)
+ (setq dirs package-directory-list)
+ (dolist (f load-path)
+ (and (stringp f)
+ (equal (file-name-nondirectory f) "site-lisp")
+ (push (expand-file-name "elpa" f) dirs))))
+ (push (if (boundp 'package-user-dir)
+ package-user-dir
+ (locate-user-emacs-file "elpa"))
+ dirs)
+ (dolist (dir dirs)
+ (when (file-directory-p dir)
+ (dolist (subdir (directory-files dir))
+ (when (and (file-directory-p (expand-file-name subdir dir))
+ ;; package-subdirectory-regexp from package.el
+ (string-match "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$"
+ subdir))
+ (throw 'package-dir-found t)))))))
+ (package-initialize))
(setq after-init-time (current-time))
(run-hooks 'after-init-hook)