Commit 578f0067 authored by Artur Malabarba's avatar Artur Malabarba

* lisp/emacs-lisp/package.el: Better dependency description

(package--used-elsewhere-p): New optional arg, ALL, and return
package-desc objects instead of names.
(package-delete): Update accordingly.
(describe-package-1): Describe which packages require the package.
parent 0c5fa361
...@@ -1646,21 +1646,25 @@ These are packages which are neither contained in ...@@ -1646,21 +1646,25 @@ These are packages which are neither contained in
unless (memq p needed) unless (memq p needed)
collect p))) collect p)))
(defun package--used-elsewhere-p (pkg-desc &optional pkg-list) (defun package--used-elsewhere-p (pkg-desc &optional pkg-list all)
"Non-nil if PKG-DESC is a dependency of a package in PKG-LIST. "Non-nil if PKG-DESC is a dependency of a package in PKG-LIST.
Return the first package found in PKG-LIST of which PKG is a Return the first package found in PKG-LIST of which PKG is a
dependency. dependency. If ALL is non-nil, return all such packages instead.
When not specified, PKG-LIST defaults to `package-alist' When not specified, PKG-LIST defaults to `package-alist'
with PKG-DESC entry removed." with PKG-DESC entry removed."
(unless (string= (package-desc-status pkg-desc) "obsolete") (unless (string= (package-desc-status pkg-desc) "obsolete")
(let ((pkg (package-desc-name pkg-desc))) (let* ((pkg (package-desc-name pkg-desc))
(cl-loop with alist = (or pkg-list (alist (or pkg-list
(remove (assq pkg package-alist) (remove (assq pkg package-alist)
package-alist)) package-alist))))
for p in alist thereis (if all
(and (memq pkg (mapcar #'car (package-desc-reqs (cadr p)))) (cl-loop for p in alist
(car p)))))) if (assq pkg (package-desc-reqs (cadr p)))
collect (cadr p))
(cl-loop for p in alist thereis
(and (assq pkg (package-desc-reqs (cadr p)))
(cadr p)))))))
(defun package--sort-deps-in-alist (package only) (defun package--sort-deps-in-alist (package only)
"Return a list of dependencies for PACKAGE sorted by dependency. "Return a list of dependencies for PACKAGE sorted by dependency.
...@@ -2027,7 +2031,7 @@ If NOSAVE is non-nil, the package is not removed from ...@@ -2027,7 +2031,7 @@ If NOSAVE is non-nil, the package is not removed from
;; Don't delete packages used as dependency elsewhere. ;; Don't delete packages used as dependency elsewhere.
(error "Package `%s' is used by `%s' as dependency, not deleting" (error "Package `%s' is used by `%s' as dependency, not deleting"
(package-desc-full-name pkg-desc) (package-desc-full-name pkg-desc)
pkg-used-elsewhere-by)) (package-desc-name pkg-used-elsewhere-by)))
(t (t
(delete-directory dir t t) (delete-directory dir t t)
;; Remove NAME-VERSION.signed file. ;; Remove NAME-VERSION.signed file.
...@@ -2127,6 +2131,7 @@ will be deleted." ...@@ -2127,6 +2131,7 @@ will be deleted."
(name (if desc (package-desc-name desc) pkg)) (name (if desc (package-desc-name desc) pkg))
(pkg-dir (if desc (package-desc-dir desc))) (pkg-dir (if desc (package-desc-dir desc)))
(reqs (if desc (package-desc-reqs desc))) (reqs (if desc (package-desc-reqs desc)))
(required-by (if desc (package--used-elsewhere-p desc nil 'all)))
(version (if desc (package-desc-version desc))) (version (if desc (package-desc-version desc)))
(archive (if desc (package-desc-archive desc))) (archive (if desc (package-desc-archive desc)))
(extras (and desc (package-desc-extras desc))) (extras (and desc (package-desc-extras desc)))
...@@ -2212,6 +2217,19 @@ will be deleted." ...@@ -2212,6 +2217,19 @@ will be deleted."
(help-insert-xref-button text 'help-package name) (help-insert-xref-button text 'help-package name)
(insert reason))) (insert reason)))
(insert "\n"))) (insert "\n")))
(when required-by
(insert (propertize "Required by" 'font-lock-face 'bold) ": ")
(let ((first t))
(dolist (pkg required-by)
(let ((text (package-desc-full-name pkg)))
(cond (first (setq first nil))
((>= (+ 2 (current-column) (length text))
(window-width))
(insert ",\n "))
(t (insert ", ")))
(help-insert-xref-button text 'help-package
(package-desc-name pkg))))
(insert "\n")))
(insert " " (propertize "Summary" 'font-lock-face 'bold) (insert " " (propertize "Summary" 'font-lock-face 'bold)
": " (if desc (package-desc-summary desc)) "\n") ": " (if desc (package-desc-summary desc)) "\n")
(when homepage (when homepage
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment