Function: tab-bar-move-tab-to

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

Signature

(tab-bar-move-tab-to TO-NUMBER &optional FROM-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. Negative TO-NUMBER counts tabs from the end of the tab bar. Argument addressing is absolute in contrast to tab-bar-move-tab where argument addressing is relative.

Key Bindings

Aliases

tab-move-to

Source Code

;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar-move-tab-to (to-number &optional from-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.
Negative TO-NUMBER counts tabs from the end of the tab bar.
Argument addressing is absolute in contrast to `tab-bar-move-tab'
where argument addressing is relative."
  (interactive "P")
  (let* ((tabs (funcall tab-bar-tabs-function))
         (from-number (or from-number (1+ (tab-bar--current-tab-index tabs))))
         (from-tab (nth (1- from-number) tabs))
         (to-number (if to-number (prefix-numeric-value to-number) 1))
         (to-number (if (< to-number 0) (+ (length tabs) (1+ to-number)) to-number))
         (to-index (max 0 (min (1- to-number) (1- (length tabs))))))
    (setq tabs (delq from-tab tabs))
    (cl-pushnew from-tab (nthcdr to-index tabs))
    (tab-bar-tabs-set tabs)
    (force-mode-line-update)))