* lisp/tab-bar.el: Improve tab-bar-show (bug#45556)

* lisp/tab-bar.el (tab-bar-show): Change :set lambda to update all frames.
Improve docstring.
This commit is contained in:
Juri Linkov 2021-01-07 20:08:44 +02:00
parent c0ca935917
commit cd56406b62
2 changed files with 22 additions and 9 deletions

View file

@ -412,8 +412,8 @@ value of 'tab-bar-show'.
---
*** New command 'toggle-frame-tab-bar'.
It can be used to enable/disable the tab bar individually
on each frame independently from the state of `tab-bar-mode'.
It can be used to enable/disable the tab bar individually on each frame
independently from the value of 'tab-bar-mode' and 'tab-bar-show'.
---
*** New user option 'tab-bar-tab-name-format-function'.

View file

@ -187,9 +187,9 @@ on a console which has no window system but does have a mouse."
;; Clicking anywhere outside existing tabs will add a new tab
(tab-bar-new-tab)))))
;; Used in the Show/Hide menu, to have the toggle reflect the current frame.
(defun toggle-tab-bar-mode-from-frame (&optional arg)
"Toggle tab bar on or off, based on the status of the current frame.
Used in the Show/Hide menu, to have the toggle reflect the current frame.
See `tab-bar-mode' for more information."
(interactive (list (or current-prefix-arg 'toggle)))
(if (eq arg 'toggle)
@ -236,18 +236,31 @@ If the value is `1', then hide the tab bar when it has only one tab,
and show it again once more tabs are created.
If nil, always keep the tab bar hidden. In this case it's still
possible to use persistent named window configurations by relying on
keyboard commands `tab-new', `tab-close', `tab-next', `tab-switcher', etc."
keyboard commands `tab-new', `tab-close', `tab-next', `tab-switcher', etc.
Setting this variable directly does not take effect; please customize
it (see the info node `Easy Customization'), then it will automatically
update the tab bar on all frames according to the new value.
To enable or disable the tab bar individually on each frame,
you can use the command `toggle-frame-tab-bar'."
:type '(choice (const :tag "Always" t)
(const :tag "When more than one tab" 1)
(const :tag "Never" nil))
:initialize 'custom-initialize-default
:set (lambda (sym val)
(set-default sym val)
(tab-bar-mode
(if (or (eq val t)
(and (natnump val)
(> (length (funcall tab-bar-tabs-function)) val)))
1 -1)))
;; Preload button images
(tab-bar-mode 1)
;; Then handle each frame individually
(dolist (frame (frame-list))
(set-frame-parameter
frame 'tab-bar-lines
(if (or (eq val t)
(and (natnump val)
(> (length (funcall tab-bar-tabs-function frame))
val)))
1 0))))
:group 'tab-bar
:version "27.1")