From bc8089a3fa11161428c51439fd3b26fd6583345d Mon Sep 17 00:00:00 2001 From: "James N. V. Cash" Date: Tue, 30 Jun 2020 02:45:15 +0300 Subject: [PATCH] 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 --- etc/NEWS | 4 ++++ lisp/tab-bar.el | 29 +++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index d58a61be21f..ddc0999c9e8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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'. diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 0a336e41658..04f4bca166c 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -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 -- 2.39.5