Skip to content

fritzgrabo/tab-bar-groups

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ Emacs 28 adds a similar tab grouping facility, which renders this package mostly obsolete.

tab-bar-groups.el

Tab groups for the tab bar.

This package provides the means to work with and to customize the appearance of named groups of tabs in Emacs 27 and higher (see below for screenshots and commands).

Installation

If you use MELPA, an easy way to install this package is via package-install. Alternatively, download tab-bar-groups.el, put it in your load-path and require it. Finally, use (tab-bar-groups-activate) or M-x tab-bar-groups-activate to turn on the provided features.

If you use both MELPA and use-package, you can use this, too:

(use-package tab-bar-groups
  :ensure
  :config
  (tab-bar-groups-activate))

Screenshots

Emacs 27, or Emacs 28 without tab-bar-format-tabs-groups in tab-bar-format: Showing a bunch of tabs in three groups Emacs, News, tbg, with init.el being the current tab and Emacs being the current group. Note that all tabs of all groups are visible. Also note that the *scratch* tab (unstyled) is not part of a group.

screenshots/tab-bar-groups-emacs-27.png

Emacs 28 with tab-bar-format-tabs-groups in tab-bar-format: Showing the same groups and tabs as above. Note that tab-bar-format-tabs-groups hides tabs in inactive groups.

screenshots/tab-bar-groups-emacs-28.png

The faces applied to the current/other tabs and groups are fully customizable.

Commands

Table of available commands and their description.

CommandDescription
tab-bar-groups-new-tabCreate a new tab in the current group.¹
tab-bar-groups-duplicate-tabDuplicate current tab in its group.¹
tab-bar-groups-change-tab-groupChange the group of the current tab (query name w/ completion).¹
tab-bar-groups-rename-groupRename the group that the current tab belongs to (query name w/ completion).
tab-bar-groups-eject-tabEject the current tab from its group.
tab-bar-groups-close-group-tabsClose all tabs of the current group.¹
tab-bar-groups-regroup-tabsRe-order tabs so that all tabs of each group are next to each other.

(1) Required in Emacs 27 only. Emacs 28 provides commands with similar functionality natively.

Recommended Keybindings

Note that this package doesn’t bind any keys by itself.

In my local configuration, I added bindings for the above commands to the pre-existing keymap for tab-related commands (C-x t):

(use-package tab-bar-groups
  :ensure
  :demand
  :config
  (tab-bar-groups-activate)
  :bind (:map tab-prefix-map
              ("g0" . tab-bar-groups-close-group-tabs)
              ("g2" . tab-bar-groups-new-tab)
              ("ga" . tab-bar-groups-change-tab-group)
              ("gg" . tab-bar-groups-regroup-tabs)
              ("gd" . tab-bar-groups-duplicate-tab)
              ("gk" . tab-bar-groups-eject-tab)
              ("gr" . tab-bar-groups-rename-group)))

Building on top of this package

Extensibility and customizability

This package was built with extensibility in mind. In fact, it’s an extraction of a bigger suite of features that I use locally to enable a “one tab group per project” workflow.

If you want to change how new tabs pick their appearance/color, how grouped tabs render in the tab bar or what happens after a tab’s group assignment has changed, have a look at the various extension points of this package:

  • tab-bar-groups-appearances
  • tab-bar-groups-colors
  • tab-bar-groups-pick-group-appearance-function
  • tab-bar-groups-style-tab-name-functions
  • tab-bar-groups-tab-post-change-group-functions (an abnormal hook)

For example, to keep all tabs of each group next to each other at all times:

(add-hook 'tab-bar-groups-tab-post-change-group-functions #'tab-bar-groups-regroup-tabs)

Helper functions to roll your own tools

This package provides a range of helper functions that you can use to find out about existing groups, their names, etc.

Integration with tab-bar-echo-area

This package provides an integration with the tab-bar-echo-area package.

Tabs and tab groups are rendered like in the tab bar (that is, tab-bar-format settings apply here as well).

screenshots/tab-bar-groups-tab-bar-echo-area.png

After both packages have been loaded, use (tab-bar-groups-activate-for-tab-bar-echo-area) to enable it.

(with-eval-after-load 'tab-bar-echo-area
  (tab-bar-groups-activate-for-tab-bar-echo-area))

Integration with project-mode-line-tag

This package provides an integration with the project-mode-line-tag package. It applies the current tab bar group’s color to the project tag in the mode line.

After both packages have been loaded, use (tab-bar-groups-activate-for-project-mode-line-tag) to enable it.

(with-eval-after-load 'project-mode-line-tag
  (tab-bar-groups-activate-for-project-mode-line-tag))

Related / Supplementary Packages

  • project-tab-groups to enhance the Emacs built-in project.el library to support keeping projects isolated in named tab groups (requires Emacs 28).

About

Emacs: Tab groups for the tab bar (rendered obsolete in Emacs 28)

Resources

License

Stars

Watchers

Forks