diff options
author | Juri Linkov <juri@linkov.net> | 2019-10-15 23:38:18 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2019-10-15 23:38:18 +0300 |
commit | 56a7c60872272eef2dbd4fd071d0af0441f374d8 (patch) | |
tree | 3e1a4530d863d484bcb205f5092e82390c3d8253 /lisp | |
parent | ffa90546980c71fc0c2355005b382f07405aeeec (diff) | |
download | emacs-56a7c60872272eef2dbd4fd071d0af0441f374d8.tar.gz |
* 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.
Diffstat (limited to 'lisp')
-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 @@ :group 'tab-bar-faces) +(defcustom tab-bar-select-tab-modifiers '() + "List of key modifiers for selecting a tab by its index digit. +Possible modifiers are `control', `meta', `shift', `hyper', `super' and +`alt'." + :type '(set :tag "Tab selection key modifiers" + (const control) + (const meta) + (const shift) + (const hyper) + (const super) + (const alt)) + :initialize 'custom-initialize-default + :set (lambda (sym val) + (set-default sym val) + ;; Reenable the tab-bar with new keybindings + (tab-bar-mode -1) + (tab-bar-mode 1)) + :group 'tab-bar + :version "27.1") + + (define-minor-mode tab-bar-mode "Toggle the tab bar in all graphical frames (Tab Bar mode)." :global t @@ -118,10 +139,27 @@ :ascent center)) tab-bar-close-button)) - (when tab-bar-mode - (global-set-key [(control shift iso-lefttab)] 'tab-previous) - (global-set-key [(control shift tab)] 'tab-previous) - (global-set-key [(control tab)] 'tab-next))) + (if tab-bar-mode + (progn + (when tab-bar-select-tab-modifiers + (dotimes (i 9) + (global-set-key (vector (append tab-bar-select-tab-modifiers + (list (+ i 1 ?0)))) + 'tab-bar-select-tab))) + ;; Don't override user customized key bindings + (unless (global-key-binding [(control tab)]) + (global-set-key [(control tab)] 'tab-next)) + (unless (global-key-binding [(control shift tab)]) + (global-set-key [(control shift tab)] 'tab-previous)) + (unless (global-key-binding [(control shift iso-lefttab)]) + (global-set-key [(control shift iso-lefttab)] 'tab-previous))) + ;; Unset only keys bound by tab-bar + (when (eq (global-key-binding [(control tab)]) 'tab-next) + (global-unset-key [(control tab)])) + (when (eq (global-key-binding [(control shift tab)]) 'tab-previous) + (global-unset-key [(control shift tab)])) + (when (eq (global-key-binding [(control shift iso-lefttab)]) 'tab-previous) + (global-unset-key [(control shift iso-lefttab)])))) (defun tab-bar-handle-mouse (event) "Text-mode emulation of switching tabs on the tab bar. |