From: Martin Rudalics Date: Thu, 29 May 2025 09:33:28 +0000 (+0200) Subject: Have 'delete-frame' delete initial daemon frame only if FORCE is non-nil X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=45e342ccc42405c2806ed5af1ed7c5866472b372;p=emacs.git 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. (cherry picked from commit 433a031d249a28a29bdc6c2c4cf880f26a262627) --- 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/src/frame.c b/src/frame.c index 7f4303dbb01..7b2feefc0a3 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.