From 30ca7beb8f0101dffffc22858bcfcd8e0d604a56 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 2 Jan 2022 23:33:00 -0600 Subject: Add function: +ensure-after-init --- lisp/acdw.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 95e1147..43cb5c7 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -75,5 +75,13 @@ ARGS." (run-at-time sunset-time (* 60 60 24) sunset-command) (run-at-time "12:00am" (* 60 60 24) sunset-command))) +(defun +ensure-after-init (function) + "Ensure FUNCTION runs after init, or now if already initialized. +If Emacs is already started, run FUNCTION. Otherwise, add it to +`after-init-hook'. FUNCTION is called with no arguments." + (if after-init-time + (funcall function) + (add-hook 'after-init-hook function))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81