emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5d43609 2/2: Introduce a new variable tab-line-switch-cycling


From: Juri Linkov
Subject: master 5d43609 2/2: Introduce a new variable tab-line-switch-cycling
Date: Wed, 9 Sep 2020 15:30:46 -0400 (EDT)

branch: master
commit 5d436090952559eb4fe8204e75760f96dcadd599
Author: Kiso Katsuyuki <katsuyuki2388@gmail.com>
Commit: Juri Linkov <juri@linkov.net>

    Introduce a new variable tab-line-switch-cycling
    
    If it is set t, enable cycling tab switch.  Default is nil.
    
    Copyright-paperwork-exempt: yes
---
 lisp/tab-line.el | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 140ee8c..ddba483 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]