From 07d37f97fb9aa9af34a72c54f73fddcf031cb6ec Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 27 Jun 2018 22:46:49 +0200 Subject: [PATCH] Refactor after! macro KISS --- core/core-lib.el | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 44d2914b1..76933d046 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -253,21 +253,18 @@ compilation. This will no-op on features that have been disabled by the user." (load next :no-message :no-error))))) #'progn #'with-no-warnings) - (cond ((symbolp targets) - `(with-eval-after-load ',targets - ,@body)) - ((and (consp targets) - (memq (car targets) '(:or :any))) - `(progn - ,@(cl-loop for next in (cdr targets) - collect `(after! ,next ,@body)))) - ((and (consp targets) - (memq (car targets) '(:and :all))) - (dolist (next (cdr targets)) - (setq body `((after! ,next ,@body)))) - (car body)) - ((listp targets) - `(after! (:all ,@targets) ,@body)))))) + (if (symbolp targets) + `(with-eval-after-load ',targets ,@body) + (pcase (car-safe targets) + ((or :or :any) + (macroexp-progn + (cl-loop for next in (cdr targets) + collect `(after! ,next ,@body)))) + ((or :and :all) + (dolist (next (cdr targets)) + (setq body `((after! ,next ,@body)))) + (car body)) + (_ `(after! (:and ,@targets) ,@body))))))) (defmacro quiet! (&rest forms) "Run FORMS without making any output."