Skip to content

Commit cc3a31a

Browse files
committed
feat(workspace): replace project-tab-groups with one-tab-per-project
1 parent b8fc926 commit cc3a31a

File tree

1 file changed

+3
-40
lines changed

1 file changed

+3
-40
lines changed

modules/me-workspaces.el

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,11 @@
1616
(use-package unique-dir-name
1717
:straight (:host github :repo "abougouffa/unique-dir-name"))
1818

19-
(use-package project-tab-groups
20-
:straight t
19+
(use-package one-tab-per-project
20+
:straight (:host github :repo "abougouffa/one-tab-per-project")
2121
:after project
2222
:init
23-
(setq project-tab-groups-tab-group-name-function #'+project-tab-groups-name-by-project-root)
24-
(project-tab-groups-mode 1)
25-
:config
26-
(defvar +project-tab-groups-unique-map (make-hash-table :test 'equal))
27-
(defun +project-tab-groups-name-by-project-root (dir)
28-
"Use the project root as group name starting from DIR."
29-
(with-temp-buffer
30-
(setq default-directory dir)
31-
(hack-dir-local-variables-non-file-buffer)
32-
(let ((root (or (when-let* ((proj (project-current)))
33-
(expand-file-name (project-root proj))) ;; Use the full path
34-
(expand-file-name dir))))
35-
root)))
36-
(defun +project-tab-groups--unique-rename-all ()
37-
(dolist (frame (frame-list))
38-
(dolist (tab (frame-parameter frame 'tabs))
39-
(when-let* ((group-path (alist-get 'group tab))
40-
(unique (gethash group-path +project-tab-groups-unique-map)))
41-
(setcdr (assoc 'name tab) (alist-get 'unique-name unique))
42-
(setcdr (assoc 'explicit-name tab) t)))))
43-
;; Rename the tab to the tab-group name (project name)
44-
(advice-add
45-
#'project-tab-groups--select-or-create-tab-group :after-while
46-
(satch-defun +project-tab-groups--name-tab-by-group:after-while-a (&rest _)
47-
(when-let ((group-path (alist-get 'group (tab-bar--current-tab))))
48-
(unique-dir-name-register group-path :map '+project-tab-groups-unique-map)
49-
(+project-tab-groups--unique-rename-all)) ; Rename all tabs accordingly
50-
t))
51-
;; Unregister the path on tab group closing and rename all tabs accordingly
52-
(advice-add
53-
#'project-tab-groups--project-kill-buffers-advice :around
54-
(satch-defun +project-tab-groups--remove-from-map:around-a (fn &rest args)
55-
(let ((path (alist-get 'group (tab-bar--current-tab))))
56-
(apply fn args)
57-
(unless (project-tab-groups--find-tab-by-group-name path) ; Removed?
58-
(unique-dir-name-unregister path :map '+project-tab-groups-unique-map)
59-
(+project-tab-groups--unique-rename-all))
60-
t))))
23+
(otpp-mode 1))
6124

6225
(use-package burly
6326
:straight t)

0 commit comments

Comments
 (0)