diff --git a/bin/doom b/bin/doom index a2e3300ff..9dc7dc8f1 100755 --- a/bin/doom +++ b/bin/doom @@ -269,12 +269,13 @@ SEE ALSO: (defcli-group! "Config Management" :docs "Commands for maintaining your Doom Emacs configuration." (defcli-autoload! ((sync s))) - (defcli-autoload! ((profiles profile))) + (defcli-autoload! ((profile pf))) (defcli-autoload! ((upgrade up))) (defcli-autoload! (env)) (defcli-autoload! (gc)) (defcli-autoload! (install)) + (defcli-obsolete! (profiles sync) (profile sync "--all") "3.0.0") (defcli-obsolete! ((build b)) (sync "--rebuild") "3.0.0") (defcli-obsolete! ((purge p)) (gc) "3.0.0") diff --git a/lisp/cli/profiles.el b/lisp/cli/profile.el similarity index 53% rename from lisp/cli/profiles.el rename to lisp/cli/profile.el index d69047db4..31ce84798 100644 --- a/lisp/cli/profiles.el +++ b/lisp/cli/profile.el @@ -1,56 +1,38 @@ -;;; lisp/cli/profiles.el -*- lexical-binding: t; -*- +;;; lisp/cli/profile.el -*- lexical-binding: t; -*- ;;; Commentary: ;;; Code: -;; -;;; Variables - -(defvar doom-cli-known-profiles-file - (file-name-concat doom-cache-dir (format "profiles.%s.el" (or (car doom-profile) "@"))) - ;; REVIEW: Use `doom-profile-data-dir' in v3 - ;; (file-name-concat doom-profile-data-dir "known-profiles.el") - "TODO") +(doom-require 'doom-lib 'profiles) ;; ;;; doom profile ... -(defcli-stub! ((profile pf)) ()) +(defcli! ((profile pf)) () + "Emacs profile management commands." + :partial t) -(defcli-stub! (profile hash) ()) - -(defcli-stub! (profile new) ()) - -(defcli-stub! (profile archive) ()) - -(defcli-stub! (profile (remove rm)) ()) - -(defcli-stub! (profile (rename mv)) ()) - -(defcli-stub! (profile nuke) ()) - - -;; -;;; doom profiles ... - -(defcli! (profiles sync) ((reload? ("--reload"))) +(defcli! (profile sync) + ((all? ("--all") "Synchronize all known profiles") + (reload? ("--reload") "Forcibly reload profile load file, even if its up-to-date")) "Synchronize your profiles with Doom." :benchmark t - (let* ((old-profiles (doom-profiles-read doom-cli-known-profiles-file)) - (new-profiles (doom-profiles-autodetect)) - (load-file doom-profile-load-file) - (version (doom-file-read load-file :by 'read :noerror t)) - (recreate? (or (not reload?) (doom-profiles-outdated-p)))) - (unless (file-exists-p load-file) - (print! (warn "No profile loader found. Generating one...")) - (print-group! (print! (start "Regenerating it..."))) - (setq recreate? t)) - (unless (equal (or version doom-version) doom-version) - (print! (warn "Detected version mismatch in profile loader (%s != %s)" - version doom-version)) - (print! (start "Generating profile manifest...")) - (setq recreate? t)) - (print-group! + (if (not all?) + (user-error "Individual profile syncing isn't implemented yet") + (let* ((old-profiles (doom-profiles-read doom-profile-cache-file)) + (new-profiles (doom-profiles-autodetect)) + (load-file doom-profile-load-file) + (version (doom-file-read load-file :by 'read :noerror t)) + (recreate? (or (not reload?) (doom-profiles-outdated-p)))) + (unless (file-exists-p load-file) + (print! (warn "No profile loader found. Generating one...")) + (print-group! (print! (start "Regenerating it..."))) + (setq recreate? t)) + (unless (equal (or version doom-version) doom-version) + (print! (warn "Detected version mismatch in profile loader (%s != %s)" + version doom-version)) + (print! (start "Generating profile manifest...")) + (setq recreate? t)) (if (not recreate?) (doom-log "Profiles are up-to-date!") (let* ((pred (lambda (a b) (eq (car a) (car b)))) @@ -68,10 +50,22 @@ (dolist (p added) (print! (item "Added %S") (car p))) (dolist (p removed) (print! (item "Removed %S") (car p))) (dolist (p changed) (print! (item "Changed %S") (car p))) - (doom-file-write doom-cli-known-profiles-file (list new-profiles) :mode #o600) + (doom-file-write doom-profile-cache-file (list new-profiles) :mode #o600) (doom-profiles-write-load-file new-profiles load-file) (print! (success "Regenerated profile loader: %s") (path load-file))))))))) -(provide 'doom-cli-profiles) -;;; profiles.el ends here +(defcli-stub! (profile hash) ()) + +(defcli-stub! (profile new) ()) + +(defcli-stub! (profile archive) ()) + +(defcli-stub! (profile (remove rm)) ()) + +(defcli-stub! (profile (rename mv)) ()) + +(defcli-stub! (profile nuke) ()) + +(provide 'doom-cli-profile) +;;; profile.el ends here diff --git a/lisp/cli/sync.el b/lisp/cli/sync.el index e40968d77..c40e131f2 100644 --- a/lisp/cli/sync.el +++ b/lisp/cli/sync.el @@ -56,7 +56,7 @@ OPTIONS: packages." :benchmark t (when (doom-profiles-bootloadable-p) - (call! '(profiles sync "--reload"))) + (call! '(profile sync "--all" "--reload"))) (when aot? (after! straight (setq straight--native-comp-available t))) diff --git a/lisp/lib/profiles.el b/lisp/lib/profiles.el index 3076cd50a..2935dfe7e 100644 --- a/lisp/lib/profiles.el +++ b/lisp/lib/profiles.el @@ -41,6 +41,13 @@ list of paths or profile config files (semi-colon delimited on Windows).") Can be changed externally by setting $DOOMPROFILELOADFILE.") +(defvar doom-profile-cache-file + (file-name-concat + doom-cache-dir (format "profiles.%s.el" (or (car doom-profile) "@"))) + "Where Doom writes its interactive profile loader script. + +Can be changed externally by setting $DOOMPROFILELOADFILE.") + (defvar doom-profile-env-file-name "init.env.el" "TODO")