Skip to content

Instantly share code, notes, and snippets.

@jbester
jbester / init.el
Last active March 11, 2024 14:37
Custom Tabline next/prev
(defun custom-tab-line-switch-to-next-tab (&optional mouse-event)
"Switch to the next tab - cycle back to the start at the end.
Its effect is the same as using the `next-buffer' command
(\\[next-buffer]). with the exception it will not open a non-visible buffer"
(interactive (list last-nonmenu-event))
(let ((window (and (listp mouse-event) (posn-window (event-start mouse-event)))))
(with-selected-window (or window (selected-window))
(let* ((tabs (funcall tab-line-tabs-function))
(tab-buffers (mapcar (lambda (tab) (if (bufferp tab) tab (cdr (assq 'buffer tab)))) tabs))
(num-tabs (length tab-buffers))