[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2601aa9 1/4: * lisp/tab-bar.el (tab-bar--undefine-keys): New func
From: |
Juri Linkov |
Subject: |
master 2601aa9 1/4: * lisp/tab-bar.el (tab-bar--undefine-keys): New function from tab-bar-mode. |
Date: |
Mon, 22 Feb 2021 12:13:33 -0500 (EST) |
branch: master
commit 2601aa9105d935441ed25370feeeae3e717cc791
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/tab-bar.el (tab-bar--undefine-keys): New function from tab-bar-mode.
---
lisp/tab-bar.el | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index dba79fb..8326104 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -113,6 +113,15 @@ Possible modifier keys are `control', `meta', `shift',
`hyper', `super' and
(unless (global-key-binding [(control shift iso-lefttab)])
(global-set-key [(control shift iso-lefttab)] 'tab-previous)))
+(defun tab-bar--undefine-keys ()
+ "Uninstall key bindings previously bound by `tab-bar--define-keys'."
+ (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--load-buttons ()
"Load the icons for the tab buttons."
(when (and tab-bar-new-button
@@ -181,13 +190,7 @@ update."
(tab-bar--load-buttons))
(if tab-bar-mode
(tab-bar--define-keys)
- ;; 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)]))))
+ (tab-bar--undefine-keys)))
(defun tab-bar-handle-mouse (event)
"Text-mode emulation of switching tabs on the tab bar.