Function: undelete-frame
undelete-frame is an interactive and byte-compiled function defined in
frame.el.gz.
Signature
(undelete-frame &optional ARG)
Documentation
Undelete a frame deleted with delete-frame.
Without a prefix argument, undelete the most recently deleted
frame.
With a numerical prefix argument ARG between 1 and 16, where 1 is
most recently deleted frame, undelete the ARGth deleted frame.
When called from Lisp, returns the new frame.
Return the undeleted frame, or nil if a frame was not undeleted.
An undeleted frame retains its original frame ID. See frame-id.
Probably introduced at or before Emacs version 31.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/frame.el.gz
(defun undelete-frame (&optional arg)
"Undelete a frame deleted with `delete-frame'.
Without a prefix argument, undelete the most recently deleted
frame.
With a numerical prefix argument ARG between 1 and 16, where 1 is
most recently deleted frame, undelete the ARGth deleted frame.
When called from Lisp, returns the new frame.
Return the undeleted frame, or nil if a frame was not undeleted.
An undeleted frame retains its original frame ID. See `frame-id'."
(interactive "P")
(if (not undelete-frame-mode)
(user-error "Undelete-Frame mode is disabled")
(if (consp arg)
(user-error "Missing deleted frame number argument")
(let* ((number (pcase arg ('nil 1) ('- -1) (_ arg)))
(frame-data (nth (1- number) undelete-frame--deleted-frames))
(graphic (display-graphic-p)))
(if (not (<= 1 number 16))
(user-error "%d is not a valid deleted frame number argument"
number)
(if (not frame-data)
(user-error "No deleted frame with number %d" number)
(if (not (eq graphic (nth 0 frame-data)))
(user-error
"Cannot undelete a %s display frame on a %s display"
(if graphic "non-graphic" "graphic")
(if graphic "graphic" "non-graphic"))
(setq undelete-frame--deleted-frames
(delq frame-data undelete-frame--deleted-frames))
(let* ((parameters
;; `undeleted' signals to `make-frame' to reuse its id.
(append `((undeleted . ,(nth 3 frame-data)))
(frame--purify-parameters (nth 1 frame-data))))
(frame (make-frame parameters)))
(window-state-put (nth 2 frame-data) (frame-root-window frame) 'safe)
(select-frame-set-input-focus frame)
frame))))))))