Subject: Frame-local tab-bar for numeric value of tab-bar-show (bug#42052)

* lisp/tab-bar.el (tab-bar-new-tab-to): Set frame parameter
tab-bar-lines to 1 when tab-bar-show is the same as number of tabs.
(tab-bar-close-tab, tab-bar-close-other-tabs): Set frame parameter
tab-bar-lines to 0 when tab-bar-show is the same as number of tabs.

Copyright-paperwork-exempt: yes
This commit is contained in:
James N. V. Cash 2020-06-30 02:45:15 +03:00 committed by Juri Linkov
parent 519e64f981
commit bc8089a3fa
2 changed files with 21 additions and 12 deletions

View file

@ -127,6 +127,10 @@ setting the variable 'auto-save-visited-mode' buffer-locally to nil.
*** The key prefix 'C-x t t' displays next command buffer in a new tab.
*** The tab bar is frame-local when 'tab-bar-show' is a number.
Show/hide the tab bar independently for each frame, according to the
value of 'tab-bar-show'.
** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and
'previous-error-no-select' bound to 'p'.

View file

@ -799,11 +799,14 @@ After the tab is created, the hooks in
(run-hook-with-args 'tab-bar-tab-post-open-functions
(nth to-index tabs)))
(when (and (not tab-bar-mode)
(or (eq tab-bar-show t)
(and (natnump tab-bar-show)
(> (length tabs) tab-bar-show))))
(cond
(tab-bar-mode)
((eq tab-bar-show t)
(tab-bar-mode 1))
((and (natnump tab-bar-show)
(> (length (funcall tab-bar-tabs-function)) tab-bar-show)
(zerop (frame-parameter nil 'tab-bar-lines)))
(set-frame-parameter nil 'tab-bar-lines 1)))
(force-mode-line-update)
(unless tab-bar-mode
@ -936,10 +939,11 @@ for the last tab on a frame is determined by
tab-bar-closed-tabs)
(set-frame-parameter nil 'tabs (delq close-tab tabs)))
(when (and tab-bar-mode
(and (natnump tab-bar-show)
(<= (length tabs) tab-bar-show)))
(tab-bar-mode -1))
(when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
(natnump tab-bar-show)
(<= (length (funcall tab-bar-tabs-function))
tab-bar-show))
(set-frame-parameter nil 'tab-bar-lines 0))
(force-mode-line-update)
(unless tab-bar-mode
@ -975,10 +979,11 @@ for the last tab on a frame is determined by
(run-hook-with-args 'tab-bar-tab-pre-close-functions (nth index tabs) nil)))
(set-frame-parameter nil 'tabs (list (nth current-index tabs)))
(when (and tab-bar-mode
(and (natnump tab-bar-show)
(<= 1 tab-bar-show)))
(tab-bar-mode -1))
(when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
(natnump tab-bar-show)
(<= (length (funcall tab-bar-tabs-function))
tab-bar-show))
(set-frame-parameter nil 'tab-bar-lines 0))
(force-mode-line-update)
(unless tab-bar-mode