emacs-diffs
[Top][All Lists]
Advanced

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

master 6199cdc 2/2: * lisp/tab-bar.el (tab-bar-select-tab): Support nega


From: Juri Linkov
Subject: master 6199cdc 2/2: * lisp/tab-bar.el (tab-bar-select-tab): Support negative arg.
Date: Tue, 16 Mar 2021 13:55:18 -0400 (EDT)

branch: master
commit 6199cdc78bde331cbb9fab4fbb93b467559bf461
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/tab-bar.el (tab-bar-select-tab): Support negative arg.
---
 lisp/tab-bar.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 888f493..351c8cf 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -814,7 +814,7 @@ on the tab bar instead."
 When this command is bound to a numeric key (with a prefix or modifier key
 using `tab-bar-select-tab-modifiers'), calling it without an argument
 will translate its bound numeric key to the numeric argument.
-ARG counts from 1."
+ARG counts from 1.  Negative ARG counts tabs from the end of the tab bar."
   (interactive "P")
   (unless (integerp arg)
     (let ((key (event-basic-type last-command-event)))
@@ -824,7 +824,9 @@ ARG counts from 1."
 
   (let* ((tabs (funcall tab-bar-tabs-function))
          (from-index (tab-bar--current-tab-index tabs))
-         (to-index (1- (max 1 (min arg (length tabs))))))
+         (to-index (if (< arg 0) (+ (length tabs) (1+ arg)) arg))
+         (to-index (1- (max 1 (min to-index (length tabs))))))
+
     (unless (eq from-index to-index)
       (let* ((from-tab (tab-bar--tab))
              (to-tab (nth to-index tabs))



reply via email to

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