Function: tab-bar-merge-tabs

tab-bar-merge-tabs is an interactive and byte-compiled function defined in tab-bar.el.gz.

Signature

(tab-bar-merge-tabs &optional TAB1 TAB2 VERTICAL)

Documentation

Merge the main window of TAB2 into TAB1.

Split the main window of TAB1 and make the new window display the main window of TAB2. Both TAB1 and TAB2 must be tab numbers. If VERTICAL is non-nil, make the new window below the old main window of TAB1. Otherwise, make the new window on the right of TAB1's main window. Interactively, VERTICAL is the prefix argument, TAB1 is the selected tab and TAB2 is the recent tab. Close TAB2 if the merge completed successfully and return TAB1.

Key Bindings

Aliases

merge-tabs

Source Code

;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar-merge-tabs (&optional tab1 tab2 vertical)
  "Merge the main window of TAB2 into TAB1.
Split the main window of TAB1 and make the new window display
the main window of TAB2.  Both TAB1 and TAB2 must be tab numbers.
If VERTICAL is non-nil, make the new window below the old main window
of TAB1.  Otherwise, make the new window on the right of TAB1's main
window.  Interactively, VERTICAL is the prefix argument, TAB1 is the
selected tab and TAB2 is the recent tab.  Close TAB2 if the merge
completed successfully and return TAB1."
  (interactive "i\ni\nP")
  (let ((tab1 (or tab1 (1+ (tab-bar--current-tab-index))))
        (tab2 (or tab2 (1+ (or (tab-bar--tab-index-recent 1) 0))))
        ws2)
    (when (eq tab1 tab2)
      (user-error "Cannot find tab to merge"))
    (tab-bar-select-tab tab2)
    (setq ws2 (window-state-get (window-main-window)))
    (let ((tab-bar-close-tab-select 'recent)
          (tab-bar-closed-tabs nil))
      (tab-bar-close-tab))
    (unless (eq tab1 (1+ (tab-bar--current-tab-index)))
      (tab-bar-select-tab tab1))
    (window-state-put
     ws2
     ;; Make new window on tab1.
     (split-window (window-main-window) nil (not vertical)))
    tab1))