Add :disable support to def-package-hook!
`def-package!` now respects `doom-disabled-packages`
This commit is contained in:
parent
d62f446dc3
commit
d4761a7c6d
1 changed files with 26 additions and 12 deletions
|
@ -59,6 +59,9 @@ package's name as a symbol, and whose CDR is the plist supplied to its
|
||||||
"A list of packages that must be installed (and will be auto-installed if
|
"A list of packages that must be installed (and will be auto-installed if
|
||||||
missing) and shouldn't be deleted.")
|
missing) and shouldn't be deleted.")
|
||||||
|
|
||||||
|
(defvar doom-disabled-packages ()
|
||||||
|
"A list of packages that should be ignored by `def-package!'.")
|
||||||
|
|
||||||
(defvar doom--site-load-path load-path
|
(defvar doom--site-load-path load-path
|
||||||
"The load path of built in Emacs libraries.")
|
"The load path of built in Emacs libraries.")
|
||||||
|
|
||||||
|
@ -301,18 +304,27 @@ byte-compilation."
|
||||||
|
|
||||||
(add-hook 'after-init-hook #'doom--display-benchmark t))))
|
(add-hook 'after-init-hook #'doom--display-benchmark t))))
|
||||||
|
|
||||||
(defalias 'def-package! 'use-package
|
(defmacro def-package! (name &rest plist)
|
||||||
"An alias for `use-package'. Note that packages are deferred by default.")
|
"A thin wrapper around `use-package'."
|
||||||
|
(when (and (memq name doom-disabled-packages)
|
||||||
|
(not (memq :disabled plist)))
|
||||||
|
(setq plist (append (list :disabled t) plist)))
|
||||||
|
`(use-package ,name ,@plist))
|
||||||
|
|
||||||
(defmacro def-package-hook! (package when &rest body)
|
(defmacro def-package-hook! (package when &rest body)
|
||||||
"Configure a package using use-package hooks (see `use-package-inject-hooks').
|
"Configure a package using use-package hooks (see `use-package-inject-hooks').
|
||||||
|
|
||||||
PACKAGE is the package name.
|
PACKAGE is the package name.
|
||||||
WHEN should be one of the following: :pre-init :post-init :pre-config :post-config
|
WHEN should be one of the following:
|
||||||
|
:pre-init :post-init :pre-config :post-config
|
||||||
|
|
||||||
Note that if a :pre-init hook returns nil, that block’s original configuration
|
WHEN can also be :disable (then BODY is ignored), which will instruct DOOM to
|
||||||
is not evaluated."
|
ignore any `def-package!' blocks for PACKAGE."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
|
(cond ((eq when :disable)
|
||||||
|
(push package doom-disabled-packages)
|
||||||
|
nil)
|
||||||
|
((memq when '(:pre-init :post-init :pre-config :post-config))
|
||||||
`(progn
|
`(progn
|
||||||
(setq use-package-inject-hooks t)
|
(setq use-package-inject-hooks t)
|
||||||
(add-hook!
|
(add-hook!
|
||||||
|
@ -320,6 +332,8 @@ is not evaluated."
|
||||||
package
|
package
|
||||||
(substring (symbol-name when) 1)))
|
(substring (symbol-name when) 1)))
|
||||||
,@body)))
|
,@body)))
|
||||||
|
(t
|
||||||
|
(error "'%s' isn't a valid hook for def-package-hook!" when))))
|
||||||
|
|
||||||
(defmacro load! (filesym &optional path noerror)
|
(defmacro load! (filesym &optional path noerror)
|
||||||
"Loads a file relative to the current module (or PATH). FILESYM is a file path
|
"Loads a file relative to the current module (or PATH). FILESYM is a file path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue