[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ffdb91c 2/4: 'Mod-9' bound to 'tab-last' now switches to the last
From: |
Juri Linkov |
Subject: |
master ffdb91c 2/4: 'Mod-9' bound to 'tab-last' now switches to the last tab like in web browsers |
Date: |
Mon, 22 Feb 2021 12:13:33 -0500 (EST) |
branch: master
commit ffdb91c6b344b6b341e75ae981ebdb3e66b94130
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
'Mod-9' bound to 'tab-last' now switches to the last tab like in web
browsers
* lisp/tab-bar.el (tab-bar--define-keys): Rebind 0 from
tab-bar-switch-to-recent-tab to its alias tab-recent.
Bind 9 to tab-last.
(tab-bar-switch-to-last-tab): New command.
(tab-last): New alias to tab-bar-switch-to-last-tab.
(tab-bar-switch-to-tab, tab-bar-undo-close-tab): Fix docstrings to
avoid mentioning the term "last" for "most recently used" meaning.
---
etc/NEWS | 3 +++
lisp/tab-bar.el | 20 +++++++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index c4f4c1d..ca0d715 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -487,6 +487,9 @@ independently from the value of 'tab-bar-mode' and
'tab-bar-show'.
*** New command 'tab-duplicate'.
---
+*** 'Mod-9' bound to 'tab-last' now switches to the last tab.
+
+---
*** New user option 'tab-bar-tab-name-format-function'.
---
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 8326104..db2376d 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -100,11 +100,13 @@ Possible modifier keys are `control', `meta', `shift',
`hyper', `super' and
"Install key bindings for switching between tabs if the user has configured
them."
(when tab-bar-select-tab-modifiers
(global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0)))
- 'tab-bar-switch-to-recent-tab)
- (dotimes (i 9)
+ 'tab-recent)
+ (dotimes (i 8)
(global-set-key (vector (append tab-bar-select-tab-modifiers
(list (+ i 1 ?0))))
- 'tab-bar-select-tab)))
+ 'tab-bar-select-tab))
+ (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?9)))
+ 'tab-last))
;; Don't override user customized key bindings
(unless (global-key-binding [(control tab)])
(global-set-key [(control tab)] 'tab-next))
@@ -720,6 +722,12 @@ ARG counts from 1."
(setq arg 1))
(tab-bar-switch-to-next-tab (- arg)))
+(defun tab-bar-switch-to-last-tab (&optional arg)
+ "Switch to the last tab or ARGth tab from the end of the tab bar."
+ (interactive "p")
+ (tab-bar-select-tab (- (length (funcall tab-bar-tabs-function))
+ (1- (or arg 1)))))
+
(defun tab-bar-switch-to-recent-tab (&optional arg)
"Switch to ARGth most recently visited tab."
(interactive "p")
@@ -734,7 +742,8 @@ ARG counts from 1."
"Switch to the tab by NAME.
Default values are tab names sorted by recency, so you can use \
\\<minibuffer-local-map>\\[next-history-element]
-to get the name of the last visited tab, the second last, and so on."
+to get the name of the most recently visited tab, the second
+most recent, and so on."
(interactive
(let* ((recent-tabs (mapcar (lambda (tab)
(alist-get 'name tab))
@@ -1070,7 +1079,7 @@ for the last tab on a frame is determined by
(message "Deleted all other tabs")))))
(defun tab-bar-undo-close-tab ()
- "Restore the last closed tab."
+ "Restore the most recently closed tab."
(interactive)
;; Pop out closed tabs that were on already deleted frames
(while (and tab-bar-closed-tabs
@@ -1261,6 +1270,7 @@ and can restore them."
(defalias 'tab-select 'tab-bar-select-tab)
(defalias 'tab-next 'tab-bar-switch-to-next-tab)
(defalias 'tab-previous 'tab-bar-switch-to-prev-tab)
+(defalias 'tab-last 'tab-bar-switch-to-last-tab)
(defalias 'tab-recent 'tab-bar-switch-to-recent-tab)
(defalias 'tab-move 'tab-bar-move-tab)
(defalias 'tab-move-to 'tab-bar-move-tab-to)