Have 'delete-frame' delete initial daemon frame only if FORCE is non-nil

* src/frame.c (delete_frame): Delete initial daemon frame only
if FORCE is non-nil (Bug#78583).
(Fdelete_frame): Rewrite doc-string to mention that it can
delete an initial daemon frame if and only if FORCE is non-nil.
* etc/NEWS:
* doc/lispref/frames.texi (Deleting Frames): Mention that
'delete-frame' can delete an initial daemon frame if and only if
FORCE is non-nil.
This commit is contained in:
Martin Rudalics 2025-05-29 11:33:28 +02:00
parent d14fc6b75f
commit 433a031d24
3 changed files with 15 additions and 4 deletions

View file

@ -2808,6 +2808,9 @@ Note that a frame cannot be deleted as long as its minibuffer serves as
surrogate minibuffer for another frame (@pxref{Minibuffers and Frames}).
Normally, you cannot delete a frame if all other frames are invisible,
but if @var{force} is non-@code{nil}, then you are allowed to do so.
Also, the initial terminal frame of an Emacs process running as daemon
(@pxref{Initial Options, daemon,, emacs, The GNU Emacs Manual}) can be
deleted if and only if @var{force} is non-@code{nil}.
@end deffn
@defun frame-live-p frame

View file

@ -2195,6 +2195,11 @@ The unused variables 'block-comment-start' and 'block-comment-end',
which never actually had any effect when set by major modes, have been
removed.
+++
** 'delete-frame' now needs non-nil FORCE argument to delete daemon frame.
The initial terminal frame of an Emacs process running as daemon can be
deleted via 'delete-frame' if and only if its optional FORCE argument is
non-nil.
* Lisp Changes in Emacs 31.1

View file

@ -2481,6 +2481,8 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
else
error ("Attempt to delete the only frame");
}
else if (IS_DAEMON && FRAME_INITIAL_P (f) && NILP (force))
error ("Attempt to delete daemon's initial frame");
#ifdef HAVE_X_WINDOWS
else if ((x_dnd_in_progress && f == x_dnd_frame)
|| (x_dnd_waiting_for_finish && f == x_dnd_finish_frame))
@ -2953,10 +2955,11 @@ FRAME must be a live frame and defaults to the selected one.
When `undelete-frame-mode' is enabled, the 16 most recently deleted
frames can be undeleted with `undelete-frame', which see.
A frame may not be deleted if its minibuffer serves as surrogate
minibuffer for another frame. Normally, you may not delete a frame if
all other frames are invisible, but if the second optional argument
FORCE is non-nil, you may do so.
Do not delete a frame whose minibuffer serves as surrogate minibuffer
for another frame. Do not delete a frame if all other frames are
invisible unless the second optional argument FORCE is non-nil. Do not
delete the initial terminal frame of an Emacs process running as daemon
unless FORCE is non-nil.
This function runs `delete-frame-functions' before actually
deleting the frame, unless the frame is a tooltip.