aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-06-21 10:12:56 -0400
committerStefan Monnier2013-06-21 10:12:56 -0400
commita7d2d4654e2dd1075df0c45c15cae52924a44ada (patch)
treea690c2f23f64fb58537d2f6cc9fb76e73f531711
parente67e483fabcc226a52adc3899ebdc43f5752c10d (diff)
downloademacs-a7d2d4654e2dd1075df0c45c15cae52924a44ada.tar.gz
emacs-a7d2d4654e2dd1075df0c45c15cae52924a44ada.zip
* lisp/emacs-lisp/package.el (package-alist): Include obsolete packages.
(package-obsolete-list): Remove. (package-activate): Remove min-version argument. Add `force' argument. Adjust to new package-alist format. (package-mark-obsolete): Remove. (package-unpack): Force reload of the package's autoloads. (package-installed-p): Check builtins if the installed package is not recent enough. (package-initialize): Don't reset package-obsolete-list. Don't specify which package version to activate. (package-process-define-package, describe-package-1) (package-menu--generate): Adjust to new package-alist format.
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/emacs-lisp/package.el142
2 files changed, 82 insertions, 75 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a64c2868462..414650b0656 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
12013-06-21 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/package.el (package-alist): Include obsolete packages.
4 (package-obsolete-list): Remove.
5 (package-activate): Remove min-version argument. Add `force' argument.
6 Adjust to new package-alist format.
7 (package-mark-obsolete): Remove.
8 (package-unpack): Force reload of the package's autoloads.
9 (package-installed-p): Check builtins if the installed package is not
10 recent enough.
11 (package-initialize): Don't reset package-obsolete-list.
12 Don't specify which package version to activate.
13 (package-process-define-package, describe-package-1)
14 (package-menu--generate): Adjust to new package-alist format.
15
12013-06-21 Juanma Barranquero <lekktu@gmail.com> 162013-06-21 Juanma Barranquero <lekktu@gmail.com>
2 17
3 * allout-widgets.el (allout-widgets-mode-off) 18 * allout-widgets.el (allout-widgets-mode-off)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 1bf1e6027e2..5fdc870dec3 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -192,8 +192,7 @@ versions of all packages not specified by other elements.
192 192
193For an element (NAME VERSION), NAME is a package name (a symbol). 193For an element (NAME VERSION), NAME is a package name (a symbol).
194VERSION should be t, a string, or nil. 194VERSION should be t, a string, or nil.
195If VERSION is t, all versions are loaded, though obsolete ones 195If VERSION is t, the most recent version is activated.
196 will be put in `package-obsolete-list' and not activated.
197If VERSION is a string, only that version is ever loaded. 196If VERSION is a string, only that version is ever loaded.
198 Any other version, even if newer, is silently ignored. 197 Any other version, even if newer, is silently ignored.
199 Hence, the package is \"held\" at that version. 198 Hence, the package is \"held\" at that version.
@@ -371,8 +370,9 @@ name (a symbol) and DESC is a `package--bi-desc' structure.")
371 370
372(defvar package-alist nil 371(defvar package-alist nil
373 "Alist of all packages available for activation. 372 "Alist of all packages available for activation.
374Each element has the form (PKG . DESC), where PKG is a package 373Each element has the form (PKG . DESCS), where PKG is a package
375name (a symbol) and DESC is a `package-desc' structure. 374name (a symbol) and DESCS is a non-empty list of `package-desc' structure,
375sorted by decreasing versions.
376 376
377This variable is set automatically by `package-load-descriptor', 377This variable is set automatically by `package-load-descriptor',
378called via `package-initialize'. To change which packages are 378called via `package-initialize'. To change which packages are
@@ -384,11 +384,6 @@ loaded and/or activated, customize `package-load-list'.")
384 "List of the names of currently activated packages.") 384 "List of the names of currently activated packages.")
385(put 'package-activated-list 'risky-local-variable t) 385(put 'package-activated-list 'risky-local-variable t)
386 386
387(defvar package-obsolete-list nil
388 "List of obsolete packages.
389Each element of the list is a `package-desc'.")
390(put 'package-obsolete-list 'risky-local-variable t)
391
392(defun package-version-join (vlist) 387(defun package-version-join (vlist)
393 "Return the version string corresponding to the list VLIST. 388 "Return the version string corresponding to the list VLIST.
394This is, approximately, the inverse of `version-to-list'. 389This is, approximately, the inverse of `version-to-list'.
@@ -439,7 +434,7 @@ controls which package subdirectories may be loaded.
439 434
440In each valid package subdirectory, this function loads the 435In each valid package subdirectory, this function loads the
441description file containing a call to `define-package', which 436description file containing a call to `define-package', which
442updates `package-alist' and `package-obsolete-list'." 437updates `package-alist'."
443 (dolist (dir (cons package-user-dir package-directory-list)) 438 (dolist (dir (cons package-user-dir package-directory-list))
444 (when (file-directory-p dir) 439 (when (file-directory-p dir)
445 (dolist (subdir (directory-files dir)) 440 (dolist (subdir (directory-files dir))
@@ -502,33 +497,33 @@ specifying the minimum acceptable version."
502;; if an older one was already activated. This is not ideal; we'd at 497;; if an older one was already activated. This is not ideal; we'd at
503;; least need to check to see if the package has actually been loaded, 498;; least need to check to see if the package has actually been loaded,
504;; and not merely activated. 499;; and not merely activated.
505(defun package-activate (package min-version) 500(defun package-activate (package &optional force)
506 "Activate package PACKAGE, of version MIN-VERSION or newer. 501 "Activate package PACKAGE.
507MIN-VERSION should be a version list. 502If FORCE is true, (re-)activate it if it's already activated."
508If PACKAGE has any dependencies, recursively activate them. 503 (let ((pkg-descs (cdr (assq package package-alist))))
509Return nil if the package could not be activated."
510 (let ((pkg-vec (cdr (assq package package-alist)))
511 available-version found)
512 ;; Check if PACKAGE is available in `package-alist'. 504 ;; Check if PACKAGE is available in `package-alist'.
513 (when pkg-vec 505 (while
514 (setq available-version (package-desc-version pkg-vec) 506 (when pkg-descs
515 found (version-list-<= min-version available-version))) 507 (let ((available-version (package-desc-version (car pkg-descs))))
508 (or (package-disabled-p package available-version)
509 ;; Prefer a builtin package.
510 (package-built-in-p package available-version))))
511 (setq pkg-descs (cdr pkg-descs)))
516 (cond 512 (cond
517 ;; If no such package is found, maybe it's built-in. 513 ;; If no such package is found, maybe it's built-in.
518 ((null found) 514 ((null pkg-descs)
519 (package-built-in-p package min-version)) 515 (package-built-in-p package))
520 ;; If the package is already activated, just return t. 516 ;; If the package is already activated, just return t.
521 ((memq package package-activated-list) 517 ((and (memq package package-activated-list) (not force))
522 t) 518 t)
523 ;; If it's disabled, then just skip it.
524 ((package-disabled-p package available-version) nil)
525 ;; Otherwise, proceed with activation. 519 ;; Otherwise, proceed with activation.
526 (t 520 (t
527 (let ((fail (catch 'dep-failure 521 (let* ((pkg-vec (car pkg-descs))
528 ;; Activate its dependencies recursively. 522 (fail (catch 'dep-failure
529 (dolist (req (package-desc-reqs pkg-vec)) 523 ;; Activate its dependencies recursively.
530 (unless (package-activate (car req) (cadr req)) 524 (dolist (req (package-desc-reqs pkg-vec))
531 (throw 'dep-failure req)))))) 525 (unless (package-activate (car req) (cadr req))
526 (throw 'dep-failure req))))))
532 (if fail 527 (if fail
533 (warn "Unable to activate package `%s'. 528 (warn "Unable to activate package `%s'.
534Required package `%s-%s' is unavailable" 529Required package `%s-%s' is unavailable"
@@ -536,10 +531,6 @@ Required package `%s-%s' is unavailable"
536 ;; If all goes well, activate the package itself. 531 ;; If all goes well, activate the package itself.
537 (package-activate-1 pkg-vec))))))) 532 (package-activate-1 pkg-vec)))))))
538 533
539(defun package-mark-obsolete (pkg-desc)
540 "Put PKG-DESC on the obsolete list, if not already there."
541 (push pkg-desc package-obsolete-list))
542
543(defun define-package (_name-string _version-string 534(defun define-package (_name-string _version-string
544 &optional _docstring _requirements 535 &optional _docstring _requirements
545 &rest _extra-properties) 536 &rest _extra-properties)
@@ -561,26 +552,18 @@ EXTRA-PROPERTIES is currently unused."
561 (let* ((new-pkg-desc (apply #'package-desc-from-define (cdr exp))) 552 (let* ((new-pkg-desc (apply #'package-desc-from-define (cdr exp)))
562 (name (package-desc-name new-pkg-desc)) 553 (name (package-desc-name new-pkg-desc))
563 (version (package-desc-version new-pkg-desc)) 554 (version (package-desc-version new-pkg-desc))
564 (old-pkg (assq name package-alist))) 555 (old-pkgs (assq name package-alist)))
565 (cond 556 (if (null old-pkgs)
566 ;; If it's not newer than a builtin version, mark it obsolete. 557 ;; If there's no old package, just add this to `package-alist'.
567 ((let ((bi (assq name package--builtin-versions))) 558 (push (list name new-pkg-desc) package-alist)
568 (and bi (version-list-<= version (cdr bi)))) 559 ;; If there is, insert the new package at the right place in the list.
569 (package-mark-obsolete new-pkg-desc)) 560 (while old-pkgs
570 ;; If there's no old package, just add this to `package-alist'. 561 (cond
571 ((null old-pkg) 562 ((null (cdr old-pkgs)) (push new-pkg-desc (cdr old-pkgs)))
572 (push (cons name new-pkg-desc) package-alist)) 563 ((version-list-< (package-desc-version (cadr old-pkgs)) version)
573 ((version-list-< (package-desc-version (cdr old-pkg)) version) 564 (push new-pkg-desc (cdr old-pkgs))
574 ;; Remove the old package and declare it obsolete. 565 (setq old-pkgs nil)))
575 (package-mark-obsolete (cdr old-pkg)) 566 (setq old-pkgs (cdr old-pkgs))))
576 (setq package-alist (cons (cons name new-pkg-desc)
577 (delq old-pkg package-alist))))
578 ;; You can have two packages with the same version, e.g. one in
579 ;; the system package directory and one in your private
580 ;; directory. We just let the first one win.
581 ((not (version-list-= (package-desc-version (cdr old-pkg)) version))
582 ;; The package is born obsolete.
583 (package-mark-obsolete new-pkg-desc)))
584 new-pkg-desc)) 567 new-pkg-desc))
585 568
586;; From Emacs 22, but changed so it adds to load-path. 569;; From Emacs 22, but changed so it adds to load-path.
@@ -691,7 +674,7 @@ untar into a directory named DIR; otherwise, signal an error."
691 ;; and then compile them. 674 ;; and then compile them.
692 (package--compile new-desc)) 675 (package--compile new-desc))
693 ;; Try to activate it. 676 ;; Try to activate it.
694 (package-activate name (package-desc-version pkg-desc)) 677 (package-activate name 'force)
695 pkg-dir)) 678 pkg-dir))
696 679
697(defun package--make-autoloads-and-stuff (pkg-desc pkg-dir) 680(defun package--make-autoloads-and-stuff (pkg-desc pkg-dir)
@@ -768,12 +751,13 @@ It will move point to somewhere in the headers."
768 "Return true if PACKAGE, of MIN-VERSION or newer, is installed. 751 "Return true if PACKAGE, of MIN-VERSION or newer, is installed.
769MIN-VERSION should be a version list." 752MIN-VERSION should be a version list."
770 (unless package--initialized (error "package.el is not yet initialized!")) 753 (unless package--initialized (error "package.el is not yet initialized!"))
771 (let ((pkg-desc (assq package package-alist))) 754 (or
772 (if pkg-desc 755 (let ((pkg-descs (cdr (assq package package-alist))))
773 (version-list-<= min-version 756 (and pkg-descs
774 (package-desc-version (cdr pkg-desc))) 757 (version-list-<= min-version
775 ;; Also check built-in packages. 758 (package-desc-version (car pkg-descs)))))
776 (package-built-in-p package min-version)))) 759 ;; Also check built-in packages.
760 (package-built-in-p package min-version)))
777 761
778(defun package-compute-transaction (package-list requirements) 762(defun package-compute-transaction (package-list requirements)
779 "Return a list of packages to be installed, including PACKAGE-LIST. 763 "Return a list of packages to be installed, including PACKAGE-LIST.
@@ -905,7 +889,8 @@ Also, add the originating archive to the `package-desc' structure."
905 (let ((bi (assq name package--builtin-versions))) 889 (let ((bi (assq name package--builtin-versions)))
906 (and bi (version-list-<= version (cdr bi)))) 890 (and bi (version-list-<= version (cdr bi))))
907 (let ((ins (cdr (assq name package-alist)))) 891 (let ((ins (cdr (assq name package-alist))))
908 (and ins (version-list-<= version (package-desc-version ins))))) 892 (and ins (version-list-<= version
893 (package-desc-version (car ins))))))
909 nil) 894 nil)
910 ((not existing-package) 895 ((not existing-package)
911 (push entry package-archive-contents)) 896 (push entry package-archive-contents))
@@ -1109,13 +1094,12 @@ makes them available for download."
1109The variable `package-load-list' controls which packages to load. 1094The variable `package-load-list' controls which packages to load.
1110If optional arg NO-ACTIVATE is non-nil, don't activate packages." 1095If optional arg NO-ACTIVATE is non-nil, don't activate packages."
1111 (interactive) 1096 (interactive)
1112 (setq package-alist nil 1097 (setq package-alist nil)
1113 package-obsolete-list nil)
1114 (package-load-all-descriptors) 1098 (package-load-all-descriptors)
1115 (package-read-all-archive-contents) 1099 (package-read-all-archive-contents)
1116 (unless no-activate 1100 (unless no-activate
1117 (dolist (elt package-alist) 1101 (dolist (elt package-alist)
1118 (package-activate (car elt) (package-desc-version (cdr elt))))) 1102 (package-activate (car elt))))
1119 (setq package--initialized t)) 1103 (setq package--initialized t))
1120 1104
1121 1105
@@ -1161,7 +1145,7 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages."
1161 (princ " is ") 1145 (princ " is ")
1162 (cond 1146 (cond
1163 ;; Loaded packages are in `package-alist'. 1147 ;; Loaded packages are in `package-alist'.
1164 ((setq desc (cdr (assq package package-alist))) 1148 ((setq desc (cadr (assq package package-alist)))
1165 (setq version (package-version-join (package-desc-version desc))) 1149 (setq version (package-version-join (package-desc-version desc)))
1166 (if (setq pkg-dir (package-desc-dir desc)) 1150 (if (setq pkg-dir (package-desc-dir desc))
1167 (insert "an installed package.\n\n") 1151 (insert "an installed package.\n\n")
@@ -1389,10 +1373,23 @@ or a list of package names (symbols) to display."
1389 (dolist (elt package-alist) 1373 (dolist (elt package-alist)
1390 (setq name (car elt)) 1374 (setq name (car elt))
1391 (when (or (eq packages t) (memq name packages)) 1375 (when (or (eq packages t) (memq name packages))
1392 (package--push (cdr elt) 1376 (let* ((lle (assq name package-load-list))
1393 (if (stringp (cadr (assq name package-load-list))) 1377 (held (cadr lle))
1394 "held" "installed") 1378 (hv (if (stringp held) (version-to-list held))))
1395 info-list))) 1379 (dolist (pkg (cdr elt))
1380 (let ((version (package-desc-version pkg)))
1381 (package--push pkg
1382 (cond
1383 ((and lle (null held)) "disabled")
1384 (hv
1385 (cond
1386 ((version-list-= version hv) "held")
1387 ((version-list-< version hv) "obsolete")
1388 (t "disabled")))
1389 ((package-built-in-p name version) "obsolete")
1390 ((eq pkg (cadr elt)) "installed")
1391 (t "obsolete"))
1392 info-list))))))
1396 1393
1397 ;; Built-in packages: 1394 ;; Built-in packages:
1398 (dolist (elt package--builtins) 1395 (dolist (elt package--builtins)
@@ -1415,11 +1412,6 @@ or a list of package names (symbols) to display."
1415 (t "available")) 1412 (t "available"))
1416 info-list)))) 1413 info-list))))
1417 1414
1418 ;; Obsolete packages:
1419 (dolist (elt package-obsolete-list)
1420 (when (or (eq packages t) (memq (package-desc-full-name elt) packages))
1421 (package--push elt "obsolete" info-list)))
1422
1423 ;; Print the result. 1415 ;; Print the result.
1424 (setq tabulated-list-entries (mapcar 'package-menu--print-info info-list)) 1416 (setq tabulated-list-entries (mapcar 'package-menu--print-info info-list))
1425 (tabulated-list-print remember-pos))) 1417 (tabulated-list-print remember-pos)))