refactor: restore doom-profile-default
And throw errors if a profile has the same name as the default (_).
This commit is contained in:
parent
b8cca048c4
commit
dc107e4a15
1 changed files with 29 additions and 27 deletions
|
@ -66,9 +66,7 @@ run.")
|
|||
|
||||
(defvar doom--profiles ())
|
||||
|
||||
;; TODO Restore this in 3.0
|
||||
(defconst doom-profile-default nil)
|
||||
;; (defconst doom-profile-default (cons "_" "0"))
|
||||
(defconst doom-profile-default (cons "_" "0"))
|
||||
|
||||
|
||||
;;
|
||||
|
@ -83,11 +81,13 @@ run.")
|
|||
(defun doom-profiles-read (&rest paths)
|
||||
"TODO"
|
||||
(let (profiles)
|
||||
(dolist (path (flatten-list paths))
|
||||
(dolist (path (delq nil (flatten-list paths)))
|
||||
(cond
|
||||
((file-directory-p path)
|
||||
(setq path (file-truename path))
|
||||
(dolist (subdir (doom-files-in path :depth 0 :match "/[^.][^/]+$" :type 'dirs :map #'file-name-base))
|
||||
(if (equal subdir (car doom-profile-default))
|
||||
(signal 'doom-profile-error (list (file-name-concat path subdir) "Implicit profile has invalid name"))
|
||||
(unless (string-prefix-p "_" subdir)
|
||||
(cl-pushnew
|
||||
(cons (intern subdir)
|
||||
|
@ -102,15 +102,15 @@ run.")
|
|||
'((doom-user-dir :path ,@val)))))))
|
||||
profiles
|
||||
:test #'eq
|
||||
:key #'car))))
|
||||
:key #'car)))))
|
||||
((file-exists-p path)
|
||||
(dolist (profile (car (doom-file-read path :by 'read*)))
|
||||
(if (eq (symbol-name (car profile)) (car doom-profile-default))
|
||||
(signal 'doom-profile-error (list path "Profile has invalid name: _"))
|
||||
(unless (string-prefix-p "_" (symbol-name (car profile)))
|
||||
(cl-pushnew profile profiles
|
||||
:test #'eq
|
||||
:key #'car))))))
|
||||
(when (assq '_ profiles)
|
||||
(signal 'doom-profile-error (list "Profile cannot be named _, as this is reserved for the implicit global profile")))
|
||||
:key #'car)))))))
|
||||
(nreverse profiles)))
|
||||
|
||||
(defun doom-profiles-autodetect ()
|
||||
|
@ -272,8 +272,10 @@ Defaults to the profile at `doom-profile-default'."
|
|||
(doom-profile<-id profile-id)
|
||||
(cl-check-type profile-id (or null string))
|
||||
(cl-check-type version (or null string))
|
||||
(cons (or profile-id (car doom-profile-default))
|
||||
(or version (cdr doom-profile-default))))
|
||||
(cons (or profile-id ;; (car doom-profile-default)
|
||||
)
|
||||
(or version ;; (cdr doom-profile-default)
|
||||
)))
|
||||
(file-name-concat doom-data-dir
|
||||
profile "@" version
|
||||
(format doom-profile-init-file-name emacs-major-version))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue