From 797866b59601f93647a8f9bca644ad5766a03978 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 May 2022 00:41:56 +0200 Subject: [PATCH] fix(cli): doom run not launching from parent dir 'doom run' was launching out of Emacs' default directories (~/.config/emacs and ~/.emacs.d) instead of the parent directory of bin/doom. This commit corrects that, but is a temporary measure until the CLI rewrite. I'm also not totally sure this will work on Windows... Fix: #6389 --- core/core-cli.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/core-cli.el b/core/core-cli.el index 2ebd05ed6..9702aa38c 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -231,7 +231,24 @@ All arguments are passed on to Emacs. WARNING: this command exists for convenience and testing. Doom will suffer additional overhead by being started this way. For the best performance, it is best to run Doom out of ~/.emacs.d and ~/.doom.d." - (throw 'exit (cons invocation-name args)))) + ;; TODO Does this work on Windows? + (let* ((tempdir (doom-path (temporary-file-directory) "doom.run")) + (tempemacsdir (doom-path tempdir ".emacs.d"))) + (delete-directory tempdir t) + (make-directory tempemacsdir t) + (with-temp-file (doom-path tempemacsdir "early-init.el") + (prin1 `(progn + (setenv "HOME" ,(getenv "HOME")) + (setq user-emacs-directory ,doom-emacs-dir) + (load ,(doom-path doom-emacs-dir "early-init.el") + nil ,(not doom-debug-mode)) + (define-advice startup--load-user-init-file (:filter-args (args) init-doom) + (cons (lambda () ,(doom-path doom-emacs-dir "init.el")) + (cdr args)))) + (current-buffer))) + (throw 'exit (format "HOME=%S %s %s" + tempdir invocation-name + (combine-and-quote-strings args)))))) ;;