wip: feat: Defer many packages

Shaving MILLISECONDS off our startup time!!!  Fuck yes!

I've measured the average startup time to be 0.68s in the previous commit, and an average of 0.52 with this commit.
This commit is contained in:
Madeleine Sydney
2025-01-08 06:52:18 -07:00
parent 27e78453e3
commit ab10e0ca56
9 changed files with 138 additions and 79 deletions

View File

@@ -95,6 +95,35 @@ On boot, ...
sydnix-cli is a command-line utility written in Clojure wrapping various sydnix-related scripts.
** Deferring Emacs packages
Nearly all configuration of Emacs packages happens under the ~use-package~ macro. ~use-package~ has various keywords with special syntax for common tasks, such as instrumenting hooks, setting keybindings, and customising variables. You may be surprised to learn that these are not /just/ syntactic sugar }:) (I was).
As an example, this
#+begin_src emacs-lisp
(use-package which-key
:hook (on-first-input . which-key-mode)
:custom
(which-key-allow-evil-operators t)
(which-key-show-operator-state-maps t)
#+end_src
is not the same as this
#+begin_src emacs-lisp
(use-package which-key
:config
(add-hook 'on-first-input #'which-key-mode)
(setq which-key-allow-evil-operators t)
(setq which-key-show-operator-state-maps t)
#+end_src
The difference connects to another silly obsession of the Emacs hacker: startup time. ~use-package~'s special keywords will /defer/ the loading of the package ([cite:@systemcrafters2021how]) . E.g., instead of loading ~which-key~ on startup, it will be loaded when the ~on-first-input~ hook is first called.
~on-first-input~ is one of many useful hooks provided by the package [[https://github.com/emacsmirror/on][on.el]] specialised for fine-grained control of package loading.
>>>>>>> Conflict 1 of 1 ends
* Tasks
** Begin setting up doomless Emacs