[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 56a7c60: * lisp/tab-bar.el (tab-bar-select-tab-modi
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] master 56a7c60: * lisp/tab-bar.el (tab-bar-select-tab-modifiers): New defcustom. |
Date: |
Tue, 15 Oct 2019 16:38:24 -0400 (EDT) |
branch: master
commit 56a7c60872272eef2dbd4fd071d0af0441f374d8
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>
* 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.
---
lisp/tab-bar.el | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 13829ef..f9d4de4 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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 56a7c60: * lisp/tab-bar.el (tab-bar-select-tab-modifiers): New defcustom.,
Juri Linkov <=