From 4b3ebd99a0f0a3ea95e2d60c63d8d6f9273922e0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 12:40:52 -0500 Subject: Implement `with-eval-after-loads' macro --- lisp/acdw.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 4c17bcb..2aa6c1f 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -108,6 +108,22 @@ is unfocused." ,@body) (message "%s... Done." ,message))) +(defmacro with-eval-after-loads (files &rest body) + "Execute BODY after FILES 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)) + +(defun waterfall-list (car list rest) + "Cons CAR with each element in LIST in a waterfall fashion, end with REST. +For use with the `with-eval-after-loads' function." + (cond ((atom list) `(,car ',list ,@rest)) + ((= 1 (length list)) `(,car ',(car list) ,@rest)) + (t + `(,car ',(car list) + ,(waterfall-list car (cdr list) rest))))) + ;;; Comment-or-uncomment-sexp ;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html -- cgit 1.4.1-21-gabe81