Function: tab-bar-undo-close-tab
tab-bar-undo-close-tab is an interactive and byte-compiled function
defined in tab-bar.el.gz.
Signature
(tab-bar-undo-close-tab)
Documentation
Restore the most recently closed tab.
Key Bindings
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar-undo-close-tab ()
"Restore the most recently closed tab."
(interactive)
;; Pop out closed tabs that were on already deleted frames
(while (and tab-bar-closed-tabs
(not (frame-live-p (alist-get 'frame (car tab-bar-closed-tabs)))))
(pop tab-bar-closed-tabs))
(if tab-bar-closed-tabs
(let* ((closed (pop tab-bar-closed-tabs))
(frame (alist-get 'frame closed))
(index (alist-get 'index closed))
(tab (alist-get 'tab closed)))
(unless (eq frame (selected-frame))
(select-frame-set-input-focus frame))
(let ((tabs (funcall tab-bar-tabs-function)))
(setq index (max 0 (min index (length tabs))))
(cl-pushnew tab (nthcdr index tabs))
(when (eq index 0)
;; `pushnew' handles the head of tabs but not frame-parameter
(tab-bar-tabs-set tabs))
(tab-bar-select-tab (1+ index)))
(run-hook-with-args 'tab-bar-post-undo-close-tab-functions
tab)
(tab-bar--update-tab-bar-lines))
(message "No more closed tabs to undo")))