Add :disable support to def-package-hook!

`def-package!` now respects `doom-disabled-packages`
This commit is contained in:
Henrik Lissner 2017-06-05 16:45:42 +02:00
parent d62f446dc3
commit d4761a7c6d
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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
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
"The load path of built in Emacs libraries.")
@ -301,18 +304,27 @@ byte-compilation."
(add-hook 'after-init-hook #'doom--display-benchmark t))))
(defalias 'def-package! 'use-package
"An alias for `use-package'. Note that packages are deferred by default.")
(defmacro def-package! (name &rest plist)
"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)
"Configure a package using use-package hooks (see `use-package-inject-hooks').
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 blocks original configuration
is not evaluated."
WHEN can also be :disable (then BODY is ignored), which will instruct DOOM to
ignore any `def-package!' blocks for PACKAGE."
(declare (indent defun))
(cond ((eq when :disable)
(push package doom-disabled-packages)
nil)
((memq when '(:pre-init :post-init :pre-config :post-config))
`(progn
(setq use-package-inject-hooks t)
(add-hook!
@ -320,6 +332,8 @@ is not evaluated."
package
(substring (symbol-name when) 1)))
,@body)))
(t
(error "'%s' isn't a valid hook for def-package-hook!" when))))
(defmacro load! (filesym &optional path noerror)
"Loads a file relative to the current module (or PATH). FILESYM is a file path