diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 0ad4f52bfc0..7f14e002892 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index 33b042720b5..13479790407 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/src/frame.c b/src/frame.c index f2acb19c77d..95fcb9ca7ff 100644 --- a/src/frame.c +++ b/src/frame.c @@ -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.