Fix desktop saving and restoring in daemon sessions

* lisp/desktop.el (desktop--check-dont-save): Don't save daemon's
initial frame.
* lisp/frameset.el (frameset-restore): Don't try deleting the
daemon's initial frame.  (Bug#80294)
This commit is contained in:
Eli Zaretskii 2026-02-01 08:49:57 +02:00
parent 87dfb040b0
commit 967294d2cb
2 changed files with 20 additions and 5 deletions

View file

@ -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

View file

@ -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)