aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2015-02-04 14:51:39 +0000
committerArtur Malabarba2015-02-04 15:04:46 +0000
commit5687ac9f013618052bdf324e0751059c9d00ff87 (patch)
tree0f81c3ad27d68e02b2703420aa7b0576ad75700f
parent5b83f03725e713c268ec1417ca36f8d3b65905d4 (diff)
downloademacs-5687ac9f013618052bdf324e0751059c9d00ff87.tar.gz
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.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/emacs-lisp/package.el39
2 files changed, 31 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 88abb4ff5f3..375304bff9e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -2,6 +2,11 @@
2 2
3 * emacs-lisp/package.el (package-delete): Remove package from 3 * emacs-lisp/package.el (package-delete): Remove package from
4 `package-selected-packages' even if it can't be deleted. 4 `package-selected-packages' even if it can't be deleted.
5 (package-installed-p): Accept package-desc objects.
6 (package-install): Can be used to mark dependencies as
7 selected. When given a package-desc object which is already
8 installed, the package is not downloaded again, but it is marked
9 as selected (if it wasn't already).
5 10
62015-02-03 Artur Malabarba <bruce.connor.am@gmail.com> 112015-02-03 Artur Malabarba <bruce.connor.am@gmail.com>
7 12
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'."
996 996
997(defun package-installed-p (package &optional min-version) 997(defun package-installed-p (package &optional min-version)
998 "Return true if PACKAGE, of MIN-VERSION or newer, is installed. 998 "Return true if PACKAGE, of MIN-VERSION or newer, is installed.
999MIN-VERSION should be a version list." 999If PACKAGE is a symbol, it is the package name and MIN-VERSION
1000should be a version list.
1001
1002If PACKAGE is a package-desc object, MIN-VERSION is ignored."
1000 (unless package--initialized (error "package.el is not yet initialized!")) 1003 (unless package--initialized (error "package.el is not yet initialized!"))
1001 (or 1004 (if (package-desc-p package)
1002 (let ((pkg-descs (cdr (assq package package-alist)))) 1005 (let ((dir (package-desc-dir pkg-desc)))
1003 (and pkg-descs 1006 (and (stringp dir)
1004 (version-list-<= min-version 1007 (file-exists-p dir)))
1005 (package-desc-version (car pkg-descs))))) 1008 (or
1006 ;; Also check built-in packages. 1009 (let ((pkg-descs (cdr (assq package package-alist))))
1007 (package-built-in-p package min-version))) 1010 (and pkg-descs
1011 (version-list-<= min-version
1012 (package-desc-version (car pkg-descs)))))
1013 ;; Also check built-in packages.
1014 (package-built-in-p package min-version))))
1008 1015
1009(defun package-compute-transaction (packages requirements &optional seen) 1016(defun package-compute-transaction (packages requirements &optional seen)
1010 "Return a list of packages to be installed, including PACKAGES. 1017 "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
1219in an archive in `package-archives'. Interactively, prompt for its name. 1226in an archive in `package-archives'. Interactively, prompt for its name.
1220 1227
1221If called interactively or if MARK-SELECTED is non-nil, add PKG 1228If called interactively or if MARK-SELECTED is non-nil, add PKG
1222to `package-selected-packages'." 1229to `package-selected-packages'.
1230
1231if PKG is a package-desc and it is already installed, don't try
1232to install it but still mark it as selected."
1223 (interactive 1233 (interactive
1224 (progn 1234 (progn
1225 ;; Initialize the package system to get the list of package 1235 ;; Initialize the package system to get the list of package
@@ -1243,10 +1253,13 @@ to `package-selected-packages'."
1243 (when (and mark-selected (not (package--user-selected-p name))) 1253 (when (and mark-selected (not (package--user-selected-p name)))
1244 (customize-save-variable 'package-selected-packages 1254 (customize-save-variable 'package-selected-packages
1245 (cons name package-selected-packages)))) 1255 (cons name package-selected-packages))))
1246 (package-download-transaction 1256 (if (package-desc-p pkg)
1247 (if (package-desc-p pkg) 1257 (if (package-installed-p pkg)
1248 (package-compute-transaction (list pkg) 1258 (message "`%s' is already installed" (package-desc-full-name pkg))
1249 (package-desc-reqs pkg)) 1259 (package-download-transaction
1260 (package-compute-transaction (list pkg)
1261 (package-desc-reqs pkg))))
1262 (package-download-transaction
1250 (package-compute-transaction () 1263 (package-compute-transaction ()
1251 (list (list pkg)))))) 1264 (list (list pkg))))))
1252 1265