mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
refactor: profile generators
This commit is contained in:
@ -52,10 +52,10 @@ Can be changed externally by setting $DOOMPROFILELOADFILE.")
|
|||||||
|
|
||||||
;;; Profile storage variables
|
;;; Profile storage variables
|
||||||
(defvar doom-profile-generators
|
(defvar doom-profile-generators
|
||||||
'(("05-vars.auto.el" . doom-profile--generate-init-vars)
|
'(("05-vars.auto.el" doom-profile--generate-vars doom--startup-vars)
|
||||||
("80-loaddefs.auto.el" . doom-profile--generate-doom-autoloads)
|
("80-loaddefs.auto.el" doom-profile--generate-loaddefs-doom doom--startup-loaddefs-doom)
|
||||||
("90-loaddefs-packages.auto.el" . doom-profile--generate-package-autoloads)
|
("90-loaddefs-packages.auto.el" doom-profile--generate-loaddefs-packages doom--startup-loaddefs-packages)
|
||||||
("95-modules.auto.el" . doom-profile--generate-load-modules))
|
("95-modules.auto.el" doom-profile--generate-load-modules doom--startup-modules))
|
||||||
"An alist mapping file names to generator functions.
|
"An alist mapping file names to generator functions.
|
||||||
|
|
||||||
The file will be generated in `doom-profile-dir'/`doom-profile-init-dir-name',
|
The file will be generated in `doom-profile-dir'/`doom-profile-init-dir-name',
|
||||||
@ -259,7 +259,7 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
|
|||||||
(dolist (file auto-files)
|
(dolist (file auto-files)
|
||||||
(print! (item "Deleting %s...") file)
|
(print! (item "Deleting %s...") file)
|
||||||
(delete-file file))
|
(delete-file file))
|
||||||
(pcase-dolist (`(,file . ,fn) doom-profile-generators)
|
(pcase-dolist (`(,file ,fn _) doom-profile-generators)
|
||||||
(let ((file (doom-path init-dir file)))
|
(let ((file (doom-path init-dir file)))
|
||||||
(doom-log "Building %s..." file)
|
(doom-log "Building %s..." file)
|
||||||
(insert "\n;;;; START " file " ;;;;\n")
|
(insert "\n;;;; START " file " ;;;;\n")
|
||||||
@ -292,18 +292,21 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
|
|||||||
(doom-file-read file :by 'insert))
|
(doom-file-read file :by 'insert))
|
||||||
(prin1 `(defun doom-startup ()
|
(prin1 `(defun doom-startup ()
|
||||||
(let ((startup-or-reload?
|
(let ((startup-or-reload?
|
||||||
|
;; Make sure this only runs at startup to protect
|
||||||
|
;; us Emacs' interpreter re-evaluating this file
|
||||||
|
;; when lazy-loading dynamic docstrings from the
|
||||||
|
;; byte-compiled init file.
|
||||||
(or (doom-context-p 'startup)
|
(or (doom-context-p 'startup)
|
||||||
(doom-context-p 'reload))))
|
(doom-context-p 'reload))))
|
||||||
(when startup-or-reload?
|
(when startup-or-reload?
|
||||||
(doom--startup-vars)
|
,@(cl-loop for (_ genfn initfn) in doom-profile-generators
|
||||||
(doom--startup-module-autoloads)
|
if (fboundp genfn)
|
||||||
(doom--startup-package-autoloads)
|
collect (list initfn))
|
||||||
(doom--startup-modules)
|
,@(when-let* ((info-dirs (butlast Info-directory-list)))
|
||||||
,(when-let* ((info-dirs (butlast Info-directory-list)))
|
`((require 'info)
|
||||||
`(progn (require 'info)
|
(info-initialize)
|
||||||
(info-initialize)
|
(setq Info-directory-list
|
||||||
(setq Info-directory-list
|
(append ',info-dirs Info-directory-list)))))))
|
||||||
(append ',info-dirs Info-directory-list)))))))
|
|
||||||
(current-buffer)))
|
(current-buffer)))
|
||||||
(print! (start "Byte-compiling %s...") (relpath init-file))
|
(print! (start "Byte-compiling %s...") (relpath init-file))
|
||||||
(print-group!
|
(print-group!
|
||||||
@ -314,10 +317,7 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
|
|||||||
(delete-file (byte-compile-dest-file init-file))
|
(delete-file (byte-compile-dest-file init-file))
|
||||||
(signal 'doom-autoload-error (list init-file e))))))
|
(signal 'doom-autoload-error (list init-file e))))))
|
||||||
|
|
||||||
(defun doom-profile--generate-init-vars ()
|
(defun doom-profile--generate-vars ()
|
||||||
;; FIX: Make sure this only runs at startup to protect us Emacs' interpreter
|
|
||||||
;; re-evaluating this file when lazy-loading dynamic docstrings from the
|
|
||||||
;; byte-compiled init file.
|
|
||||||
`((defun doom--startup-vars ()
|
`((defun doom--startup-vars ()
|
||||||
,@(cl-loop for var in doom-autoloads-cached-vars
|
,@(cl-loop for var in doom-autoloads-cached-vars
|
||||||
if (boundp var)
|
if (boundp var)
|
||||||
@ -400,8 +400,8 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
|
|||||||
(when (eq custom-file old-custom-file)
|
(when (eq custom-file old-custom-file)
|
||||||
(doom-load custom-file 'noerror)))))))))
|
(doom-load custom-file 'noerror)))))))))
|
||||||
|
|
||||||
(defun doom-profile--generate-doom-autoloads ()
|
(defun doom-profile--generate-loaddefs-doom ()
|
||||||
`((defun doom--startup-module-autoloads ()
|
`((defun doom--startup-loaddefs-doom ()
|
||||||
(let ((load-in-progress t))
|
(let ((load-in-progress t))
|
||||||
,@(doom-autoloads--scan
|
,@(doom-autoloads--scan
|
||||||
(append (doom-glob doom-core-dir "lib/*.el")
|
(append (doom-glob doom-core-dir "lib/*.el")
|
||||||
@ -413,8 +413,8 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
|
|||||||
(mapcan #'doom-glob doom-autoloads-files))
|
(mapcan #'doom-glob doom-autoloads-files))
|
||||||
nil)))))
|
nil)))))
|
||||||
|
|
||||||
(defun doom-profile--generate-package-autoloads ()
|
(defun doom-profile--generate-loaddefs-packages ()
|
||||||
`((defun doom--startup-package-autoloads ()
|
`((defun doom--startup-loaddefs-packages ()
|
||||||
(let ((load-in-progress t))
|
(let ((load-in-progress t))
|
||||||
,@(doom-autoloads--scan
|
,@(doom-autoloads--scan
|
||||||
(mapcar #'straight--autoloads-file
|
(mapcar #'straight--autoloads-file
|
||||||
|
Reference in New Issue
Block a user