Remove :when support from after!; add defer-until!
New macro does what the :when keyword did for after!.
This commit is contained in:
parent
e9ccc09fe4
commit
5a7c8803d9
3 changed files with 21 additions and 18 deletions
|
@ -222,22 +222,10 @@ MATCH is a string regexp. Only entries that match it will be included."
|
|||
|
||||
(defalias 'lambda! 'λ!)
|
||||
|
||||
(defmacro after! (targets &rest body)
|
||||
"A smart wrapper around `with-eval-after-load'. Supresses warnings during
|
||||
compilation. This will no-op on features that have been disabled by the user."
|
||||
(defmacro defer-until! (condition &rest body)
|
||||
"Run BODY when CONDITION is true (checks on `after-load-functions'). Meant to
|
||||
serve as a predicated alternative to `after!'."
|
||||
(declare (indent defun) (debug t))
|
||||
(unless (and (symbolp targets)
|
||||
(memq targets (bound-and-true-p doom-disabled-packages)))
|
||||
(list (if (or (not (bound-and-true-p byte-compile-current-file))
|
||||
(eq (car-safe targets) :when)
|
||||
(dolist (next (doom-enlist targets))
|
||||
(unless (keywordp next)
|
||||
(if (symbolp next)
|
||||
(require next nil :no-error)
|
||||
(load next :no-message :no-error)))))
|
||||
#'progn
|
||||
#'with-no-warnings)
|
||||
(cond ((eq (car-safe targets) :when)
|
||||
`(if ,(cadr targets)
|
||||
(progn ,@body)
|
||||
,(let ((fun (gensym "doom|delay-form-")))
|
||||
|
@ -250,7 +238,22 @@ compilation. This will no-op on features that have been disabled by the user."
|
|||
,@body)))
|
||||
(put ',fun 'permanent-local-hook t)
|
||||
(add-hook 'after-load-functions #',fun)))))
|
||||
((symbolp targets)
|
||||
|
||||
(defmacro after! (targets &rest body)
|
||||
"A smart wrapper around `with-eval-after-load'. Supresses warnings during
|
||||
compilation. This will no-op on features that have been disabled by the user."
|
||||
(declare (indent defun) (debug t))
|
||||
(unless (and (symbolp targets)
|
||||
(memq targets (bound-and-true-p doom-disabled-packages)))
|
||||
(list (if (or (not (bound-and-true-p byte-compile-current-file))
|
||||
(dolist (next (doom-enlist targets))
|
||||
(unless (keywordp next)
|
||||
(if (symbolp next)
|
||||
(require next nil :no-error)
|
||||
(load next :no-message :no-error)))))
|
||||
#'progn
|
||||
#'with-no-warnings)
|
||||
(cond ((symbolp targets)
|
||||
`(with-eval-after-load ',targets
|
||||
,@body))
|
||||
((and (consp targets)
|
||||
|
|
|
@ -30,13 +30,13 @@ these properties:
|
|||
If non-nil, don't expand any template for this file and don't test any other
|
||||
file template rule against this buffer."
|
||||
(declare (indent defun))
|
||||
(after! (:when (boundp '+file-templates-alist))
|
||||
(defer-until! (boundp '+file-templates-alist)
|
||||
(+file-templates--set pred plist)))
|
||||
|
||||
;;;###autodef
|
||||
(defun set-file-templates! (&rest templates)
|
||||
"Like `set-file-templates!', but register many file templates at once."
|
||||
(after! (:when (boundp '+file-templates-alist))
|
||||
(defer-until! (boundp '+file-templates-alist)
|
||||
(dolist (template templates)
|
||||
(+file-templates--set (car template) (cdr template)))))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
DOCSET (a string).
|
||||
|
||||
See `devdocs-alist' for the defaults. "
|
||||
(after! (:when (boundp 'devdocs-alist))
|
||||
(defer-until! (boundp 'devdocs-alist)
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(setf (alist-get mode devdocs-alist) docset))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue