From 329d65d0d44b87878b6fcbf007f2c4d62f4b62e5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 17 Sep 2022 13:01:28 +0200 Subject: [PATCH] fix(profiles): unexpanded paths in implicit profiles Fixes two issues with implicit profiles: 1. Where user-emacs-directory (and sometimes doom-user-dir) would be unexpanded in the profile init file (generated by 'doom profiles sync'), which would be ineffective at runtime. 2. Where an implicit profile with a .doomprofile that lacks a user-emacs-directory setting would not have any user-emacs-directory set for it at all. Instead, it should fall back to that profile's location. --- lisp/doom-profiles.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lisp/doom-profiles.el b/lisp/doom-profiles.el index 6c66c92b1..b3da2a2a7 100644 --- a/lisp/doom-profiles.el +++ b/lisp/doom-profiles.el @@ -80,16 +80,20 @@ run.") (dolist (path (flatten-list paths)) (cond ((file-directory-p path) - (dolist (subdir (doom-files-in (file-truename path) :depth 0 :match "/[^.][^/]+$" :type 'dirs :map #'file-name-base)) + (setq path (file-truename path)) + (dolist (subdir (doom-files-in path :depth 0 :match "/[^.][^/]+$" :type 'dirs :map #'file-name-base)) (unless (string-prefix-p "_" subdir) (cl-pushnew (cons (intern subdir) - (if-let (profile-file (file-exists-p! doom-profiles-config-file-name path)) - (car (doom-file-read profile-file :by 'read*)) - (let ((subdir (file-name-as-directory (abbreviate-file-name subdir)))) - `((user-emacs-directory . ,subdir) - ,@(when (file-exists-p! "lisp/doom.el" subdir) - '(doom-user-dir . ,subdir)))))) + (let* ((val (abbreviate-file-name (file-name-as-directory subdir))) + (val (if (file-name-absolute-p val) + `(,val) + `(,(abbreviate-file-name path) ,val)))) + (cons `(user-emacs-directory :path ,@val) + (if-let (profile-file (file-exists-p! doom-profiles-config-file-name path)) + (car (doom-file-read profile-file :by 'read*)) + (when (file-exists-p (doom-path path subdir "lisp/doom.el")) + '((doom-user-dir :path ,@val))))))) profiles :test #'eq :key #'car))))