diff options
| author | Juri Linkov | 2021-02-22 19:03:42 +0200 |
|---|---|---|
| committer | Juri Linkov | 2021-02-22 19:03:42 +0200 |
| commit | ffdb91c6b344b6b341e75ae981ebdb3e66b94130 (patch) | |
| tree | e4e698974fd9aff6fc53fceb282b1a5021b71f80 | |
| parent | 2601aa9105d935441ed25370feeeae3e717cc791 (diff) | |
| download | emacs-ffdb91c6b344b6b341e75ae981ebdb3e66b94130.tar.gz emacs-ffdb91c6b344b6b341e75ae981ebdb3e66b94130.zip | |
'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.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/tab-bar.el | 20 |
2 files changed, 18 insertions, 5 deletions
| @@ -487,6 +487,9 @@ independently from the value of 'tab-bar-mode' and 'tab-bar-show'. | |||
| 487 | *** New command 'tab-duplicate'. | 487 | *** New command 'tab-duplicate'. |
| 488 | 488 | ||
| 489 | --- | 489 | --- |
| 490 | *** 'Mod-9' bound to 'tab-last' now switches to the last tab. | ||
| 491 | |||
| 492 | --- | ||
| 490 | *** New user option 'tab-bar-tab-name-format-function'. | 493 | *** New user option 'tab-bar-tab-name-format-function'. |
| 491 | 494 | ||
| 492 | --- | 495 | --- |
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 83261042404..db2376d9efb 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 | |||
| 100 | "Install key bindings for switching between tabs if the user has configured them." | 100 | "Install key bindings for switching between tabs if the user has configured them." |
| 101 | (when tab-bar-select-tab-modifiers | 101 | (when tab-bar-select-tab-modifiers |
| 102 | (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0))) | 102 | (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0))) |
| 103 | 'tab-bar-switch-to-recent-tab) | 103 | 'tab-recent) |
| 104 | (dotimes (i 9) | 104 | (dotimes (i 8) |
| 105 | (global-set-key (vector (append tab-bar-select-tab-modifiers | 105 | (global-set-key (vector (append tab-bar-select-tab-modifiers |
| 106 | (list (+ i 1 ?0)))) | 106 | (list (+ i 1 ?0)))) |
| 107 | 'tab-bar-select-tab))) | 107 | 'tab-bar-select-tab)) |
| 108 | (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?9))) | ||
| 109 | 'tab-last)) | ||
| 108 | ;; Don't override user customized key bindings | 110 | ;; Don't override user customized key bindings |
| 109 | (unless (global-key-binding [(control tab)]) | 111 | (unless (global-key-binding [(control tab)]) |
| 110 | (global-set-key [(control tab)] 'tab-next)) | 112 | (global-set-key [(control tab)] 'tab-next)) |
| @@ -720,6 +722,12 @@ ARG counts from 1." | |||
| 720 | (setq arg 1)) | 722 | (setq arg 1)) |
| 721 | (tab-bar-switch-to-next-tab (- arg))) | 723 | (tab-bar-switch-to-next-tab (- arg))) |
| 722 | 724 | ||
| 725 | (defun tab-bar-switch-to-last-tab (&optional arg) | ||
| 726 | "Switch to the last tab or ARGth tab from the end of the tab bar." | ||
| 727 | (interactive "p") | ||
| 728 | (tab-bar-select-tab (- (length (funcall tab-bar-tabs-function)) | ||
| 729 | (1- (or arg 1))))) | ||
| 730 | |||
| 723 | (defun tab-bar-switch-to-recent-tab (&optional arg) | 731 | (defun tab-bar-switch-to-recent-tab (&optional arg) |
| 724 | "Switch to ARGth most recently visited tab." | 732 | "Switch to ARGth most recently visited tab." |
| 725 | (interactive "p") | 733 | (interactive "p") |
| @@ -734,7 +742,8 @@ ARG counts from 1." | |||
| 734 | "Switch to the tab by NAME. | 742 | "Switch to the tab by NAME. |
| 735 | Default values are tab names sorted by recency, so you can use \ | 743 | Default values are tab names sorted by recency, so you can use \ |
| 736 | \\<minibuffer-local-map>\\[next-history-element] | 744 | \\<minibuffer-local-map>\\[next-history-element] |
| 737 | to get the name of the last visited tab, the second last, and so on." | 745 | to get the name of the most recently visited tab, the second |
| 746 | most recent, and so on." | ||
| 738 | (interactive | 747 | (interactive |
| 739 | (let* ((recent-tabs (mapcar (lambda (tab) | 748 | (let* ((recent-tabs (mapcar (lambda (tab) |
| 740 | (alist-get 'name tab)) | 749 | (alist-get 'name tab)) |
| @@ -1070,7 +1079,7 @@ for the last tab on a frame is determined by | |||
| 1070 | (message "Deleted all other tabs"))))) | 1079 | (message "Deleted all other tabs"))))) |
| 1071 | 1080 | ||
| 1072 | (defun tab-bar-undo-close-tab () | 1081 | (defun tab-bar-undo-close-tab () |
| 1073 | "Restore the last closed tab." | 1082 | "Restore the most recently closed tab." |
| 1074 | (interactive) | 1083 | (interactive) |
| 1075 | ;; Pop out closed tabs that were on already deleted frames | 1084 | ;; Pop out closed tabs that were on already deleted frames |
| 1076 | (while (and tab-bar-closed-tabs | 1085 | (while (and tab-bar-closed-tabs |
| @@ -1261,6 +1270,7 @@ and can restore them." | |||
| 1261 | (defalias 'tab-select 'tab-bar-select-tab) | 1270 | (defalias 'tab-select 'tab-bar-select-tab) |
| 1262 | (defalias 'tab-next 'tab-bar-switch-to-next-tab) | 1271 | (defalias 'tab-next 'tab-bar-switch-to-next-tab) |
| 1263 | (defalias 'tab-previous 'tab-bar-switch-to-prev-tab) | 1272 | (defalias 'tab-previous 'tab-bar-switch-to-prev-tab) |
| 1273 | (defalias 'tab-last 'tab-bar-switch-to-last-tab) | ||
| 1264 | (defalias 'tab-recent 'tab-bar-switch-to-recent-tab) | 1274 | (defalias 'tab-recent 'tab-bar-switch-to-recent-tab) |
| 1265 | (defalias 'tab-move 'tab-bar-move-tab) | 1275 | (defalias 'tab-move 'tab-bar-move-tab) |
| 1266 | (defalias 'tab-move-to 'tab-bar-move-tab-to) | 1276 | (defalias 'tab-move-to 'tab-bar-move-tab-to) |