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 ())
|
(defvar doom--profiles ())
|
||||||
|
|
||||||
;; TODO Restore this in 3.0
|
(defconst doom-profile-default (cons "_" "0"))
|
||||||
(defconst doom-profile-default nil)
|
|
||||||
;; (defconst doom-profile-default (cons "_" "0"))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -83,34 +81,36 @@ run.")
|
||||||
(defun doom-profiles-read (&rest paths)
|
(defun doom-profiles-read (&rest paths)
|
||||||
"TODO"
|
"TODO"
|
||||||
(let (profiles)
|
(let (profiles)
|
||||||
(dolist (path (flatten-list paths))
|
(dolist (path (delq nil (flatten-list paths)))
|
||||||
(cond
|
(cond
|
||||||
((file-directory-p path)
|
((file-directory-p path)
|
||||||
(setq path (file-truename path))
|
(setq path (file-truename path))
|
||||||
(dolist (subdir (doom-files-in path :depth 0 :match "/[^.][^/]+$" :type 'dirs :map #'file-name-base))
|
(dolist (subdir (doom-files-in path :depth 0 :match "/[^.][^/]+$" :type 'dirs :map #'file-name-base))
|
||||||
(unless (string-prefix-p "_" subdir)
|
(if (equal subdir (car doom-profile-default))
|
||||||
(cl-pushnew
|
(signal 'doom-profile-error (list (file-name-concat path subdir) "Implicit profile has invalid name"))
|
||||||
(cons (intern subdir)
|
(unless (string-prefix-p "_" subdir)
|
||||||
(let* ((val (abbreviate-file-name (file-name-as-directory subdir)))
|
(cl-pushnew
|
||||||
(val (if (file-name-absolute-p val)
|
(cons (intern subdir)
|
||||||
`(,val)
|
(let* ((val (abbreviate-file-name (file-name-as-directory subdir)))
|
||||||
`(,(abbreviate-file-name path) ,val))))
|
(val (if (file-name-absolute-p val)
|
||||||
(cons `(user-emacs-directory :path ,@val)
|
`(,val)
|
||||||
(if-let (profile-file (file-exists-p! doom-profiles-config-file-name path))
|
`(,(abbreviate-file-name path) ,val))))
|
||||||
(car (doom-file-read profile-file :by 'read*))
|
(cons `(user-emacs-directory :path ,@val)
|
||||||
(when (file-exists-p (doom-path path subdir "lisp/doom.el"))
|
(if-let (profile-file (file-exists-p! doom-profiles-config-file-name path))
|
||||||
'((doom-user-dir :path ,@val)))))))
|
(car (doom-file-read profile-file :by 'read*))
|
||||||
profiles
|
(when (file-exists-p (doom-path path subdir "lisp/doom.el"))
|
||||||
:test #'eq
|
'((doom-user-dir :path ,@val)))))))
|
||||||
:key #'car))))
|
profiles
|
||||||
|
:test #'eq
|
||||||
|
:key #'car)))))
|
||||||
((file-exists-p path)
|
((file-exists-p path)
|
||||||
(dolist (profile (car (doom-file-read path :by 'read*)))
|
(dolist (profile (car (doom-file-read path :by 'read*)))
|
||||||
(unless (string-prefix-p "_" (symbol-name (car profile)))
|
(if (eq (symbol-name (car profile)) (car doom-profile-default))
|
||||||
(cl-pushnew profile profiles
|
(signal 'doom-profile-error (list path "Profile has invalid name: _"))
|
||||||
:test #'eq
|
(unless (string-prefix-p "_" (symbol-name (car profile)))
|
||||||
:key #'car))))))
|
(cl-pushnew profile profiles
|
||||||
(when (assq '_ profiles)
|
:test #'eq
|
||||||
(signal 'doom-profile-error (list "Profile cannot be named _, as this is reserved for the implicit global profile")))
|
:key #'car)))))))
|
||||||
(nreverse profiles)))
|
(nreverse profiles)))
|
||||||
|
|
||||||
(defun doom-profiles-autodetect ()
|
(defun doom-profiles-autodetect ()
|
||||||
|
@ -272,8 +272,10 @@ Defaults to the profile at `doom-profile-default'."
|
||||||
(doom-profile<-id profile-id)
|
(doom-profile<-id profile-id)
|
||||||
(cl-check-type profile-id (or null string))
|
(cl-check-type profile-id (or null string))
|
||||||
(cl-check-type version (or null string))
|
(cl-check-type version (or null string))
|
||||||
(cons (or profile-id (car doom-profile-default))
|
(cons (or profile-id ;; (car doom-profile-default)
|
||||||
(or version (cdr doom-profile-default))))
|
)
|
||||||
|
(or version ;; (cdr doom-profile-default)
|
||||||
|
)))
|
||||||
(file-name-concat doom-data-dir
|
(file-name-concat doom-data-dir
|
||||||
profile "@" version
|
profile "@" version
|
||||||
(format doom-profile-init-file-name emacs-major-version))))
|
(format doom-profile-init-file-name emacs-major-version))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue