From e4bedfb5a0f0ef12e54c0052d9b4d673937e1475 Mon Sep 17 00:00:00 2001 From: Kiso Katsuyuki Date: Mon, 7 Sep 2020 17:14:09 -0500 Subject: [PATCH] Introduce a new variable tab-line-switch-cycling If it is set t, enable cycling tab switch. Default is nil. --- lisp/tab-line.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 3b4d3e68ad..23661c619a 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -659,7 +659,9 @@ tab-line-switch-to-prev-tab (eq buffer tab) (eq buffer (cdr (assq 'buffer tab))))))) (tab (if pos - (nth (1- pos) tabs))) + (if (and tab-line-switch-cycling (<= pos 0)) + (nth (1- (length tabs)) tabs) + (nth (1- pos) tabs)))) (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))) (when (bufferp buffer) (switch-to-buffer buffer))))))) @@ -681,11 +683,22 @@ tab-line-switch-to-next-tab (eq buffer tab) (eq buffer (cdr (assq 'buffer tab))))))) (tab (if pos - (nth (1+ pos) tabs))) + (if (and tab-line-switch-cycling (<= (length tabs) (1+ pos))) + (car tabs) + (nth (1+ pos) tabs)))) (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))) (when (bufferp buffer) (switch-to-buffer buffer))))))) +(defcustom tab-line-switch-cycling nil + "Enable cycling tab switch. +If non-nil, `tab-line-switch-to-prev-tab' in the first tab +switches to the last tab and `tab-line-switch-to-next-tab' in the last +tab swithces to the first tab." + :type 'boolean + :group 'tab-line + :version "28.1") + (defcustom tab-line-close-tab-function 'bury-buffer "Defines what to do on closing the tab. -- 2.28.0