summaryrefslogtreecommitdiff
path: root/lisp/tab-line.el
diff options
context:
space:
mode:
authorKiso Katsuyuki <katsuyuki2388@gmail.com>2020-09-09 22:22:49 +0300
committerJuri Linkov <juri@linkov.net>2020-09-09 22:24:06 +0300
commit5d436090952559eb4fe8204e75760f96dcadd599 (patch)
treebcbf91dfdb2ce8519d409860e8fccd2600dbc121 /lisp/tab-line.el
parentc3f986a4557b8785e16daf84f94c029b89c9feff (diff)
downloademacs-5d436090952559eb4fe8204e75760f96dcadd599.tar.gz
Introduce a new variable tab-line-switch-cycling
If it is set t, enable cycling tab switch. Default is nil. Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/tab-line.el')
-rw-r--r--lisp/tab-line.el19
1 files changed, 17 insertions, 2 deletions
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 140ee8c389e..ddba483859c 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -658,7 +658,10 @@ Its effect is the same as using the `previous-buffer' command
(if (bufferp tab)
(eq buffer tab)
(eq buffer (cdr (assq 'buffer tab)))))))
- (tab (if pos (nth (1- pos) tabs)))
+ (tab (if pos
+ (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)))))))
@@ -679,11 +682,23 @@ Its effect is the same as using the `next-buffer' command
(if (bufferp tab)
(eq buffer tab)
(eq buffer (cdr (assq 'buffer tab)))))))
- (tab (if pos (nth (1+ pos) tabs)))
+ (tab (if pos
+ (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.