diff --git a/lisp/desktop.el b/lisp/desktop.el index 74961032303..df98079b1c2 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -1064,13 +1064,19 @@ DIRNAME must be the directory in which the desktop file will be saved." ;; ---------------------------------------------------------------------------- (defun desktop--check-dont-save (frame) - (not (frame-parameter frame 'desktop-dont-save))) + (and (not (frame-parameter frame 'desktop-dont-save)) + ;; Don't save daemon initial frames, since we cannot (and don't + ;; need to) restore them. + (not (and (daemonp) + (equal (terminal-name (frame-terminal frame)) + "initial_terminal"))))) (defconst desktop--app-id `(desktop . ,desktop-file-version)) (defun desktop-save-frameset () "Save the state of existing frames in `desktop-saved-frameset'. -Frames with a non-nil `desktop-dont-save' parameter are not saved." +Frames with a non-nil `desktop-dont-save' parameter are not saved. +Likewise the initial frame of a daemon sesion." (setq desktop-saved-frameset (and desktop-restore-frames (frameset-save nil diff --git a/lisp/frameset.el b/lisp/frameset.el index 85a90f67c68..e11a1da7e9b 100644 --- a/lisp/frameset.el +++ b/lisp/frameset.el @@ -1362,9 +1362,18 @@ All keyword parameters default to nil." ;; Clean up the frame list (when cleanup-frames (let ((map nil) - (cleanup (if (eq cleanup-frames t) - (lambda (frame action) - (when (memq action '(:rejected :ignored)) + (cleanup + (if (eq cleanup-frames t) + (lambda (frame action) + (when (and (memq action '(:rejected :ignored)) + ;; Don't try deleting the daemon's initial + ;; frame, as that would only trigger + ;; warnings. + (not + (and (daemonp) + (equal (terminal-name (frame-terminal + frame)) + "initial_terminal")))) (delete-frame frame))) cleanup-frames))) (maphash (lambda (frame _action) (push frame map)) frameset--action-map)