Subject: Re: master cd8319677d8: * lisp/tab-bar.el: Ignore daemon's initial frame (bug#78896).

From: Juri Linkov <[email-masked]>
Date: Sun, 29 Jun 2025 09:58:08 +0300

[Moving back to bug#78896 for continuity]

>>>     * lisp/tab-bar.el: Ignore daemon's initial frame (bug#78896).
>>>     (tab-bar--update-tab-bar-lines): Don't set the frame parameter
>>>     'tab-bar-lines' in daemon's initial frame because it messes up the
>>>     frames when 'format-mode-line' called from 'tab-bar-format-global'
>>>     on daemon's initial frame forces focus switch to daemon's initial
>>>     frame.  Also don't set 'default-frame-alist' in daemon mode because
>>>     'frame-notice-user-settings' copies the frame parameter 'tab-bar-lines'
>>>     from 'default-frame-alist' to daemon's initial frame.  Here updating
>>>     'default-frame-alist' is not much needed anyway since the frame
>>>     parameter 'tab-bar-lines' for new frames is set in 'make_terminal_frame'
>>>     and 'x-create-frame'.  'default-frame-alist' might be need only
>>>     to handle non-default 'tab-bar-show', but this can be handled by
>>>     'toggle-frame-tab-bar' called from 'server-after-make-frame-hook'.
>>>     (toggle-frame-tab-bar): Document a useful case of calling it
>>>     from 'server-after-make-frame-hook'.
>>
>> This would seem to have broken (setopt tab-bar-show 1).
>> In my Emacs the tab bar is now always shown.
>
> The change to not update default-frame-alist, when (daemonp), is the
> problem.  According to your commit message "this can be handled by
> 'toggle-frame-tab-bar' called from 'server-after-make-frame-hook'".
> But clearly it is not being handled.  It seems like a regression that I
> would now have to add something to server-after-make-frame-hook to make
> my tab-bar-show customisation work.

Sorry, indeed not handled in 'toggle-frame-tab-bar'.  And not sure
if it should handle 'tab-bar-show' at all.  So need to find a solution
that doesn't require using 'toggle-frame-tab-bar'.  The most reliable way
is to update 'default-frame-alist' even when (daemonp).  The problem is
that it requires ad-hoc changes in 'frame-notice-user-settings'
that I tried to avoid.

The docstring of 'default-frame-alist' says:

  Setting this variable does not affect existing frames, only new ones.

But in fact 'frame-notice-user-settings' affects the existing
daemon's initial frame.  We need to find a fix that ignores it
in 'frame-notice-user-settings'.