From: Chong Yidong Date: Fri, 26 Aug 2011 15:53:50 +0000 (-0400) Subject: * package.el (package-install): Call package-initialize if called interactively. X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~66^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7254299e4d19b0acdfc5dd7580c24be817731488;p=emacs.git * package.el (package-install): Call package-initialize if called interactively. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b82163e5160..e3fe51454e5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-08-26 Chong Yidong + + * emacs-lisp/package.el (package-install): Call package-initialize + if called interactively. + 2011-08-26 Leo Liu * emacs-lisp/cl-macs.el (defstruct): Fix format. (Bug#9357) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 19e8375966b..88282606aa8 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -852,18 +852,26 @@ using `package-compute-transaction'." (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" @@ -1076,8 +1084,6 @@ makes them available for download." (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.