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

From: Juri Linkov <[email-masked]>
Date: Wed, 10 Feb 2021 20:24:49 +0200

> Hope this is satisfactory, if not please feel free to adjust as you wish.

Thanks, please see more comments:

> +(defun tab-bar--tab-bar-lines-for-frame (frame)
> +  (if (not tab-bar-mode)
> +      0
> +    (cond
> +     ((eq tab-bar-show t) 1)
> +     ((natnump tab-bar-show)
> +      (if (> (length (funcall tab-bar-tabs-function frame)) tab-bar-show) 1 0))
> +     (t 0))))

A small optimization:

  ((not tab-bar-mode) 0)

could be added as the first condition of the same 'cond'.

>    :set (lambda (sym val)
>           (set-default sym val)
>           ;; Preload button images
> +         ;; Note: tab-bar-mode updates tab-bar-lines as well.
> +         (tab-bar-mode 1))

Not sure whether the users would want to enable tab-bar-mode
unconditionally after customizing tab-bar-show.

Maybe when customized tab-bar-show to nil, only call
tab-bar--update-tab-bar-lines in all frames?
Or maybe simply to disable the tab bar with (tab-bar-mode 0)
when customized to nil?

> @@ -852,16 +867,15 @@ After the tab is created, the hooks in
> +    ;; Switch on tab-bar-mode, since a tab was created
> +    (when tab-bar-show
>        (tab-bar-mode 1))
> +
> +    ;; Recalculate tab-bar-lines and update frames
> +    (tab-bar--update-tab-bar-lines (selected-frame))
> +    (when tab-bar-mode
> +      (tab-bar--load-buttons)
> +      (tab-bar--define-keys))

Would you agree that here in tab-bar-new-tab-to, the first call of
tab-bar-mode should already do all these calls: tab-bar--update-tab-bar-lines,
tab-bar--load-buttons, tab-bar--define-keys?  So maybe it should be
sufficient just to leave these 2 lines here:

    (when tab-bar-show
       (tab-bar-mode 1))