Function: tab-bar-move-tab-to-group
tab-bar-move-tab-to-group is an interactive and byte-compiled function
defined in tab-bar.el.gz.
Signature
(tab-bar-move-tab-to-group &optional TAB)
Documentation
Relocate TAB (by default, the current tab) closer to its group.
Probably introduced at or before Emacs version 28.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
;;; Tab groups
(defun tab-bar-move-tab-to-group (&optional tab)
"Relocate TAB (by default, the current tab) closer to its group."
(interactive)
(let* ((tabs (funcall tab-bar-tabs-function))
(tab (or tab (tab-bar--current-tab-find tabs)))
(tab-index (tab-bar--tab-index tab))
(group (alist-get 'group tab))
;; Beginning position of the same group
(beg (seq-position tabs group
(lambda (tb gr)
(and (not (eq tb tab))
(equal (alist-get 'group tb) gr)))))
;; Size of the same group
(len (when beg
(seq-position (nthcdr beg tabs) group
(lambda (tb gr)
(not (equal (alist-get 'group tb) gr))))))
(pos (if beg
(cond
;; Don't move tab when it's already inside group bounds
((and len (>= tab-index beg) (<= tab-index (+ beg len))) nil)
;; Move tab from the right to the group end
((and len (> tab-index (+ beg len))) (+ beg len 1))
;; Move tab from the left to the group beginning
((< tab-index beg) beg))
;; Move tab with a new group to the end
-1)))
(when pos
(tab-bar-move-tab-to pos (1+ tab-index)))))