Fix doom/help-packages
Also adds doom-package-backend function. TODO: Report more information about straight packages.
This commit is contained in:
parent
00a4701b16
commit
e3d6d13be5
2 changed files with 47 additions and 25 deletions
|
@ -397,17 +397,19 @@ If prefix arg is present, refresh the cache."
|
|||
(let* ((guess (or (function-called-at-point)
|
||||
(symbol-at-point))))
|
||||
(require 'finder-inf nil t)
|
||||
(require 'package)
|
||||
(unless package--initialized
|
||||
(package-initialize t))
|
||||
(let* ((doom--packages (doom--help-packages-list))
|
||||
(packages (cl-delete-duplicates
|
||||
(let ((packages (cl-delete-duplicates
|
||||
(append (mapcar 'car package-alist)
|
||||
(mapcar 'car package--builtins)
|
||||
(mapcar 'car doom--packages)
|
||||
(mapcar 'car (doom--help-packages-list))
|
||||
nil))))
|
||||
(unless (memq guess packages)
|
||||
(setq guess nil))
|
||||
(list (intern (completing-read (if guess
|
||||
(list
|
||||
(intern
|
||||
(completing-read (if guess
|
||||
(format "Select package to search for (default %s): "
|
||||
guess)
|
||||
"Describe package: ")
|
||||
|
@ -416,40 +418,45 @@ If prefix arg is present, refresh the cache."
|
|||
(if (or (package-desc-p package)
|
||||
(and (symbolp package)
|
||||
(or (assq package package-alist)
|
||||
(assq package package-archive-contents)
|
||||
(assq package package--builtins))))
|
||||
(describe-package package)
|
||||
(help-setup-xref (list #'doom/help-packages package)
|
||||
(called-interactively-p 'interactive))
|
||||
(with-help-window (help-buffer)
|
||||
(with-current-buffer standard-output
|
||||
(prin1 package)
|
||||
(princ " is a site package.\n\n"))))
|
||||
(with-help-window (help-buffer)))
|
||||
(save-excursion
|
||||
(with-current-buffer (help-buffer)
|
||||
(let ((doom-packages (doom--help-packages-list))
|
||||
(inhibit-read-only t)
|
||||
(indent (make-string 13 ? )))
|
||||
(goto-char (point-min))
|
||||
(goto-char (point-max))
|
||||
(if (re-search-forward "^ *Status: " nil t)
|
||||
(progn
|
||||
(end-of-line)
|
||||
(insert "\n"))
|
||||
(re-search-forward "\n\n" nil t))
|
||||
|
||||
(package--print-help-section "Package")
|
||||
(insert (symbol-name package) "\n")
|
||||
|
||||
(package--print-help-section "Source")
|
||||
(insert (or (pcase (ignore-errors (doom-package-backend package))
|
||||
(`elpa (concat "[M]ELPA " (doom--package-url package)))
|
||||
(`quelpa (format "QUELPA %s" (prin1-to-string (doom-package-prop package :recipe))))
|
||||
(`emacs "Built-in")
|
||||
(_ (symbol-file package)))
|
||||
(insert (or (pcase (doom-package-backend package)
|
||||
(`straight
|
||||
(format! "Straight\n%s"
|
||||
(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")
|
||||
|
||||
(when (assq package doom-packages)
|
||||
(package--print-help-section "Modules")
|
||||
(insert "Declared by the following Doom modules:\n")
|
||||
(dolist (m (doom-package-prop package :modules))
|
||||
(dolist (m (doom-package-get package :modules))
|
||||
(insert indent)
|
||||
(doom--help-package-insert-button
|
||||
(format "%s %s" (car m) (or (cdr m) ""))
|
||||
|
@ -474,7 +481,9 @@ If prefix arg is present, refresh the cache."
|
|||
(find-file (expand-file-name file doom-emacs-dir))
|
||||
(goto-char (point-min))
|
||||
(forward-line (1- line))
|
||||
(recenter)))))))))
|
||||
(recenter)))))
|
||||
|
||||
(insert "\n\n")))))
|
||||
|
||||
(defvar doom--package-cache nil)
|
||||
(defun doom--package-list ()
|
||||
|
|
|
@ -101,6 +101,19 @@ A protected package cannot be deleted and will be auto-installed if missing."
|
|||
(or (doom-package-protected-p package)
|
||||
(assq :core (doom-package-get package :modules))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-backend (package)
|
||||
"Return 'straight, 'builtin, 'elpa or 'other, depending on how PACKAGE is
|
||||
installed."
|
||||
(cond ((gethash (symbol-name package) straight--build-cache)
|
||||
'straight)
|
||||
((or (doom-package-built-in-p package)
|
||||
(assq package package--builtins))
|
||||
'builtin)
|
||||
((assq package package-alist)
|
||||
'elpa)
|
||||
('other)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-different-recipe-p (name)
|
||||
"Return t if a package named NAME (a symbol) has a different recipe than it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue