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

From: Juri Linkov <[email-masked]>
Date: Sat, 13 Feb 2021 20:23:20 +0200

Hey Bastian,

Thank you for working on this patch.  Please prepare the ChangeLog
commit message, so your patch could be pushed to master.  Then it would be
easier to reason about further changes and base them on the pushed version.

> @@ -89,8 +89,9 @@ tab-bar-select-tab-modifiers
>   :set (lambda (sym val)
>          (set-default sym val)
>          ;; Reenable the tab-bar with new keybindings
> -         (tab-bar-mode -1)
> -         (tab-bar-mode 1))
> +         (when tab-bar-mode
> +           (tab-bar-mode -1)
> +           (tab-bar-mode 1)))
>   :group 'tab-bar
>   :version "27.1")
>
> This seems to fix the issue. I can't say I fully understand why
> though. It must have something to do with running
> tab-bar--update-tab-bar-lines in early initialization? We could also
> wrap the call to tab-bar--update-tab-bar-lines.

The problem is that currently the function tab-bar-mode contains:

  (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)]))
    ...

If the global-unset-key part would be refactored into a separate
function, then tab-bar-select-tab-modifiers could call two
functions sequentially: a new function that undefines old keys,
then the existing separate function tab-bar--define-keys
that will define keys with customized modifier.