Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created December 19, 2024 07:24
Show Gist options
  • Save aaronjensen/3dcb665b22ccc9a4fa85345a22d83df6 to your computer and use it in GitHub Desktop.
Save aaronjensen/3dcb665b22ccc9a4fa85345a22d83df6 to your computer and use it in GitHub Desktop.
(defvar c/eager-hook nil)
(defmacro c/eager-run-hook (hook)
`(while (and (not (input-pending-p))
,hook)
(let ((first-hook (car ,hook))
(remaining-hooks (cdr ,hook))
(c/time-hooks (intern (format " eager • %s" ',hook))))
(add-hook 'c/eager-hook first-hook)
(run-hook-wrapped 'c/eager-hook #'c/run-hook)
(setq ,hook remaining-hooks
c/eager-hook nil))))
(defun c/eager-run-hooks ()
(c/eager-run-hook c/first-input-hook)
(c/eager-run-hook c/first-buffer-hook)
(c/eager-run-hook c/first-file-hook))
(defun c/eager-run-hooks-later ()
(run-with-timer 0 nil #'c/eager-run-hooks))
(add-hook 'elpaca-after-init-hook #'c/eager-run-hooks-later)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment