mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
tweak: centralize profile loader script
Because this file serves as a global manifest for Doom's profiles, it should be kept in a central location for any Doom instance to consult, rather than per-instance. Plus, post-v3 Doom will only write files to $XDG_*_HOME and $TMPDIR, therefore I'd like to avoid writing to $EMACSDIR. This change shouldn't affect end-users, in any case. Run 'doom sync' to regenerate the file, which should happen when you run 'doom upgrade' anyway.
This commit is contained in:
@ -78,22 +78,20 @@
|
|||||||
;; FIX: Discard the switch to prevent "invalid option" errors later.
|
;; FIX: Discard the switch to prevent "invalid option" errors later.
|
||||||
(push (cons "--profile" (lambda (_) (pop argv))) command-switch-alist)
|
(push (cons "--profile" (lambda (_) (pop argv))) command-switch-alist)
|
||||||
;; Running 'doom sync' or 'doom profile sync' (re)generates a light
|
;; Running 'doom sync' or 'doom profile sync' (re)generates a light
|
||||||
;; profile loader in $EMACSDIR/profiles/load.el (or
|
;; profile loader in $XDG_DATA_HOME/doom/profiles.X.el (or
|
||||||
;; $DOOMPROFILELOADFILE), after reading `doom-profile-load-path'. This
|
;; $DOOMPROFILELOADFILE), after reading `doom-profile-load-path'. This
|
||||||
;; loader requires `$DOOMPROFILE' be set to function.
|
;; loader requires `$DOOMPROFILE' be set to function.
|
||||||
(setenv "DOOMPROFILE" profile)
|
(setenv "DOOMPROFILE" profile)
|
||||||
(or (load (expand-file-name
|
(or (load (let ((windows? (memq system-type '(ms-dos windows-nt cygwin))))
|
||||||
(format (let ((lfile (getenv-internal "DOOMPROFILELOADFILE")))
|
(expand-file-name
|
||||||
(if lfile
|
(format (or (getenv-internal "DOOMPROFILELOADFILE")
|
||||||
(concat (let ((suffix ".el"))
|
(file-name-concat (if windows? "doomemacs/data" "doom")
|
||||||
(if (string-suffix-p suffix lfile)
|
"profiles.%d.el"))
|
||||||
(substring lfile 0 (- (length lfile) (length suffix)))
|
emacs-major-version)
|
||||||
lfile))
|
(or (if windows? (getenv-internal "LOCALAPPDATA"))
|
||||||
".%d.elc")
|
(getenv-internal "XDG_DATA_HOME")
|
||||||
"profiles/load.%d.elc"))
|
"~/.local/share"))
|
||||||
emacs-major-version)
|
'noerror (not init-file-debug) 'nosuffix))
|
||||||
user-emacs-directory)
|
|
||||||
'noerror (not init-file-debug) 'nosuffix)
|
|
||||||
(user-error "Profiles not initialized yet; run 'doom sync' first"))))
|
(user-error "Profiles not initialized yet; run 'doom sync' first"))))
|
||||||
|
|
||||||
;; PERF: When `load'ing or `require'ing files, each permutation of
|
;; PERF: When `load'ing or `require'ing files, each permutation of
|
||||||
|
@ -33,9 +33,15 @@ Can be changed externally by setting $DOOMPROFILELOADPATH to a colon-delimited
|
|||||||
list of paths or profile config files (semi-colon delimited on Windows).")
|
list of paths or profile config files (semi-colon delimited on Windows).")
|
||||||
|
|
||||||
(defvar doom-profile-load-file
|
(defvar doom-profile-load-file
|
||||||
(if-let (loader (getenv-internal "DOOMPROFILELOADFILE"))
|
;; REVIEW: Derive from `doom-data-dir' in v3
|
||||||
(expand-file-name loader doom-emacs-dir)
|
(expand-file-name
|
||||||
(file-name-concat doom-emacs-dir (format "profiles/load.el" emacs-major-version)))
|
(format (or (getenv-internal "DOOMPROFILELOADFILE")
|
||||||
|
(file-name-concat (if doom--system-windows-p "doomemacs/data" "doom")
|
||||||
|
"profiles.%d.el"))
|
||||||
|
emacs-major-version)
|
||||||
|
(or (if doom--system-windows-p (getenv-internal "LOCALAPPDATA"))
|
||||||
|
(getenv-internal "XDG_DATA_HOME")
|
||||||
|
"~/.local/share"))
|
||||||
"Where Doom writes its interactive profile loader script.
|
"Where Doom writes its interactive profile loader script.
|
||||||
|
|
||||||
Can be changed externally by setting $DOOMPROFILELOADFILE.")
|
Can be changed externally by setting $DOOMPROFILELOADFILE.")
|
||||||
|
Reference in New Issue
Block a user