refactor(profiles): bootstrap script

- Swap out the funcall+alist lookup for a pcase (which is expanded to a
  cond, which is is faster and easier to read).
- Wrap bootstrap file to $EMACSDIR/profiles/init.el, but byte-compile it
  to $EMACSDIR/profiles/init.X.el where X is emacs-major-version.
- Make doom-profiles-save's second argument optional (defaults to
  doom-profiles-bootstrap-file).
- Make doom-profiles-save throw a error if byte-compilation fails for
  some reason.
- Rename the tempvars to include 'doom' in their name, so debuggers know
  where they originate.
This commit is contained in:
Henrik Lissner 2022-09-17 20:21:43 +02:00
parent 09d24cd68a
commit 6dffa09c71
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
3 changed files with 89 additions and 87 deletions

View file

@ -81,9 +81,9 @@
;; $XDG_CONFIG_HOME/doom-profiles.el, and ~/.doom-profiles.el. All it
;; needs is for `$DOOMPROFILE' to be set.
(setenv "DOOMPROFILE" profile)
(or (load (expand-file-name (format "profiles/init.%d" emacs-major-version)
(or (load (expand-file-name (format "profiles/init.%d.elc" emacs-major-version)
user-emacs-directory)
'noerror (not init-file-debug) nil 'must-suffix)
'noerror (not init-file-debug) 'nosuffix)
(user-error "Profiles not initialized yet; run 'doom sync' first"))))
;; PERF: When `load'ing or `require'ing files, each permutation of