Function: tab-line-switch-to-next-tab

tab-line-switch-to-next-tab is an interactive and byte-compiled function defined in tab-line.el.gz.

Signature

(tab-line-switch-to-next-tab &optional EVENT ARG)

Documentation

Switch to the next ARGth tab's buffer.

When tab-line-tabs-function is tab-line-tabs-window-buffers, its effect is the same as using the next-buffer command
(C-x <right> (next-buffer)).
For other values of tab-line-tabs-function this command switches to the next buffer in the sequence defined by tab-line-tabs-function. To wrap buffer cycling in this case is possible when tab-line-switch-cycling is non-nil.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/tab-line.el.gz
(defun tab-line-switch-to-next-tab (&optional event arg)
 "Switch to the next ARGth tab's buffer.
When `tab-line-tabs-function' is `tab-line-tabs-window-buffers',
its effect is the same as using the `next-buffer' command
\(\\[next-buffer]).
For other values of `tab-line-tabs-function' this command
switches to the next buffer in the sequence defined by
`tab-line-tabs-function'.  To wrap buffer cycling in this case
is possible when `tab-line-switch-cycling' is non-nil."
  (interactive (list last-nonmenu-event
                     (prefix-numeric-value current-prefix-arg)))
  (let ((window (and (listp event) (posn-window (event-start event)))))
    (with-selected-window (or window (selected-window))
      (if (eq tab-line-tabs-function #'tab-line-tabs-window-buffers)
          (next-buffer arg t)
        (let* ((buffers (seq-keep
                         (lambda (tab) (or (and (bufferp tab) tab)
                                           (alist-get 'buffer tab)))
                         (funcall tab-line-tabs-function)))
               (old-pos (seq-position buffers (current-buffer)))
               (new-pos (when old-pos (+ old-pos (or arg 1))))
               (new-pos (when new-pos
                          (if tab-line-switch-cycling
                              (mod new-pos (length buffers))
                            (min new-pos (1- (length buffers))))))
               (buffer (when new-pos (nth new-pos buffers))))
          (when (bufferp buffer)
            (let ((switch-to-buffer-obey-display-actions nil))
              (switch-to-buffer buffer))))))))