From 0763e40986ef9ccd592d33df9106fb9c8b0eee00 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 29 Sep 2021 17:18:35 -0500 Subject: Correct with-eval-after-loads From this reddit comment: https://old.reddit.com/r/emacs/comments/pxe9pr/need_help_writing_a_macro/hemygul/ --- lisp/acdw.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/acdw.el b/lisp/acdw.el index 6e66838..792b9ef 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -80,12 +80,20 @@ When not specified, ELLIPSIS defaults to '...'." ,@forms)) (add-function :after after-focus-change-function #',func-name)))) -(defmacro with-eval-after-loads (files &rest body) - "Execute BODY after FILES are loaded. +(defmacro with-eval-after-loads (features &rest body) + "Execute BODY after FEATURES are loaded. This macro simplifies `with-eval-after-load' for multiple nested features." - (declare (indent 1) (debug (form def-body))) - (waterfall-list 'with-eval-after-load files body)) + (declare (indent 1) + (debug (form def-body))) + (unless (listp features) + (setq features (list features))) + (if (null features) + (macroexp-progn body) + (let* ((this (car features)) + (rest (cdr features))) + `(with-eval-after-load ',this + (with-eval-after-loads ,rest ,@body))))) (defmacro with-message (message &rest body) "Execute BODY, messaging 'MESSAGE...' before and 'MESSAGE... Done.' after." -- cgit 1.4.1-21-gabe81