From: Juri Linkov Date: Tue, 16 Mar 2021 17:54:54 +0000 (+0200) Subject: * lisp/tab-bar.el (tab-bar-select-tab): Support negative arg. X-Git-Tag: emacs-28.0.90~3256 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6199cdc78bde331cbb9fab4fbb93b467559bf461;p=emacs.git * lisp/tab-bar.el (tab-bar-select-tab): Support negative arg. --- diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 888f493ddcc..351c8cff349 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))