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

From: Juri Linkov <[email-masked]>
Date: Fri, 05 Feb 2021 10:54:03 +0200

> I noticed that with the latest master branch setting tab-bar-show
> to "1" does not work work for new frames. On those the tabs are shown
> even if tab-bar-show is set to 1.

Thanks for finding a case that is still unhandled.

> I suppose a hook is needed which applies the correct setting
> to the new frame?

Generally, Emacs core packages should avoid adding own code
to hooks, because hooks are intended mostly for users, such as
for example, configuring to enable tab-bar selectively:

  (add-hook 'after-make-frame-functions 'toggle-frame-tab-bar)

Fortunately, frames provide a better way to set their default values
with default-frame-alist, that tab-bar-mode already modifies.
So doing something similar fixes the problem:

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 6720d82b47..0cf74a7833 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -252,6 +252,12 @@ tab-bar-show
          (set-default sym val)
          ;; Preload button images
          (tab-bar-mode 1)
+         ;; New frames have only one tab, so hide it by default
+         (when (eq val 1)
+           (setq default-frame-alist
+              (cons (cons 'tab-bar-lines 0)
+                    (assq-delete-all 'tab-bar-lines
+                                     default-frame-alist))))
          ;; Then handle each frame individually
          (dolist (frame (frame-list))
            (set-frame-parameter