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
This commit is contained in:
Henrik Lissner 2022-05-12 00:41:56 +02:00
parent 1b8f46c7c5
commit 797866b596
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -231,7 +231,24 @@ All arguments are passed on to Emacs.
WARNING: this command exists for convenience and testing. Doom will suffer WARNING: this command exists for convenience and testing. Doom will suffer
additional overhead by being started this way. For the best performance, it is additional overhead by being started this way. For the best performance, it is
best to run Doom out of ~/.emacs.d and ~/.doom.d." 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))))))
;; ;;