Extend after! macro to support :any, :all & feature lists #442
This commit is contained in:
parent
0d27eda45a
commit
589108fdb2
1 changed files with 22 additions and 8 deletions
|
@ -59,17 +59,31 @@
|
|||
|
||||
(defalias 'lambda! 'λ!)
|
||||
|
||||
(defmacro after! (feature &rest forms)
|
||||
(defmacro after! (features &rest body)
|
||||
"A smart wrapper around `with-eval-after-load'. Supresses warnings during
|
||||
compilation."
|
||||
(declare (indent defun) (debug t))
|
||||
`(,(if (or (not (bound-and-true-p byte-compile-current-file))
|
||||
(if (symbolp feature)
|
||||
(require feature nil :no-error)
|
||||
(load feature :no-message :no-error)))
|
||||
#'progn
|
||||
#'with-no-warnings)
|
||||
(with-eval-after-load ',feature ,@forms)))
|
||||
(list (if (or (not (bound-and-true-p byte-compile-current-file))
|
||||
(dolist (next (doom-enlist features))
|
||||
(if (symbolp next)
|
||||
(require next nil :no-error)
|
||||
(load next :no-message :no-error))))
|
||||
#'progn
|
||||
#'with-no-warnings)
|
||||
(cond ((symbolp features)
|
||||
`(eval-after-load ',features '(progn ,@body)))
|
||||
((and (consp features)
|
||||
(memq (car features) '(:or :any)))
|
||||
`(progn
|
||||
,@(cl-loop for next in (cdr features)
|
||||
collect `(after! ,next ,@body))))
|
||||
((and (consp features)
|
||||
(memq (car features) '(:and :all)))
|
||||
(dolist (next (cdr features))
|
||||
(setq body `(after! ,next ,@body)))
|
||||
body)
|
||||
((listp features)
|
||||
`(after! (:all ,@features) ,@body)))))
|
||||
|
||||
(defmacro quiet! (&rest forms)
|
||||
"Run FORMS without making any noise."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue