From: James N. V. Cash <james.nvc@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: , 42052@debbugs.gnu.org
Subject: bug#42052: 28.0.50; tab-bar-mode should be frame-local
Date: Thu, 09 Jul 2020 13:06:41 -0400 [thread overview]
Message-ID: <874kqgpqhq.fsf@gmail.com> (raw)
In-Reply-To: <87zh8liggc.fsf@mail.linkov.net>
Juri Linkov <juri@linkov.net> writes:
> Thanks, pushed to master. If you have more ideas for further development,
> this report could be left open to address these issues too.
I've attached another patch that makes the key bindings & xpm icons get
loaded when tab-bar-show is 1 as well. It doesn't un-load the
keybindings in the way that globalling toggling tab-bar-mode off, but I
don't really see a sensible way of doing that frame-locally.
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -95,23 +95,27 @@ tab-bar-select-tab-modifiers
:version "27.1")
\f
-(define-minor-mode tab-bar-mode
- "Toggle the tab bar in all graphical frames (Tab Bar mode)."
- :global t
- ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
- :variable tab-bar-mode
- (let ((val (if tab-bar-mode 1 0)))
- (dolist (frame (frame-list))
- (set-frame-parameter frame 'tab-bar-lines val))
- ;; If the user has given `default-frame-alist' a `tab-bar-lines'
- ;; parameter, replace it.
- (if (assq 'tab-bar-lines default-frame-alist)
- (setq default-frame-alist
- (cons (cons 'tab-bar-lines val)
- (assq-delete-all 'tab-bar-lines
- default-frame-alist)))))
-
- (when (and tab-bar-mode tab-bar-new-button
+(defun tab-bar--define-keys ()
+ "Install key bindings for switching between tabs if the user has
+configured them."
+ (when tab-bar-select-tab-modifiers
+ (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0)))
+ 'tab-bar-switch-to-recent-tab)
+ (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)))
+
+(defun tab-bar--load-buttons ()
+ "Load the icons for the tab buttons."
+ (when (and tab-bar-new-button
(not (get-text-property 0 'display tab-bar-new-button)))
;; This file is pre-loaded so only here we can use the right data-directory:
(add-text-properties 0 (length tab-bar-new-button)
@@ -121,7 +125,7 @@ tab-bar-mode
:ascent center))
tab-bar-new-button))
- (when (and tab-bar-mode tab-bar-close-button
+ (when (and tab-bar-close-button
(not (get-text-property 0 'display tab-bar-close-button)))
;; This file is pre-loaded so only here we can use the right data-directory:
(add-text-properties 0 (length tab-bar-close-button)
@@ -129,24 +133,27 @@ tab-bar-mode
:file "tabs/close.xpm"
:margin (2 . 0)
:ascent center))
- tab-bar-close-button))
+ tab-bar-close-button)))
+(define-minor-mode tab-bar-mode
+ "Toggle the tab bar in all graphical frames (Tab Bar mode)."
+ :global t
+ ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
+ :variable tab-bar-mode
+ (let ((val (if tab-bar-mode 1 0)))
+ (dolist (frame (frame-list))
+ (set-frame-parameter frame 'tab-bar-lines val))
+ ;; If the user has given `default-frame-alist' a `tab-bar-lines'
+ ;; parameter, replace it.
+ (if (assq 'tab-bar-lines default-frame-alist)
+ (setq default-frame-alist
+ (cons (cons 'tab-bar-lines val)
+ (assq-delete-all 'tab-bar-lines
+ default-frame-alist)))))
+ (when tab-bar-mode
+ (tab-bar--load-buttons))
(if tab-bar-mode
- (progn
- (when tab-bar-select-tab-modifiers
- (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0)))
- 'tab-bar-switch-to-recent-tab)
- (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)))
+ (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)]))
@@ -806,7 +813,10 @@ tab-bar-new-tab-to
((and (natnump tab-bar-show)
(> (length (funcall tab-bar-tabs-function)) tab-bar-show)
(zerop (frame-parameter nil 'tab-bar-lines)))
- (set-frame-parameter nil 'tab-bar-lines 1)))
+ (progn
+ (tab-bar--load-buttons)
+ (tab-bar--define-keys)
+ (set-frame-parameter nil 'tab-bar-lines 1))))
(force-mode-line-update)
(unless tab-bar-mode
next prev parent reply other threads:[~2020-07-09 17:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 20:07 bug#42052: 28.0.50; tab-bar-mode should be frame-local James N. V. Cash
2020-06-27 23:40 ` Juri Linkov
2020-06-28 12:15 ` James N. V. Cash
2020-06-28 19:45 ` James N. V. Cash
2020-06-28 23:18 ` Juri Linkov
2020-06-29 0:26 ` James N. V. Cash
2020-06-29 0:35 ` James N. V. Cash
2020-06-29 23:45 ` Juri Linkov
2020-07-09 17:06 ` James N. V. Cash [this message]
2020-07-09 23:49 ` Juri Linkov
2020-07-11 14:45 ` James N. V. Cash
2020-07-12 0:01 ` Juri Linkov
2020-07-11 15:17 ` Stefan Monnier
2020-07-12 0:04 ` Juri Linkov
2020-07-12 16:38 ` Stefan Monnier
2020-10-13 3:07 ` Lars Ingebrigtsen
2021-01-05 18:36 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874kqgpqhq.fsf@gmail.com \
--to=james.nvc@gmail.com \
--cc=42052@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.