From 0e2fa0ba1904e6d1f019be9e76265abe91ecc408 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 5 May 2022 22:43:44 +0200 Subject: [PATCH] fix(lib): type error on doom/restart-and-restore On Windows, restart-emacs doesn't escape its arguments properly (#6219). 56686f677a5d attempted to fix this, but ended up breaking it for everyone else as well, causing the type error: Wrong type argument: listp, "--eval \"(add-hook 'window-setup-hook #'doom-load-session 100)\"" This commit fixes both the regression and the original issue. Amend: 56686f677a5d Fix: #6219 --- core/autoload/sessions.el | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/autoload/sessions.el b/core/autoload/sessions.el index e32dff849..13e648cea 100644 --- a/core/autoload/sessions.el +++ b/core/autoload/sessions.el @@ -122,14 +122,22 @@ If DEBUG (the prefix arg) is given, start the new instance with the --debug switch." (interactive "P") - (setq doom-autosave-session nil) (doom/quicksave-session) (save-some-buffers nil t) (letf! ((#'save-buffers-kill-emacs #'kill-emacs) - (confirm-kill-emacs)) + (confirm-kill-emacs) + (tmpfile (make-temp-file "post-load"))) + ;; HACK `restart-emacs' does not properly escape arguments on Windows (in + ;; `restart-emacs--daemon-on-windows' and + ;; `restart-emacs--start-gui-on-windows'), so don't give it complex + ;; arguments at all. Should be fixed upstream, but restart-emacs seems to + ;; be unmaintained. + (with-temp-file tmpfile + (print `(progn (add-hook 'window-setup-hook #'doom-load-session 100) + (delete-file ,tmpfile)) + (current-buffer))) (restart-emacs - (combine-and-quote-strings - (append (if debug (list "--debug-init")) - (when (boundp 'chemacs-current-emacs-profile) - (list "--with-profile" chemacs-current-emacs-profile)) - (list "--eval" "(add-hook 'window-setup-hook #'doom-load-session 100)")))))) + (append (if debug (list "--debug-init")) + (when (boundp 'chemacs-current-emacs-profile) + (list "--with-profile" chemacs-current-emacs-profile)) + (list "-l" tmpfile)))))