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 --- init.el | 5 ++--- lisp/acdw.el | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index 0866f17..5d5c02f 100644 --- a/init.el +++ b/init.el @@ -51,7 +51,7 @@ (:hook #'+init-add-setup-to-imenu)) (setup (:require +key) - (+key-setup)) + (+ensure-after-init #'+key-global-mode)) (setup (:require auth-source) (:option auth-sources (list (private/ "authinfo") @@ -175,8 +175,7 @@ custom-variable-default-form 'lisp +custom-variable-allowlist '(safe-local-variable-values warning-suppress-types)) - (when (file-exists-p custom-file) - (+custom-load-ignoring-most-customizations t)) + (+ensure-after-init #'+custom-load-ignoring-most-customizations) (advice-add #'custom-buffer-create-internal :after #'+cus-edit-expand-widgets) (:with-mode Custom-mode (:local-set imenu-generic-expression +cus-edit-imenu-generic-expression))) 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