+2011-08-26 Chong Yidong <cyd@stupidchicken.com>
+
+ * emacs-lisp/package.el (package-install): Call package-initialize
+ if called interactively.
+
2011-08-26 Leo Liu <sdl.web@gmail.com>
* emacs-lisp/cl-macs.el (defstruct): Fix format. (Bug#9357)
(t
(error "Unknown package kind: %s" (symbol-name kind)))))))
+(defvar package--initialized nil)
+
;;;###autoload
(defun package-install (name)
"Install the package named NAME.
-Interactively, prompt for the package name.
-The package is found on one of the archives in `package-archives'."
+NAME should be the name of one of the available packages in an
+archive in `package-archives'. Interactively, prompt for NAME."
(interactive
- (list (intern (completing-read "Install package: "
- (mapcar (lambda (elt)
- (cons (symbol-name (car elt))
- nil))
- package-archive-contents)
- nil t))))
+ (progn
+ ;; Initialize the package system to get the list of package
+ ;; symbols for completion.
+ (unless package--initialized
+ (package-initialize t))
+ (list (intern (completing-read
+ "Install package: "
+ (mapcar (lambda (elt)
+ (cons (symbol-name (car elt))
+ nil))
+ package-archive-contents)
+ nil t)))))
(let ((pkg-desc (assq name package-archive-contents)))
(unless pkg-desc
(error "Package `%s' is not available for installation"
(car archive)))))
(package-read-all-archive-contents))
-(defvar package--initialized nil)
-
;;;###autoload
(defun package-initialize (&optional no-activate)
"Load Emacs Lisp packages, and activate them.