package!: improve docstring & add :needs property
This commit is contained in:
parent
10d46b3dc0
commit
cdeab2c292
1 changed files with 28 additions and 16 deletions
|
@ -179,25 +179,37 @@ packages are deferred by default."
|
||||||
|
|
||||||
(defmacro package! (name &rest plist)
|
(defmacro package! (name &rest plist)
|
||||||
"Wraps around `use-package' to declare a deferred package (unless otherwise
|
"Wraps around `use-package' to declare a deferred package (unless otherwise
|
||||||
indicated), takes the same arguments, but adds the :recipe property, which takes
|
indicated), takes the same arguments, but adds a few custom properties:
|
||||||
a MELPA recipe. Also binds `__PACKAGE__` for PLIST forms to optionally use."
|
|
||||||
|
:recipe RECIPE Takes a MELPA-style recipe (see `quelpa-recipe' for an
|
||||||
|
example); for packages to be installed from external
|
||||||
|
sources.
|
||||||
|
:pin ARCHIVE-NAME Instructs ELPA to only look for this package in
|
||||||
|
ARCHIVE-NAME. e.g. \"org\".
|
||||||
|
:needs FEATURE Don't install this package if FEATURE isn't available.
|
||||||
|
|
||||||
|
Also binds `__PACKAGE__` for PLIST forms to optionally use."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(let ((recipe (cadr (memq :recipe plist)))
|
(let ((recipe (cadr (memq :recipe plist)))
|
||||||
(pin (cadr (memq :pin plist)))
|
(pin (cadr (memq :pin plist)))
|
||||||
(lpath (cadr (memq :load-path plist))))
|
(lpath (cadr (memq :load-path plist)))
|
||||||
(when (and recipe (= 0 (mod (length recipe) 2)))
|
(dep (cadr (memq :needs plist))))
|
||||||
(push name recipe))
|
(when (or (not dep)
|
||||||
(if (not lpath)
|
(or (featurep dep)
|
||||||
(cl-pushnew (cons name recipe) doom-packages :key 'car)
|
(package-installed-p dep)))
|
||||||
(cl-pushnew lpath doom--base-load-path)
|
(when (and recipe (= 0 (mod (length recipe) 2)))
|
||||||
(setq recipe nil
|
(push name recipe))
|
||||||
pin nil))
|
(if (not lpath)
|
||||||
(when pin
|
(cl-pushnew (cons name recipe) doom-packages :key 'car)
|
||||||
(cl-pushnew (cons package (plist-get plist :pin)) package-pinned-packages :key 'car))
|
(cl-pushnew lpath doom--base-load-path)
|
||||||
(setq plist (use-package-plist-delete plist :recipe))
|
(setq recipe nil
|
||||||
(setq plist (use-package-plist-delete plist :pin))
|
pin nil))
|
||||||
(unless doom-dont-load-p
|
(when pin
|
||||||
`(use-package! ,name ,@plist))))
|
(cl-pushnew (cons package (plist-get plist :pin)) package-pinned-packages :key 'car))
|
||||||
|
(setq plist (use-package-plist-delete plist :recipe))
|
||||||
|
(setq plist (use-package-plist-delete plist :pin))
|
||||||
|
(unless doom-dont-load-p
|
||||||
|
`(use-package! ,name ,@plist)))))
|
||||||
|
|
||||||
(defmacro require! (feature)
|
(defmacro require! (feature)
|
||||||
"Like `require', but will prefer uncompiled files if `doom-prefer-el-p' is
|
"Like `require', but will prefer uncompiled files if `doom-prefer-el-p' is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue