Subject: bug#71939: tab-bar `tab-bar-show-inactive-group-tabs' feature request

From: Ship Mints <[email-masked]>
Date: Thu, 4 Jul 2024 09:41:42 -0400

I'd like to propose that `tab-bar' allow optionally showing tabs for
inactive groups when `tab-bar-format-tabs-groups' is in force rather than
the always-on policy of collapsing inactive groups.

The proposed custom variable `tab-bar-show-inactive-group-tabs' is backward
compatible for existing users and has no visible changes for people who do
not set it to t. I will occasionally set the value locally to alter frame
by frame behavior. I've also used a key binding to toggle the behavior to
nice effect.

I've been using these changes (via advice :override) under Emacs 29.3.

Thanks, again, for this package.

The proposed implementation is below with new/changed code in bold.

*(defcustom tab-bar-show-inactive-group-tabs nil  "Show tabs which are in
inactive groups."  :type 'boolean  :initialize 'custom-initialize-default
:set (lambda (sym val)         (set-default sym val)
 (force-mode-line-update))  :group 'tab-bar  :version "30.x")*
(defun tab-bar-format-tabs-groups ()
  "Produce tabs for the tab bar grouped according to their groups."
  (let* ((tabs (funcall tab-bar-tabs-function))
         (current-group (funcall tab-bar-tab-group-function
                                 (tab-bar--current-tab-find tabs)))
         (previous-group nil)
         (i 0))
    (mapcan
     (lambda (tab)
       (let ((tab-group (funcall tab-bar-tab-group-function tab)))
         (setq i (1+ i))
         (prog1 (cond
                 ;; Show current group tabs and ungrouped tabs
                 ((or (equal tab-group current-group) (not tab-group))
                  (append
                   ;; Prepend current group name before first tab
                   (when (and (not (equal previous-group tab-group))
tab-group)
                     (tab-bar--format-tab-group tab i t))
                   ;; Override default tab faces to use group faces
                   (let ((tab-bar-tab-face-function
tab-bar-tab-group-face-function))
                     (tab-bar--format-tab tab i))))
                 ;; Show first tab of other groups with a group name
                 ((not (equal previous-group tab-group))

*                  (append                   (tab-bar--format-tab-group tab
i)                   (when tab-bar-show-inactive-group-tabs
     (let ((tab-bar-tab-face-function tab-bar-tab-group-face-function))
                   (tab-bar--format-tab tab i)))))*                 ;; Hide
other group tabs

*                 (t (when tab-bar-show-inactive-group-tabs
      (let ((tab-bar-tab-face-function tab-bar-tab-group-face-function))
                    (tab-bar--format-tab tab i)))))*           (setq
previous-group tab-group))))
     tabs)))

-Stephane