0

I am trying to use oauth2.el for some local shenanigans and would like to see how others are using it. Is there a way I can query elpa/melpa for dependencies to this (or any other package)?

1 Answer 1

2

Not sure about querying the package archive directly, but you can do something along the lines of:

(let ((needle 'oauth2)
      (resolve-deps-recursively t)
      curr-deps
      all-rdeps)
  (dolist (curr package-archive-contents all-rdeps)
    ;; (car curr) => pkg
    ;; (cadr curr) => pkg-desc
    (setq curr-deps (if resolve-deps-recursively
                        (package--dependencies (car curr))
                      (mapcar #'car (package-desc-reqs (cadr curr)))))
    (when (memq needle curr-deps)
      (push (car curr) all-rdeps))))

This will find all reverse dependencies of needle. If resolve-deps-recursively is non-nil, it will, as the name suggests, resolve dependencies recursively. In other words, if pkg1 depends on pkg2 which depends on [...] which depends on pkgn which depends on needle, pkg1 will appear in the result.

Given my package-archive-contents, I get the following results for 'oauth2:

;; with recursive dependency resolution
'(flim google-contacts mu-cite oauth2-request org-onenote semi slack smudge wanderlust)

;; without recursive dependency resolution
'(flim google-contacts oauth2-request org-onenote slack smudge)
1
  • Very nice, thanks!
    – zedoo
    Aug 18, 2022 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.