fix(lib): type error on doom/restart-and-restore

On Windows, restart-emacs doesn't escape its arguments properly (#6219).
56686f677a 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: 56686f677a
Fix: #6219
This commit is contained in:
Henrik Lissner 2022-05-05 22:43:44 +02:00
parent 80cd7557e1
commit 0e2fa0ba19
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -122,14 +122,22 @@
If DEBUG (the prefix arg) is given, start the new instance with the --debug If DEBUG (the prefix arg) is given, start the new instance with the --debug
switch." switch."
(interactive "P") (interactive "P")
(setq doom-autosave-session nil)
(doom/quicksave-session) (doom/quicksave-session)
(save-some-buffers nil t) (save-some-buffers nil t)
(letf! ((#'save-buffers-kill-emacs #'kill-emacs) (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 (restart-emacs
(combine-and-quote-strings (append (if debug (list "--debug-init"))
(append (if debug (list "--debug-init")) (when (boundp 'chemacs-current-emacs-profile)
(when (boundp 'chemacs-current-emacs-profile) (list "--with-profile" chemacs-current-emacs-profile))
(list "--with-profile" chemacs-current-emacs-profile)) (list "-l" tmpfile)))))
(list "--eval" "(add-hook 'window-setup-hook #'doom-load-session 100)"))))))