From 232da91620c703f6d10d9ff74d73c78aeb8f5be7 Mon Sep 17 00:00:00 2001 From: Milan Glacier Date: Thu, 25 May 2023 10:39:51 -0400 Subject: [PATCH] refactor(utils): add options for controlling time to incrementally load packages. --- lisp/autoloads/my-utils-autoloads.el | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lisp/autoloads/my-utils-autoloads.el b/lisp/autoloads/my-utils-autoloads.el index 975bf0b..f4063da 100644 --- a/lisp/autoloads/my-utils-autoloads.el +++ b/lisp/autoloads/my-utils-autoloads.el @@ -98,21 +98,31 @@ for debugging purposes when you want to examine a hook value." (defvar my$load-incrementally-packages () "packages to be loaded incrementally after startup") +(defvar my$load-incrementally-packages-first-time 2 + "time to load packages incrementally for the first time") +(defvar my$load-incrementally-packages-idle-time 0.75 + "idle time to load packages incrementally") (defun my:load-packages-incrementally (pkgs) "load package from PKGS incrementally" - (let ((gc-cons-threshold most-positive-fixnum)) + (let ((gc-cons-threshold most-positive-fixnum) + (pkg (car pkgs)) + (rest-pkgs (cdr pkgs))) (when pkgs - (if (featurep (car pkgs)) - (my:load-packages-incrementally (cdr pkgs)) + (if (featurep pkg) + (my:load-packages-incrementally rest-pkgs) (progn - (require (car pkgs)) - (run-with-idle-timer 0.75 nil #'my:load-packages-incrementally (cdr pkgs))))))) + (require pkg) + (run-with-idle-timer + my$load-incrementally-packages-idle-time nil + #'my:load-packages-incrementally rest-pkgs)))))) ;;;###autoload (defun my:load-packages-incrementally-setup () "Set up a idle timer to start idly load packages." - (run-with-idle-timer 2 nil #'my:load-packages-incrementally my$load-incrementally-packages)) + (run-with-idle-timer + my$load-incrementally-packages-first-time nil + #'my:load-packages-incrementally my$load-incrementally-packages)) (provide 'my-utils-autoloads) ;;; my-utils-autoloads ends here -- 2.45.2