summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-04 14:51:39 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-04 15:04:46 +0000
commit5687ac9f013618052bdf324e0751059c9d00ff87 (patch)
tree0f81c3ad27d68e02b2703420aa7b0576ad75700f /lisp/emacs-lisp
parent5b83f03725e713c268ec1417ca36f8d3b65905d4 (diff)
downloademacs-5687ac9f013618052bdf324e0751059c9d00ff87.tar.gz
emacs-5687ac9f013618052bdf324e0751059c9d00ff87.tar.bz2
emacs-5687ac9f013618052bdf324e0751059c9d00ff87.zip
emacs-lisp/package.el (package-install): Mark dependencies as selected.
In particular, when given a package-desc object which is already installed, the package is not downloaded again.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/package.el39
1 files changed, 26 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index b07362e6a5e..3d44755f46a 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -996,15 +996,22 @@ GnuPG keyring is located under \"gnupg\" in `package-user-dir'."
(defun package-installed-p (package &optional min-version)
"Return true if PACKAGE, of MIN-VERSION or newer, is installed.
-MIN-VERSION should be a version list."
+If PACKAGE is a symbol, it is the package name and MIN-VERSION
+should be a version list.
+
+If PACKAGE is a package-desc object, MIN-VERSION is ignored."
(unless package--initialized (error "package.el is not yet initialized!"))
- (or
- (let ((pkg-descs (cdr (assq package package-alist))))
- (and pkg-descs
- (version-list-<= min-version
- (package-desc-version (car pkg-descs)))))
- ;; Also check built-in packages.
- (package-built-in-p package min-version)))
+ (if (package-desc-p package)
+ (let ((dir (package-desc-dir pkg-desc)))
+ (and (stringp dir)
+ (file-exists-p dir)))
+ (or
+ (let ((pkg-descs (cdr (assq package package-alist))))
+ (and pkg-descs
+ (version-list-<= min-version
+ (package-desc-version (car pkg-descs)))))
+ ;; Also check built-in packages.
+ (package-built-in-p package min-version))))
(defun package-compute-transaction (packages requirements &optional seen)
"Return a list of packages to be installed, including PACKAGES.
@@ -1219,7 +1226,10 @@ 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 MARK-SELECTED is non-nil, add PKG
-to `package-selected-packages'."
+to `package-selected-packages'.
+
+if PKG is a package-desc and it is already installed, don't try
+to install it but still mark it as selected."
(interactive
(progn
;; Initialize the package system to get the list of package
@@ -1243,10 +1253,13 @@ to `package-selected-packages'."
(when (and mark-selected (not (package--user-selected-p name)))
(customize-save-variable 'package-selected-packages
(cons name package-selected-packages))))
- (package-download-transaction
- (if (package-desc-p pkg)
- (package-compute-transaction (list pkg)
- (package-desc-reqs pkg))
+ (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))))))