Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tabs created project-switch-project gets the wrong name #2

Closed
suleymanboyar opened this issue May 17, 2023 · 2 comments
Closed

Comments

@suleymanboyar
Copy link

suleymanboyar commented May 17, 2023

In the README file it says that project-tab-groups-tab-group-name-function's default setting will try to look for two dir-local variables, if they are not found it will fall back to the project’s directory name.

In my case opening a project, the new tab bar gets the buffer's name and changing the buffer changes the name of the tab bar too. Am I misunderstanding how project-tab-groups-tab-group-name-function is supposed to work? The way I understood is if I open a project with path ~/myprojects/foobar, the tab bar should be renamed to foobar.

Relative parts from my config

(defun my/project-magit-status ()
  "Open `magit' within project root."
  (interactive)
  (magit-status
   (project-root
    (project-current))))

(use-package project
  :bind (:map project-prefix-map
              ("k" . my/close-project-tab)
              ("F" . consult-ripgrep))
  :custom
  (project-vc-merge-submodules t)
  (project-vc-extra-root-markers '(".project"))
  (project-switch-commands
   '((project-find-file "Find file")
     (project-find-regexp "Find regexp")
     (project-find-dir "Find directory")
     (project-dired "Root dired")
     (project-vc-dir "VC-Dir")
     (project-shell "Shell")
     (project-eshell "Eshell")
     (my/project-magit-status "Magit")
     (consult-ripgrep "Ripgrep"))))

;;; Workspaces (tabspace-mode)
(tab-bar-mode +1)

(use-package project-tab-groups
  :straight t
  :init
  (project-tab-groups-mode 1))
@fritzgrabo
Copy link
Owner

Hey @suleymanboyar, thanks for reaching out, and thanks for your question. Happy to hear that you're giving this package a try!

Please note that the project-tab-groups-tab-group-name-function function you mentioned is responsible for generating the name of the tab group that this package creates for you when you open a project. It does not affect the name of the individual tabs within that group.

Looking at your config, it seems like your tab bar doesn't display tab groups yet.

To enable that (or more correctly: to see the names of the existing tab groups in your tab bar), you'll need to adjust Emacs' tab-bar-format variable.

The default value is this:

(tab-bar-format-history tab-bar-format-tabs tab-bar-separator tab-bar-format-add-tab)

... and you'll want this:

;; Switch tab-bar-format-tabs to tab-bar-format-tabs-groups
(setq tab-bar-format '(tab-bar-format-history tab-bar-format-tabs-groups tab-bar-separator tab-bar-format-add-tab))

Please consult the documentation of that variable via C-h v tab-bar-format for more details.

Oh, and please also note that tab bar groups are a feature of Emacs 28.1 -- are you on that version (or a higher one) already?

With all of ^^ in place, you should get a new tab group titled foobar when you open ~/myprojects/foobar.

Hope this works -- please let me know if it doesn't!

@suleymanboyar
Copy link
Author

I seem to have fully understood how this package extended on tab-bar-mode.

Thank you for creating this project and maintaining it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants