summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/package.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/package.el')
-rw-r--r--lisp/emacs-lisp/package.el65
1 files changed, 47 insertions, 18 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 6059f03f999..605d1cf375c 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -4,7 +4,7 @@
;; Author: Tom Tromey <tromey@redhat.com>
;; Created: 10 Mar 2007
-;; Version: 1.0
+;; Version: 1.0.1
;; Keywords: tools
;; This file is part of GNU Emacs.
@@ -234,11 +234,28 @@ a package can run arbitrary code."
:group 'package
:version "24.1")
+(defcustom package-pinned-packages nil
+ "An alist of packages that are pinned to a specific archive
+
+Each element has the form (SYM . ID).
+ SYM is a package, as a symbol.
+ ID is an archive name, as a string. This should correspond to an
+ entry in `package-archives'.
+
+If the archive of name ID does not contain the package SYM, no
+other location will be considered, which will make the
+package unavailable."
+ :type '(alist :key-type (symbol :tag "Package")
+ :value-type (string :tag "Archive name"))
+ :risky t
+ :group 'package
+ :version "24.4")
+
(defconst package-archive-version 1
"Version number of the package archive understood by this file.
Lower version numbers than this will probably be understood as well.")
-(defconst package-el-version "1.0"
+(defconst package-el-version "1.0.1"
"Version of package.el.")
;; We don't prime the cache since it tends to get out of date.
@@ -735,6 +752,8 @@ It will move point to somewhere in the headers."
(package--with-work-buffer location file
(package-unpack name version))))
+(defvar package--initialized nil)
+
(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."
@@ -790,9 +809,8 @@ but version %s required"
"Need package `%s-%s', but only %s is available"
(symbol-name next-pkg) (package-version-join next-version)
(package-version-join (package-desc-vers (cdr pkg-desc)))))
- ;; Only add to the transaction if we don't already have it.
- (unless (memq next-pkg package-list)
- (push next-pkg package-list))
+ ;; Move to front, so it gets installed early enough (bug#14082).
+ (setq package-list (cons next-pkg (delq next-pkg package-list)))
(setq package-list
(package-compute-transaction package-list
(package-desc-reqs
@@ -855,8 +873,13 @@ Also, add the originating archive to the end of the package vector."
(version (package-desc-vers (cdr package)))
(entry (cons name
(vconcat (cdr package) (vector archive))))
- (existing-package (assq name package-archive-contents)))
- (cond ((not existing-package)
+ (existing-package (assq name package-archive-contents))
+ (pinned-to-archive (assoc name package-pinned-packages)))
+ (cond ((and pinned-to-archive
+ ;; If pinned to another archive, skip entirely.
+ (not (equal (cdr pinned-to-archive) archive)))
+ nil)
+ ((not existing-package)
(add-to-list 'package-archive-contents entry))
((version-list-< (package-desc-vers (cdr existing-package))
version)
@@ -896,8 +919,6 @@ using `package-compute-transaction'."
package-user-dir)
(package-activate elt (version-to-list v-string)))))
-(defvar package--initialized nil)
-
;;;###autoload
(defun package-install (name)
"Install the package named NAME.
@@ -1182,7 +1203,7 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages."
(require 'lisp-mnt)
(let ((package-name (symbol-name package))
(built-in (assq package package--builtins))
- desc pkg-dir reqs version installable)
+ desc pkg-dir reqs version installable archive)
(prin1 package)
(princ " is ")
(cond
@@ -1196,6 +1217,7 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages."
;; Available packages are in `package-archive-contents'.
((setq desc (cdr (assq package package-archive-contents)))
(setq version (package-version-join (package-desc-vers desc))
+ archive (aref desc (- (length desc) 1))
installable t)
(if built-in
(insert "a built-in package.\n\n")
@@ -1224,8 +1246,10 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages."
(installable
(if built-in
(insert (propertize "Built-in." 'font-lock-face 'font-lock-builtin-face)
- " Alternate version available -- ")
- (insert "Available -- "))
+ " Alternate version available")
+ (insert "Available"))
+ (insert " from " archive)
+ (insert " -- ")
(let ((button-text (if (display-graphic-p) "Install" "[Install]"))
(button-face (if (display-graphic-p)
'(:box (:line-width 2 :color "dark grey")
@@ -1588,10 +1612,11 @@ call will upgrade the package."
(length upgrades)
(if (= (length upgrades) 1) "" "s")))))
-(defun package-menu-execute ()
+(defun package-menu-execute (&optional noquery)
"Perform marked Package Menu actions.
Packages marked for installation are downloaded and installed;
-packages marked for deletion are removed."
+packages marked for deletion are removed.
+Optional argument NOQUERY non-nil means do not ask the user to confirm."
(interactive)
(unless (derived-mode-p 'package-menu-mode)
(error "The current buffer is not in Package Menu mode"))
@@ -1611,16 +1636,20 @@ packages marked for deletion are removed."
(push (car id) install-list))))
(forward-line)))
(when install-list
- (if (yes-or-no-p
+ (if (or
+ noquery
+ (yes-or-no-p
(if (= (length install-list) 1)
(format "Install package `%s'? " (car install-list))
(format "Install these %d packages (%s)? "
(length install-list)
- (mapconcat 'symbol-name install-list ", "))))
+ (mapconcat 'symbol-name install-list ", ")))))
(mapc 'package-install install-list)))
;; Delete packages, prompting if necessary.
(when delete-list
- (if (yes-or-no-p
+ (if (or
+ noquery
+ (yes-or-no-p
(if (= (length delete-list) 1)
(format "Delete package `%s-%s'? "
(caar delete-list)
@@ -1630,7 +1659,7 @@ packages marked for deletion are removed."
(mapconcat (lambda (elt)
(concat (car elt) "-" (cdr elt)))
delete-list
- ", "))))
+ ", ")))))
(dolist (elt delete-list)
(condition-case-unless-debug err
(package-delete (car elt) (cdr elt))