From 5936af79326e8d484d482ed9a9cc1a3d3dd90f49 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 switch cycling. Default is nil. --- lisp/tab-line.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 3b4d3e68ad..2ad1b6a330 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,21 @@ 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 `tab-line-switch-to-next-tab', + `tab-line-switch-to-prev-tab' cycling switch. If the value is t, + the cycling switch is enabled. If the value is nil, it is disabled." + :type '(choice (const :tag "Disabled" nil) + (other :tag "Enabled" t)) + :group 'tab-line) + (defcustom tab-line-close-tab-function 'bury-buffer "Defines what to do on closing the tab. -- 2.28.0