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,59 +397,66 @@ If prefix arg is present, refresh the cache."
|
||||||
(let* ((guess (or (function-called-at-point)
|
(let* ((guess (or (function-called-at-point)
|
||||||
(symbol-at-point))))
|
(symbol-at-point))))
|
||||||
(require 'finder-inf nil t)
|
(require 'finder-inf nil t)
|
||||||
|
(require 'package)
|
||||||
(unless package--initialized
|
(unless package--initialized
|
||||||
(package-initialize t))
|
(package-initialize t))
|
||||||
(let* ((doom--packages (doom--help-packages-list))
|
(let ((packages (cl-delete-duplicates
|
||||||
(packages (cl-delete-duplicates
|
(append (mapcar 'car package-alist)
|
||||||
(append (mapcar 'car package-alist)
|
(mapcar 'car package--builtins)
|
||||||
(mapcar 'car package--builtins)
|
(mapcar 'car (doom--help-packages-list))
|
||||||
(mapcar 'car doom--packages)
|
nil))))
|
||||||
nil))))
|
|
||||||
(unless (memq guess packages)
|
(unless (memq guess packages)
|
||||||
(setq guess nil))
|
(setq guess nil))
|
||||||
(list (intern (completing-read (if guess
|
(list
|
||||||
(format "Select package to search for (default %s): "
|
(intern
|
||||||
guess)
|
(completing-read (if guess
|
||||||
"Describe package: ")
|
(format "Select package to search for (default %s): "
|
||||||
packages nil t nil nil
|
guess)
|
||||||
(if guess (symbol-name guess))))))))
|
"Describe package: ")
|
||||||
|
packages nil t nil nil
|
||||||
|
(if guess (symbol-name guess))))))))
|
||||||
(if (or (package-desc-p package)
|
(if (or (package-desc-p package)
|
||||||
(and (symbolp package)
|
(and (symbolp package)
|
||||||
(or (assq package package-alist)
|
(or (assq package package-alist)
|
||||||
(assq package package-archive-contents)
|
|
||||||
(assq package package--builtins))))
|
(assq package package--builtins))))
|
||||||
(describe-package package)
|
(describe-package package)
|
||||||
(help-setup-xref (list #'doom/help-packages package)
|
(help-setup-xref (list #'doom/help-packages package)
|
||||||
(called-interactively-p 'interactive))
|
(called-interactively-p 'interactive))
|
||||||
(with-help-window (help-buffer)
|
(with-help-window (help-buffer)))
|
||||||
(with-current-buffer standard-output
|
|
||||||
(prin1 package)
|
|
||||||
(princ " is a site package.\n\n"))))
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(with-current-buffer (help-buffer)
|
(with-current-buffer (help-buffer)
|
||||||
(let ((doom-packages (doom--help-packages-list))
|
(let ((doom-packages (doom--help-packages-list))
|
||||||
(inhibit-read-only t)
|
(inhibit-read-only t)
|
||||||
(indent (make-string 13 ? )))
|
(indent (make-string 13 ? )))
|
||||||
(goto-char (point-min))
|
(goto-char (point-max))
|
||||||
(if (re-search-forward "^ *Status: " nil t)
|
(if (re-search-forward "^ *Status: " nil t)
|
||||||
(progn
|
(progn
|
||||||
(end-of-line)
|
(end-of-line)
|
||||||
(insert "\n"))
|
(insert "\n"))
|
||||||
(re-search-forward "\n\n" nil t))
|
(re-search-forward "\n\n" nil t))
|
||||||
|
|
||||||
|
(package--print-help-section "Package")
|
||||||
|
(insert (symbol-name package) "\n")
|
||||||
|
|
||||||
(package--print-help-section "Source")
|
(package--print-help-section "Source")
|
||||||
(insert (or (pcase (ignore-errors (doom-package-backend package))
|
(insert (or (pcase (doom-package-backend package)
|
||||||
(`elpa (concat "[M]ELPA " (doom--package-url package)))
|
(`straight
|
||||||
(`quelpa (format "QUELPA %s" (prin1-to-string (doom-package-prop package :recipe))))
|
(format! "Straight\n%s"
|
||||||
(`emacs "Built-in")
|
(indent
|
||||||
(_ (symbol-file package)))
|
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")
|
"unknown")
|
||||||
"\n")
|
"\n")
|
||||||
|
|
||||||
(when (assq package doom-packages)
|
(when (assq package doom-packages)
|
||||||
(package--print-help-section "Modules")
|
(package--print-help-section "Modules")
|
||||||
(insert "Declared by the following Doom modules:\n")
|
(insert "Declared by the following Doom modules:\n")
|
||||||
(dolist (m (doom-package-prop package :modules))
|
(dolist (m (doom-package-get package :modules))
|
||||||
(insert indent)
|
(insert indent)
|
||||||
(doom--help-package-insert-button
|
(doom--help-package-insert-button
|
||||||
(format "%s %s" (car m) (or (cdr m) ""))
|
(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))
|
(find-file (expand-file-name file doom-emacs-dir))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(forward-line (1- line))
|
(forward-line (1- line))
|
||||||
(recenter)))))))))
|
(recenter)))))
|
||||||
|
|
||||||
|
(insert "\n\n")))))
|
||||||
|
|
||||||
(defvar doom--package-cache nil)
|
(defvar doom--package-cache nil)
|
||||||
(defun doom--package-list ()
|
(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)
|
(or (doom-package-protected-p package)
|
||||||
(assq :core (doom-package-get package :modules))))
|
(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
|
;;;###autoload
|
||||||
(defun doom-package-different-recipe-p (name)
|
(defun doom-package-different-recipe-p (name)
|
||||||
"Return t if a package named NAME (a symbol) has a different recipe than it
|
"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