bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#46299: 28.0.50; Value of tab-bar-show not respected in new frames.


From: Bastian Beranek
Subject: bug#46299: 28.0.50; Value of tab-bar-show not respected in new frames.
Date: Mon, 15 Feb 2021 11:09:39 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Juri Linkov <juri@linkov.net> writes:

> Thanks, now your patch is pushed to master.

Thanks!

>
> While using it, I noticed a new problem.
> There is this code in 'tab-switcher':
>
>     (let ((tab-bar-new-tab-choice t)
>           ;; Don't enable tab-bar-mode if it's disabled
>           (tab-bar-show nil))
>       (tab-bar-new-tab))
>
> Before your patch, I did nothing with the enabled tab-bar,
> but now it disables the tab-bar, and doesn't enable it again later,
> because tab-bar-show is let-bound to nil.
>

Could you please describe the desired behavior of tab-switcher in a few
more words? I can't see anything wrong with it if I try it out here,
although I can sort of see what you're getting at: While the
tab-swicher is active there should be no tab bar, and it should return
when it is finished?

What I see is that the tab-bar just stays on all the time, with a
temporary tab for the tab-switcher itself. I have tab-bar-show
customized to "1" here.

Side question: Why does tab-switcher need to create a tab for its
purpose? Doesn't it make more sense to use a regular buffer for that?

> A good solution would be to add a new choice value to tab-bar-show.
> Something like 'do-not-change-tab-bar-lines', but shorter.
> Then when let-bound, it should do nothing with the tab-bar-lines.

Wouldn't it make more sense to have a different variable for that?
Because tab-bar-show is a defcustom and we wouldn't want to expose this
special value to users, right?

>
> Also this is related to another problem:
> What if the user wants to manually enable the tab bar on one frame only
> without enabling tab-bar-mode?  Currently it's possible with
>
>   (add-hook 'after-make-frame-functions 'toggle-frame-tab-bar)
>
> But tab-bar--update-tab-bar-lines will disable it sooner or later.
> Customizing to the same value like 'do-not-change-tab-bar-lines'
> will solve this problem as well.

That's true. I can see how tab-bar--update-tab-bar-lines can interfere
with toggle-frame-tab-bar.

But I think we would need a frame dependent variable to fix this. We
can't use a global single variable, because toggle-frame-tab-bar is not
supposed to change the behavior of tabs on other frames. I have to think
about a good solution for a bit longer. Is attaching a new parameter to
frames similiar to this a possibility?

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 4e47ae2c10..cbda0c032b 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -161,7 +161,8 @@ tab-bar--update-tab-bar-lines
                          (t frames))))
     ;; Loop over all frames and update default-frame-alist
     (dolist (frame frame-lst)
-      (set-frame-parameter frame 'tab-bar-lines 
(tab-bar--tab-bar-lines-for-frame frame))))
+      (unless (frame-parameter frame 'tab-bar-lines-do-not-change)
+        (set-frame-parameter frame 'tab-bar-lines 
(tab-bar--tab-bar-lines-for-frame frame)))))
   (when (eq frames t)
     (setq default-frame-alist
           (cons (cons 'tab-bar-lines (if (and tab-bar-mode (eq tab-bar-show 
t)) 1 0))
@@ -233,7 +234,8 @@ toggle-frame-tab-bar
   (add-hook 'after-make-frame-functions 'toggle-frame-tab-bar)"
   (interactive)
   (set-frame-parameter frame 'tab-bar-lines
-                       (if (> (frame-parameter frame 'tab-bar-lines) 0) 0 1)))
+                       (if (> (frame-parameter frame 'tab-bar-lines) 0) 0 1))
+  (set-frame-parameter frame 'tab-bar-lines-do-not-change t))
 
 (defvar tab-bar-map (make-sparse-keymap)
   "Keymap for the tab bar.

Note that I'm not yet suggesting that we do it exactly as the above,
this has other issues - toggling twice does leave the do-not-change
frame parameter in place for example, so it's not the same as doing
nothing.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]