Refactor package! macro
This commit is contained in:
parent
93f7520c79
commit
0eb200c49f
1 changed files with 32 additions and 20 deletions
|
@ -197,7 +197,8 @@ necessary package metadata is initialized and available for them."
|
||||||
;;
|
;;
|
||||||
;;; Module package macros
|
;;; Module package macros
|
||||||
|
|
||||||
(cl-defmacro package! (name &rest plist &key built-in _recipe disable ignore _freeze)
|
(cl-defmacro package!
|
||||||
|
(name &rest plist &key built-in _recipe disable ignore _freeze)
|
||||||
"Declares a package and how to install it (if applicable).
|
"Declares a package and how to install it (if applicable).
|
||||||
|
|
||||||
This macro is declarative and does not load nor install packages. It is used to
|
This macro is declarative and does not load nor install packages. It is used to
|
||||||
|
@ -226,28 +227,39 @@ Returns t if package is successfully registered, and nil if it was disabled
|
||||||
elsewhere."
|
elsewhere."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(let ((old-plist (cdr (assq name doom-packages))))
|
(let ((old-plist (cdr (assq name doom-packages))))
|
||||||
|
;; Add current module to :modules
|
||||||
(let ((module-list (plist-get old-plist :modules))
|
(let ((module-list (plist-get old-plist :modules))
|
||||||
(module (or doom--current-module
|
(module (doom-module-from-path)))
|
||||||
(let ((file (file!)))
|
|
||||||
(cond ((file-in-directory-p file doom-private-dir)
|
|
||||||
(list :private))
|
|
||||||
((file-in-directory-p file doom-core-dir)
|
|
||||||
(list :core))
|
|
||||||
((doom-module-from-path file)))))))
|
|
||||||
(unless (member module module-list)
|
(unless (member module module-list)
|
||||||
(setq module-list (append module-list (list module) nil)
|
(plist-put! plist :modules
|
||||||
plist (plist-put plist :modules module-list))))
|
(append module-list
|
||||||
(when built-in
|
(list module)
|
||||||
(doom-log "Ignoring built-in package %S" name)
|
nil))))
|
||||||
(when (equal built-in '(quote prefer))
|
|
||||||
(setq built-in `(locate-library ,(symbol-name name) nil doom--initial-load-path))))
|
;; Handle :built-in
|
||||||
(setq plist (plist-put plist :ignore (or built-in ignore)))
|
(unless ignore
|
||||||
(while plist
|
(when built-in
|
||||||
(unless (null (cadr plist))
|
(doom-log "Ignoring built-in package %S" name)
|
||||||
(setq old-plist (plist-put old-plist (car plist) (cadr plist))))
|
(when (equal built-in '(quote prefer))
|
||||||
(pop plist)
|
(setq built-in `(locate-library ,(symbol-name name) nil doom--initial-load-path))))
|
||||||
(pop plist))
|
(plist-put! plist :ignore built-in))
|
||||||
|
|
||||||
|
;; DEPRECATED Translate :fetcher to :host
|
||||||
|
(with-plist! plist (recipe)
|
||||||
|
(with-plist! recipe (fetcher)
|
||||||
|
(when fetcher
|
||||||
|
(message "%s\n%s"
|
||||||
|
"WARNING: The :fetcher property was used for the %S package."
|
||||||
|
"This property is deprecated. Replace it with :host.")
|
||||||
|
(plist-put! recipe :host fetcher)
|
||||||
|
(plist-delete! recipe :fetcher))
|
||||||
|
(plist-put! plist :recipe recipe)))
|
||||||
|
|
||||||
|
(doplist! ((prop val) plist)
|
||||||
|
(unless (null val)
|
||||||
|
(plist-put! old-plist prop val)))
|
||||||
(setq plist old-plist)
|
(setq plist old-plist)
|
||||||
|
|
||||||
;; TODO Add `straight-use-package-pre-build-function' support
|
;; TODO Add `straight-use-package-pre-build-function' support
|
||||||
(macroexp-progn
|
(macroexp-progn
|
||||||
(append `((setf (alist-get ',name doom-packages) ',plist))
|
(append `((setf (alist-get ',name doom-packages) ',plist))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue