diff options
| author | Juri Linkov | 2019-10-15 23:38:18 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-10-15 23:38:18 +0300 |
| commit | 56a7c60872272eef2dbd4fd071d0af0441f374d8 (patch) | |
| tree | 3e1a4530d863d484bcb205f5092e82390c3d8253 | |
| parent | ffa90546980c71fc0c2355005b382f07405aeeec (diff) | |
| download | emacs-56a7c60872272eef2dbd4fd071d0af0441f374d8.tar.gz emacs-56a7c60872272eef2dbd4fd071d0af0441f374d8.zip | |
* lisp/tab-bar.el (tab-bar-select-tab-modifiers): New defcustom.
(tab-bar-mode): Use tab-bar-select-tab-modifiers to bind
tab-bar-select-tab.
Don't override user customized key bindings of C-TAB, C-S-TAB.
On disabling tab-bar-mode, unset only keys bound by tab-bar.
| -rw-r--r-- | lisp/tab-bar.el | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 13829efe94c..f9d4de4ebf2 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el | |||
| @@ -84,6 +84,27 @@ | |||
| 84 | :group 'tab-bar-faces) | 84 | :group 'tab-bar-faces) |
| 85 | 85 | ||
| 86 | 86 | ||
| 87 | (defcustom tab-bar-select-tab-modifiers '() | ||
| 88 | "List of key modifiers for selecting a tab by its index digit. | ||
| 89 | Possible modifiers are `control', `meta', `shift', `hyper', `super' and | ||
| 90 | `alt'." | ||
| 91 | :type '(set :tag "Tab selection key modifiers" | ||
| 92 | (const control) | ||
| 93 | (const meta) | ||
| 94 | (const shift) | ||
| 95 | (const hyper) | ||
| 96 | (const super) | ||
| 97 | (const alt)) | ||
| 98 | :initialize 'custom-initialize-default | ||
| 99 | :set (lambda (sym val) | ||
| 100 | (set-default sym val) | ||
| 101 | ;; Reenable the tab-bar with new keybindings | ||
| 102 | (tab-bar-mode -1) | ||
| 103 | (tab-bar-mode 1)) | ||
| 104 | :group 'tab-bar | ||
| 105 | :version "27.1") | ||
| 106 | |||
| 107 | |||
| 87 | (define-minor-mode tab-bar-mode | 108 | (define-minor-mode tab-bar-mode |
| 88 | "Toggle the tab bar in all graphical frames (Tab Bar mode)." | 109 | "Toggle the tab bar in all graphical frames (Tab Bar mode)." |
| 89 | :global t | 110 | :global t |
| @@ -118,10 +139,27 @@ | |||
| 118 | :ascent center)) | 139 | :ascent center)) |
| 119 | tab-bar-close-button)) | 140 | tab-bar-close-button)) |
| 120 | 141 | ||
| 121 | (when tab-bar-mode | 142 | (if tab-bar-mode |
| 122 | (global-set-key [(control shift iso-lefttab)] 'tab-previous) | 143 | (progn |
| 123 | (global-set-key [(control shift tab)] 'tab-previous) | 144 | (when tab-bar-select-tab-modifiers |
| 124 | (global-set-key [(control tab)] 'tab-next))) | 145 | (dotimes (i 9) |
| 146 | (global-set-key (vector (append tab-bar-select-tab-modifiers | ||
| 147 | (list (+ i 1 ?0)))) | ||
| 148 | 'tab-bar-select-tab))) | ||
| 149 | ;; Don't override user customized key bindings | ||
| 150 | (unless (global-key-binding [(control tab)]) | ||
| 151 | (global-set-key [(control tab)] 'tab-next)) | ||
| 152 | (unless (global-key-binding [(control shift tab)]) | ||
| 153 | (global-set-key [(control shift tab)] 'tab-previous)) | ||
| 154 | (unless (global-key-binding [(control shift iso-lefttab)]) | ||
| 155 | (global-set-key [(control shift iso-lefttab)] 'tab-previous))) | ||
| 156 | ;; Unset only keys bound by tab-bar | ||
| 157 | (when (eq (global-key-binding [(control tab)]) 'tab-next) | ||
| 158 | (global-unset-key [(control tab)])) | ||
| 159 | (when (eq (global-key-binding [(control shift tab)]) 'tab-previous) | ||
| 160 | (global-unset-key [(control shift tab)])) | ||
| 161 | (when (eq (global-key-binding [(control shift iso-lefttab)]) 'tab-previous) | ||
| 162 | (global-unset-key [(control shift iso-lefttab)])))) | ||
| 125 | 163 | ||
| 126 | (defun tab-bar-handle-mouse (event) | 164 | (defun tab-bar-handle-mouse (event) |
| 127 | "Text-mode emulation of switching tabs on the tab bar. | 165 | "Text-mode emulation of switching tabs on the tab bar. |