Refactor package pinning
- Make doom/info package details more concise - Removed doom-pinned-packages variable (pin info now stored in doom-packages metadata) - Fix unpin! not actually unpinning some packages
This commit is contained in:
parent
c5d6e6267c
commit
097972bd9d
4 changed files with 129 additions and 80 deletions
|
@ -23,11 +23,25 @@
|
|||
(when (file-exists-p file)
|
||||
(insert-file-contents file))))
|
||||
|
||||
(defun doom--collect-forms-in (file form)
|
||||
(when (file-readable-p file)
|
||||
(let (forms)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents file)
|
||||
(delay-mode-hooks (emacs-lisp-mode))
|
||||
(while (re-search-forward (format "(%s " (regexp-quote form)) nil t)
|
||||
(unless (doom-point-in-string-or-comment-p)
|
||||
(save-excursion
|
||||
(goto-char (match-beginning 0))
|
||||
(push (sexp-at-point) forms))))
|
||||
(nreverse forms)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-info ()
|
||||
"Returns diagnostic information about the current Emacs session in markdown,
|
||||
ready to be pasted in a bug report on github."
|
||||
(require 'vc-git)
|
||||
(require 'core-packages)
|
||||
(let ((default-directory doom-emacs-dir)
|
||||
(doom-modules (doom-modules)))
|
||||
(cl-letf
|
||||
|
@ -80,14 +94,10 @@ ready to be pasted in a bug report on github."
|
|||
'("n/a")))
|
||||
(packages
|
||||
,@(or (condition-case e
|
||||
(cl-loop for (name . plist) in (doom-package-list)
|
||||
if (cl-find :private (plist-get plist :modules)
|
||||
:key #'car)
|
||||
collect
|
||||
(if-let (splist (doom-plist-delete (copy-sequence plist)
|
||||
:modules))
|
||||
(prin1-to-string (cons name splist))
|
||||
name))
|
||||
(mapcar
|
||||
#'cdr (doom--collect-forms-in
|
||||
(doom-path doom-private-dir "packages.el")
|
||||
"package!"))
|
||||
(error (format "<%S>" e)))
|
||||
'("n/a")))
|
||||
(elpa
|
||||
|
@ -98,7 +108,14 @@ ready to be pasted in a bug report on github."
|
|||
collect (format "%s" name)))
|
||||
(error (format "<%S>" e)))
|
||||
'("n/a")))
|
||||
(unpin ,@(or (get 'doom-pinned-packages 'modified) '("n/a"))))))))
|
||||
(unpin ,@(or (condition-case e
|
||||
(mapcan #'identity
|
||||
(mapcar
|
||||
#'cdr (doom--collect-forms-in
|
||||
(doom-path doom-private-dir "packages.el")
|
||||
"unpin!")))
|
||||
(error (format "<%S>" e)))
|
||||
'("n/a"))))))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
nil-value)
|
||||
plist)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-set (package prop value)
|
||||
"Set PROPERTY in PACKAGE's recipe to VALUE."
|
||||
(setf (alist-get package doom-packages)
|
||||
(plist-put (alist-get package doom-packages)
|
||||
prop value)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-recipe (package &optional prop nil-value)
|
||||
"Returns the `straight' recipe PACKAGE was registered with."
|
||||
|
@ -23,6 +30,14 @@
|
|||
nil-value)
|
||||
plist)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-recipe-repo (package)
|
||||
"Resolve and return PACKAGE's (symbol) local-repo property."
|
||||
(if-let* ((recipe (cdr (straight-recipes-retrieve package)))
|
||||
(repo (straight-vc-local-repo-name recipe)))
|
||||
repo
|
||||
(symbol-name package)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-build-recipe (package &optional prop nil-value)
|
||||
"Returns the `straight' recipe PACKAGE was installed with."
|
||||
|
@ -190,6 +205,33 @@ ones."
|
|||
(doom--read-module-packages-file private-packages all-p t))
|
||||
(nreverse doom-packages)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-pinned-list ()
|
||||
"Return an alist mapping package names (strings) to pinned commits (strings)."
|
||||
(let (alist)
|
||||
(dolist (package doom-packages alist)
|
||||
(with-plist! (cdr package) (recipe modules disable ignore pin unpin)
|
||||
(when (and (not ignore)
|
||||
(not disable)
|
||||
(or pin unpin))
|
||||
(setf (alist-get (doom-package-recipe-repo (car package)) alist
|
||||
nil 'remove #'equal)
|
||||
(unless unpin pin)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-unpinned-list ()
|
||||
"Return an alist mapping package names (strings) to pinned commits (strings)."
|
||||
(let (alist)
|
||||
(dolist (package doom-packages alist)
|
||||
(with-plist! (cdr package) (recipe modules disable ignore pin unpin)
|
||||
(when (and (not ignore)
|
||||
(not disable)
|
||||
(or unpin
|
||||
(and (plist-member recipe :pin)
|
||||
(null pin))))
|
||||
(cl-pushnew (doom-package-recipe-repo (car package)) alist
|
||||
:test #'equal))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-recipe-list ()
|
||||
"Return straight recipes for non-builtin packages with a local-repo."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue