]> git.eshelyaron.com Git - emacs.git/commitdiff
Have 'delete-frame' delete initial daemon frame only if FORCE is non-nil
authorMartin Rudalics <rudalics@gmx.at>
Thu, 29 May 2025 09:33:28 +0000 (11:33 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 7 Jun 2025 19:53:07 +0000 (21:53 +0200)
* 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)

doc/lispref/frames.texi
src/frame.c

index 0ad4f52bfc066196abd75c15704bc53e2c7a4ed1..7f14e002892f7a1130d29c9c93e0e64e75b1e52f 100644 (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
index 7f4303dbb012e0c6581f0d1cebeb337ad7bb00ea..7b2feefc0a39d93f7e6c00da2fa53d3f6b214898 100644 (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.