Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created January 8, 2020 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjensen/7aa99e109a2890be031ba52488e896c5 to your computer and use it in GitHub Desktop.
Save aaronjensen/7aa99e109a2890be031ba52488e896c5 to your computer and use it in GitHub Desktop.
(defvar aj--eager-features nil)
(setq aj--initial-feature-count (length features))
(setq aj--eager-features-path (no-littering-expand-var-file-name "eager-features"))
(defun aj/load-eager-features ()
(while (and aj--eager-features
(not (input-pending-p)))
(unwind-protect
(require (pop aj--eager-features) nil t)))
(when aj--eager-features
(aj/load-eager-features-idle)))
(defun aj/load-eager-features-idle ()
(run-with-idle-timer 0.05 nil #'aj/load-eager-features))
(defun aj/load-eager-features-start ()
(and (file-exists-p aj--eager-features-path)
(load aj--eager-features-path)
(aj/load-eager-features-idle)))
(defun aj/save-libs ()
(with-temp-file aj--eager-features-path
(insert "(setq aj--eager-features '")
(insert (format "%S" (reverse (butlast features aj--initial-feature-count))))
(insert ")\n")))
(add-hook 'after-init-hook #'aj/load-eager-features-start)
(add-hook 'kill-emacs-hook #'aj/save-libs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment