fix: desktop-read issue if Emacs process is a daemon

This commit is contained in:
Jason Tian 2024-07-09 19:00:00 +08:00
parent 16c2879a16
commit f810c51ec8
2 changed files with 12 additions and 1 deletions

View file

@ -228,6 +228,17 @@ The tee executable is required for the sudo execution."))
The tee executable is required for the sudo execution.")))
(write-region (point-min) (point-max) file))))
(defun my-run-after-emacs-startup (func)
"Run FUNC after Emacs startup, with special handling for daemon mode."
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(with-selected-frame frame
(funcall func))))
(add-hook 'emacs-startup-hook func)))
;; use the function for `desktop-read`
;; (my-run-after-emacs-startup 'desktop-read)
(provide 'init-pre)

View file

@ -17,7 +17,7 @@
)
(desktop-save-mode 1)
(add-hook 'emacs-startup-hook 'desktop-read)
(my-run-after-emacs-startup 'desktop-read)
;; save a bunch of variables to the desktop file
;; for lists specify the len of the maximal saved data also