summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-04-05 23:21:26 +0100
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-04-06 11:19:04 +0100
commit6701726b98261f862e4708aadb6d518b886cf8e2 (patch)
tree5e637b9b9324df7570c0b9a4a59d71d2ef14db23 /lisp/emacs-lisp
parentb6610d55470c7e835472a581977ab6fad537c8b6 (diff)
downloademacs-6701726b98261f862e4708aadb6d518b886cf8e2.tar.gz
emacs-6701726b98261f862e4708aadb6d518b886cf8e2.tar.bz2
emacs-6701726b98261f862e4708aadb6d518b886cf8e2.zip
emacs-lisp/package.el (package-install): Add ASYNC and CALLBACK
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/package.el22
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index e7c33db7528..6d5d46c14bb 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1773,13 +1773,16 @@ using `package-compute-transaction'."
(kill-buffer (current-buffer)))))))))
;;;###autoload
-(defun package-install (pkg &optional dont-select)
+(defun package-install (pkg &optional dont-select async callback)
"Install the package PKG.
PKG can be a package-desc or the package name of one the available packages
in an archive in `package-archives'. Interactively, prompt for its name.
If called interactively or if DONT-SELECT nil, add PKG to
`package-selected-packages'.
+If ASYNC is non-nil, perform the downloads asynchronously.
+If CALLBACK is non-nil, call it with no arguments once the
+entire operation is done.
If PKG is a package-desc and it is already installed, don't try
to install it but still mark it as selected."
@@ -1807,15 +1810,14 @@ to install it but still mark it as selected."
(unless (or dont-select (package--user-selected-p name))
(customize-save-variable 'package-selected-packages
(cons name package-selected-packages))))
- (if (package-desc-p pkg)
- (if (package-installed-p pkg)
- (message "`%s' is already installed" (package-desc-full-name pkg))
- (package-download-transaction
- (package-compute-transaction (list pkg)
- (package-desc-reqs pkg))))
- (package-download-transaction
- (package-compute-transaction ()
- (list (list pkg))))))
+ (if-let ((transaction
+ (if (package-desc-p pkg)
+ (unless (package-installed-p pkg)
+ (package-compute-transaction (list pkg)
+ (package-desc-reqs pkg)))
+ (package-compute-transaction () (list (list pkg))))))
+ (package-download-transaction transaction async callback)
+ (message "`%s' is already installed" (package-desc-full-name pkg))))
(defun package-strip-rcs-id (str)
"Strip RCS version ID from the version string STR.