aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/package.el101
1 files changed, 75 insertions, 26 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 409dfedb74b..a8362cb2050 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -120,9 +120,9 @@
120;; - "installed" instead of a blank in the status column 120;; - "installed" instead of a blank in the status column
121;; - tramp needs its files to be compiled in a certain order. 121;; - tramp needs its files to be compiled in a certain order.
122;; how to handle this? fix tramp? 122;; how to handle this? fix tramp?
123;; - maybe we need separate .elc directories for various emacs versions 123;; - maybe we need separate .elc directories for various emacs
124;; and also emacs-vs-xemacs. That way conditional compilation can 124;; versions. That way conditional compilation can work. But would
125;; work. But would this break anything? 125;; this break anything?
126;; - William Xu suggests being able to open a package file without 126;; - William Xu suggests being able to open a package file without
127;; installing it 127;; installing it
128;; - Interface with desktop.el so that restarting after an install 128;; - Interface with desktop.el so that restarting after an install
@@ -357,9 +357,9 @@ contents of the archive."
357 357
358(defun package-check-signature () 358(defun package-check-signature ()
359 "Check whether we have a usable OpenPGP configuration. 359 "Check whether we have a usable OpenPGP configuration.
360If true, and `package-check-signature' is `allow-unsigned', 360If so, and variable `package-check-signature' is
361return `allow-unsigned', otherwise return the value of 361`allow-unsigned', return `allow-unsigned', otherwise return the
362`package-check-signature'." 362value of variable `package-check-signature'."
363 (if (eq package-check-signature 'allow-unsigned) 363 (if (eq package-check-signature 'allow-unsigned)
364 (progn 364 (progn
365 (require 'epg-config) 365 (require 'epg-config)
@@ -475,6 +475,8 @@ Slots:
475 signed) 475 signed)
476 476
477(defun package--from-builtin (bi-desc) 477(defun package--from-builtin (bi-desc)
478 "Create a `package-desc' object from BI-DESC.
479BI-DESC should be a `package--bi-desc' object."
478 (package-desc-create :name (pop bi-desc) 480 (package-desc-create :name (pop bi-desc)
479 :version (package--bi-desc-version bi-desc) 481 :version (package--bi-desc-version bi-desc)
480 :summary (package--bi-desc-summary bi-desc) 482 :summary (package--bi-desc-summary bi-desc)
@@ -512,11 +514,21 @@ This is, approximately, the inverse of `version-to-list'.
512 (apply #'concat (nreverse str-list))))) 514 (apply #'concat (nreverse str-list)))))
513 515
514(defun package-desc-full-name (pkg-desc) 516(defun package-desc-full-name (pkg-desc)
517 "Return full name of package-desc object PKG-DESC.
518This is the name of the package with its version appended."
515 (format "%s-%s" 519 (format "%s-%s"
516 (package-desc-name pkg-desc) 520 (package-desc-name pkg-desc)
517 (package-version-join (package-desc-version pkg-desc)))) 521 (package-version-join (package-desc-version pkg-desc))))
518 522
519(defun package-desc-suffix (pkg-desc) 523(defun package-desc-suffix (pkg-desc)
524 "Return file-name extension of package-desc object PKG-DESC.
525Depending on the `package-desc-kind' of PKG-DESC, this is one of:
526
527 'single - \".el\"
528 'tar - \".tar\"
529 'dir - \"\"
530
531Signal an error if the kind is none of the above."
520 (pcase (package-desc-kind pkg-desc) 532 (pcase (package-desc-kind pkg-desc)
521 ('single ".el") 533 ('single ".el")
522 ('tar ".tar") 534 ('tar ".tar")
@@ -524,6 +536,10 @@ This is, approximately, the inverse of `version-to-list'.
524 (kind (error "Unknown package kind: %s" kind)))) 536 (kind (error "Unknown package kind: %s" kind))))
525 537
526(defun package-desc--keywords (pkg-desc) 538(defun package-desc--keywords (pkg-desc)
539 "Return keywords of package-desc object PKG-DESC.
540These keywords come from the foo-pkg.el file, and in general
541corresponds to the keywords in the \"Keywords\" header of the
542package."
527 (let ((keywords (cdr (assoc :keywords (package-desc-extras pkg-desc))))) 543 (let ((keywords (cdr (assoc :keywords (package-desc-extras pkg-desc)))))
528 (if (eq (car-safe keywords) 'quote) 544 (if (eq (car-safe keywords) 'quote)
529 (nth 1 keywords) 545 (nth 1 keywords)
@@ -533,10 +549,10 @@ This is, approximately, the inverse of `version-to-list'.
533 "Return the priority of the archive of package-desc object P." 549 "Return the priority of the archive of package-desc object P."
534 (package-archive-priority (package-desc-archive p))) 550 (package-archive-priority (package-desc-archive p)))
535 551
536;; Package descriptor format used in finder-inf.el and package--builtins.
537(cl-defstruct (package--bi-desc 552(cl-defstruct (package--bi-desc
538 (:constructor package-make-builtin (version summary)) 553 (:constructor package-make-builtin (version summary))
539 (:type vector)) 554 (:type vector))
555 "Package descriptor format used in finder-inf.el and package--builtins."
540 version 556 version
541 reqs 557 reqs
542 summary) 558 summary)
@@ -578,7 +594,15 @@ loaded and/or activated, customize `package-load-list'.")
578;; The following functions are called on each installed package by 594;; The following functions are called on each installed package by
579;; `package-load-all-descriptors', which ultimately populates the 595;; `package-load-all-descriptors', which ultimately populates the
580;; `package-alist' variable. 596;; `package-alist' variable.
597
581(defun package-process-define-package (exp) 598(defun package-process-define-package (exp)
599 "Process define-package expression EXP and push it to `package-alist'.
600EXP should be a form read from a foo-pkg.el file.
601Convert EXP into a `package-desc' object using the
602`package-desc-from-define' constructor before pushing it to
603`package-alist'.
604If there already exists a package by that name in
605`package-alist', replace that definition with the new one."
582 (when (eq (car-safe exp) 'define-package) 606 (when (eq (car-safe exp) 'define-package)
583 (let* ((new-pkg-desc (apply #'package-desc-from-define (cdr exp))) 607 (let* ((new-pkg-desc (apply #'package-desc-from-define (cdr exp)))
584 (name (package-desc-name new-pkg-desc)) 608 (name (package-desc-name new-pkg-desc))
@@ -869,6 +893,7 @@ untar into a directory named DIR; otherwise, signal an error."
869 (mapcar #'macroexp-quote 893 (mapcar #'macroexp-quote
870 (apply #'nconc 894 (apply #'nconc
871 (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist)))) 895 (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist))))
896
872(defun package-unpack (pkg-desc) 897(defun package-unpack (pkg-desc)
873 "Install the contents of the current buffer as a package." 898 "Install the contents of the current buffer as a package."
874 (let* ((name (package-desc-name pkg-desc)) 899 (let* ((name (package-desc-name pkg-desc))
@@ -1902,12 +1927,13 @@ if all the in-between dependencies are also in PACKAGE-LIST."
1902;; installed in a variety of ways (archives, buffer, file), but 1927;; installed in a variety of ways (archives, buffer, file), but
1903;; requirements (dependencies) are always satisfied by looking in 1928;; requirements (dependencies) are always satisfied by looking in
1904;; `package-archive-contents'. 1929;; `package-archive-contents'.
1930
1905(defun package-archive-base (desc) 1931(defun package-archive-base (desc)
1906 "Return the archive containing the package NAME." 1932 "Return the package described by DESC."
1907 (cdr (assoc (package-desc-archive desc) package-archives))) 1933 (cdr (assoc (package-desc-archive desc) package-archives)))
1908 1934
1909(defun package-install-from-archive (pkg-desc) 1935(defun package-install-from-archive (pkg-desc)
1910 "Download and install a tar package." 1936 "Download and install a tar package defined by PKG-DESC."
1911 ;; This won't happen, unless the archive is doing something wrong. 1937 ;; This won't happen, unless the archive is doing something wrong.
1912 (when (eq (package-desc-kind pkg-desc) 'dir) 1938 (when (eq (package-desc-kind pkg-desc) 'dir)
1913 (error "Can't install directory package from archive")) 1939 (error "Can't install directory package from archive"))
@@ -2084,7 +2110,7 @@ Downloads and installs required packages as needed."
2084 2110
2085;;;###autoload 2111;;;###autoload
2086(defun package-install-file (file) 2112(defun package-install-file (file)
2087 "Install a package from a file. 2113 "Install a package from FILE.
2088The file can either be a tar file, an Emacs Lisp file, or a 2114The file can either be a tar file, an Emacs Lisp file, or a
2089directory." 2115directory."
2090 (interactive "fPackage file name: ") 2116 (interactive "fPackage file name: ")
@@ -2220,7 +2246,7 @@ object."
2220 2246
2221;;;###autoload 2247;;;###autoload
2222(defun package-autoremove () 2248(defun package-autoremove ()
2223 "Remove packages that are no more needed. 2249 "Remove packages that are no longer needed.
2224 2250
2225Packages that are no more needed by other packages in 2251Packages that are no more needed by other packages in
2226`package-selected-packages' and their dependencies 2252`package-selected-packages' and their dependencies
@@ -2337,6 +2363,8 @@ The description is read from the installed package files."
2337 ))) 2363 )))
2338 2364
2339(defun describe-package-1 (pkg) 2365(defun describe-package-1 (pkg)
2366 "Insert the package description for PKG.
2367Helper function for `describe-package'."
2340 (require 'lisp-mnt) 2368 (require 'lisp-mnt)
2341 (let* ((desc (or 2369 (let* ((desc (or
2342 (if (package-desc-p pkg) pkg) 2370 (if (package-desc-p pkg) pkg)
@@ -2566,6 +2594,9 @@ The description is read from the installed package files."
2566 (browse-url-add-buttons)))) 2594 (browse-url-add-buttons))))
2567 2595
2568(defun package-install-button-action (button) 2596(defun package-install-button-action (button)
2597 "Run `package-install' on the package BUTTON points to.
2598Used for the 'action property of buttons in the buffer created by
2599`describe-package'."
2569 (let ((pkg-desc (button-get button 'package-desc))) 2600 (let ((pkg-desc (button-get button 'package-desc)))
2570 (when (y-or-n-p (format-message "Install package `%s'? " 2601 (when (y-or-n-p (format-message "Install package `%s'? "
2571 (package-desc-full-name pkg-desc))) 2602 (package-desc-full-name pkg-desc)))
@@ -2574,6 +2605,9 @@ The description is read from the installed package files."
2574 (goto-char (point-min))))) 2605 (goto-char (point-min)))))
2575 2606
2576(defun package-delete-button-action (button) 2607(defun package-delete-button-action (button)
2608 "Run `package-delete' on the package BUTTON points to.
2609Used for the 'action property of buttons in the buffer created by
2610`describe-package'."
2577 (let ((pkg-desc (button-get button 'package-desc))) 2611 (let ((pkg-desc (button-get button 'package-desc)))
2578 (when (y-or-n-p (format-message "Delete package `%s'? " 2612 (when (y-or-n-p (format-message "Delete package `%s'? "
2579 (package-desc-full-name pkg-desc))) 2613 (package-desc-full-name pkg-desc)))
@@ -2582,10 +2616,17 @@ The description is read from the installed package files."
2582 (goto-char (point-min))))) 2616 (goto-char (point-min)))))
2583 2617
2584(defun package-keyword-button-action (button) 2618(defun package-keyword-button-action (button)
2619 "Show filtered \"*Packages*\" buffer for BUTTON.
2620The buffer is filtered by the `package-keyword' property of BUTTON.
2621Used for the 'action property of buttons in the buffer created by
2622`describe-package'."
2585 (let ((pkg-keyword (button-get button 'package-keyword))) 2623 (let ((pkg-keyword (button-get button 'package-keyword)))
2586 (package-show-package-list t (list pkg-keyword)))) 2624 (package-show-package-list t (list pkg-keyword))))
2587 2625
2588(defun package-make-button (text &rest props) 2626(defun package-make-button (text &rest properties)
2627 "Insert button labeled TEXT with button PROPERTIES at point.
2628PROPERTIES are passed to `insert-text-button', for which this
2629function is a convenience wrapper used by `describe-package-1'."
2589 (let ((button-text (if (display-graphic-p) text (concat "[" text "]"))) 2630 (let ((button-text (if (display-graphic-p) text (concat "[" text "]")))
2590 (button-face (if (display-graphic-p) 2631 (button-face (if (display-graphic-p)
2591 '(:box (:line-width 2 :color "dark grey") 2632 '(:box (:line-width 2 :color "dark grey")
@@ -2593,20 +2634,23 @@ The description is read from the installed package files."
2593 :foreground "black") 2634 :foreground "black")
2594 'link))) 2635 'link)))
2595 (apply #'insert-text-button button-text 'face button-face 'follow-link t 2636 (apply #'insert-text-button button-text 'face button-face 'follow-link t
2596 props))) 2637 properties)))
2597 2638
2598(defun package--print-email-button (name) 2639(defun package--print-email-button (recipient)
2599 (when (car name) 2640 "Insert a button whose action will send an email to RECIPIENT.
2600 (insert (car name))) 2641NAME should have the form (FULLNAME . EMAIL) where FULLNAME is
2601 (when (and (car name) (cdr name)) 2642either a full name or nil, and EMAIL is a valid email address."
2643 (when (car recipient)
2644 (insert (car recipient)))
2645 (when (and (car recipient) (cdr recipient))
2602 (insert " ")) 2646 (insert " "))
2603 (when (cdr name) 2647 (when (cdr recipient)
2604 (insert "<") 2648 (insert "<")
2605 (insert-text-button (cdr name) 2649 (insert-text-button (cdr recipient)
2606 'follow-link t 2650 'follow-link t
2607 'action (lambda (_) 2651 'action (lambda (_)
2608 (compose-mail 2652 (compose-mail
2609 (format "%s <%s>" (car name) (cdr name))))) 2653 (format "%s <%s>" (car recipient) (cdr recipient)))))
2610 (insert ">")) 2654 (insert ">"))
2611 (insert "\n")) 2655 (insert "\n"))
2612 2656
@@ -2704,13 +2748,13 @@ package PKG-DESC, add one. The alist is keyed with PKG-DESC."
2704 (push (cons ,pkg-desc ,status) ,listname))) 2748 (push (cons ,pkg-desc ,status) ,listname)))
2705 2749
2706(defvar package-list-unversioned nil 2750(defvar package-list-unversioned nil
2707 "If non-nil include packages that don't have a version in `list-package'.") 2751 "If non-nil, include packages that don't have a version in `list-packages'.")
2708 2752
2709(defvar package-list-unsigned nil 2753(defvar package-list-unsigned nil
2710 "If non-nil, mention in the list which packages were installed w/o signature.") 2754 "If non-nil, mention in the list which packages were installed w/o signature.")
2711 2755
2712(defvar package--emacs-version-list (version-to-list emacs-version) 2756(defvar package--emacs-version-list (version-to-list emacs-version)
2713 "`emacs-version', as a list.") 2757 "The value of variable `emacs-version' as a list.")
2714 2758
2715(defun package--incompatible-p (pkg &optional shallow) 2759(defun package--incompatible-p (pkg &optional shallow)
2716 "Return non-nil if PKG has no chance of being installable. 2760 "Return non-nil if PKG has no chance of being installable.
@@ -2785,7 +2829,7 @@ Can be toggled with \\<package-menu-mode-map> \\[package-menu-toggle-hiding].
2785Installed obsolete packages are always displayed.") 2829Installed obsolete packages are always displayed.")
2786 2830
2787(defun package-menu-toggle-hiding () 2831(defun package-menu-toggle-hiding ()
2788 "Toggle visibility of obsolete available packages." 2832 "In Package Menu, toggle visibility of obsolete available packages."
2789 (interactive) 2833 (interactive)
2790 (unless (derived-mode-p 'package-menu-mode) 2834 (unless (derived-mode-p 'package-menu-mode)
2791 (user-error "The current buffer is not a Package Menu")) 2835 (user-error "The current buffer is not a Package Menu"))
@@ -3103,7 +3147,7 @@ user-error if there is already a refresh running asynchronously."
3103 (package-refresh-contents package-menu-async)) 3147 (package-refresh-contents package-menu-async))
3104 3148
3105(defun package-menu-hide-package () 3149(defun package-menu-hide-package ()
3106 "Hide a package under point. 3150 "Hide a package under point in Package Menu.
3107If optional arg BUTTON is non-nil, describe its associated package." 3151If optional arg BUTTON is non-nil, describe its associated package."
3108 (interactive) 3152 (interactive)
3109 (declare (interactive-only "change `package-hidden-regexps' instead.")) 3153 (declare (interactive-only "change `package-hidden-regexps' instead."))
@@ -3202,6 +3246,7 @@ The full list of keys can be viewed with \\[describe-mode]."
3202 'package-menu-view-commentary 'package-menu-describe-package "24.1") 3246 'package-menu-view-commentary 'package-menu-describe-package "24.1")
3203 3247
3204(defun package-menu-get-status () 3248(defun package-menu-get-status ()
3249 "Return status text of package at point in Package Menu."
3205 (let* ((id (tabulated-list-get-id)) 3250 (let* ((id (tabulated-list-get-id))
3206 (entry (and id (assoc id tabulated-list-entries)))) 3251 (entry (and id (assoc id tabulated-list-entries))))
3207 (if entry 3252 (if entry
@@ -3227,6 +3272,10 @@ consideration."
3227 (package-desc-version pkg-desc))) 3272 (package-desc-version pkg-desc)))
3228 3273
3229(defun package-menu--find-upgrades () 3274(defun package-menu--find-upgrades ()
3275 "In Package Menu, return an alist of packages that can be upgraded.
3276The alist has the same form as `package-alist', namely a list
3277of (PKG . DESCS), but where DESCS is the `package-desc' object
3278corresponding to the newer version."
3230 (let (installed available upgrades) 3279 (let (installed available upgrades)
3231 ;; Build list of installed/available packages in this buffer. 3280 ;; Build list of installed/available packages in this buffer.
3232 (dolist (entry tabulated-list-entries) 3281 (dolist (entry tabulated-list-entries)
@@ -3490,7 +3539,7 @@ Store this list in `package-menu--new-package-list'."
3490 3539
3491 3540
3492(defun package-menu--post-refresh () 3541(defun package-menu--post-refresh ()
3493 "If there's a *Packages* buffer, revert it and check for new packages and upgrades. 3542 "Revert \"*Packages*\" buffer and check for new packages and upgrades.
3494Do nothing if there's no *Packages* buffer. 3543Do nothing if there's no *Packages* buffer.
3495 3544
3496This function is called after `package-refresh-contents' and it 3545This function is called after `package-refresh-contents' and it