Function: tab-bar-move-tab-to-frame

tab-bar-move-tab-to-frame is an interactive and byte-compiled function defined in tab-bar.el.gz.

Signature

(tab-bar-move-tab-to-frame ARG &optional FROM-FRAME FROM-NUMBER TO-FRAME TO-NUMBER)

Documentation

Move tab from FROM-NUMBER position to new position at TO-NUMBER.

FROM-NUMBER defaults to the current tab number. FROM-NUMBER and TO-NUMBER count from 1. FROM-FRAME specifies the source frame and defaults to the selected frame. TO-FRAME specifies the target frame and defaults the next frame. Interactively, ARG selects the ARGth next frame on the same terminal, to which to move the tab; ARG defaults to 1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar-move-tab-to-frame (arg &optional from-frame from-number
                                      to-frame to-number)
  "Move tab from FROM-NUMBER position to new position at TO-NUMBER.
FROM-NUMBER defaults to the current tab number.
FROM-NUMBER and TO-NUMBER count from 1.
FROM-FRAME specifies the source frame and defaults to the selected frame.
TO-FRAME specifies the target frame and defaults the next frame.
Interactively, ARG selects the ARGth next frame on the same terminal,
to which to move the tab; ARG defaults to 1."
  (interactive "P")
  (unless from-frame
    (setq from-frame (selected-frame)))
  (unless to-frame
    (dotimes (_ (prefix-numeric-value arg))
      (setq to-frame (next-frame to-frame))))
  (unless (eq from-frame to-frame)
    (let* ((from-tabs (funcall tab-bar-tabs-function from-frame))
           (from-number (or from-number
                            (1+ (tab-bar--current-tab-index from-tabs))))
           (from-tab (nth (1- from-number) from-tabs))
           (to-tabs (funcall tab-bar-tabs-function to-frame))
           (to-index (max 0 (min (1- (or to-number 1)) (1- (length to-tabs))))))
      ;; Delete the window configuration (wc) that has frame references,
      ;; and leave only the window state (ws) to restore it on another frame.
      (cl-pushnew (assq-delete-all
                   'wc (if (eq (car from-tab) 'current-tab)
                           (tab-bar--tab from-frame)
                         from-tab))
                  (nthcdr to-index to-tabs))
      (with-selected-frame from-frame
        (let ((inhibit-message t) ; avoid message about deleted tab
              (tab-bar-close-last-tab-choice 'delete-frame)
              tab-bar-closed-tabs)
          (tab-bar-close-tab from-number)))
      (tab-bar-tabs-set to-tabs to-frame)
      (force-mode-line-update t))))