Fix & extend doom/help-packages

+ It would display Doom's commit, rather than the package's
+ Add Homepage link
+ Fix module lists for packages that aren't installed
This commit is contained in:
Henrik Lissner 2020-03-12 12:42:58 -04:00
parent 2fcc338702
commit 2c2df9df8c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -468,27 +468,44 @@ If prefix arg is present, refresh the cache."
(insert (symbol-name package) "\n")
(package--print-help-section "Source")
(insert (or (pcase (doom-package-backend package)
(`straight
(format! "Straight (%s)\n%s"
(let ((default-directory (straight--build-dir (symbol-name package))))
(cdr
(doom-call-process "git" "log" "-1" "--format=%D %h %ci")))
(indent
13 (string-trim
(pp-to-string
(doom-package-build-recipe package))))))
(`elpa
(format "[M]ELPA %s" (doom--package-url package)))
(`builtin "Built-in")
(_ (abbreviate-file-name (symbol-file package))))
"unknown")
"\n")
(pcase (doom-package-backend package)
(`straight
(insert "Straight\n")
(package--print-help-section "Pinned")
(insert (if-let (pin (plist-get (cdr (assq package doom-packages)) :pin))
pin
"unpinned")
"\n")
(package--print-help-section "Build")
(insert (let ((default-directory (straight--repos-dir (symbol-name package))))
(cdr
(doom-call-process "git" "log" "-1" "--format=%D %h %ci")))
"\n")
(let ((recipe (doom-package-build-recipe package)))
(insert (format! "%s\n"
(indent 13
(string-trim (pp-to-string recipe)))))
(when (gethash (symbol-name package) straight--build-cache)
(package--print-help-section "Homepage")
(insert (doom--package-url package))))
(`elpa (insert "[M]ELPA " (doom--package-url package)))
(`builtin (insert "Built-in"))
(`other (insert
(abbreviate-file-name
(or (symbol-file package)
(locate-library (symbol-name package))))))
(_ (insert "Not installed")))
(insert "\n")
(when-let
(modules
(if (gethash (symbol-name package) straight--build-cache)
(doom-package-get package :modules)
(plist-get (cdr (assq package (doom-packages-list 'all)))
:modules)))
(package--print-help-section "Modules")
(insert "Declared by the following Doom modules:\n")
(dolist (m (doom-package-get package :modules))
(dolist (m modules)
(insert indent)
(doom--help-package-insert-button
(format "%s %s" (car m) (or (cdr m) ""))