diff --git a/modules/ui/workspaces/autoload/workspaces.el b/modules/ui/workspaces/autoload/workspaces.el index fe1a7429d..2c306d1d1 100644 --- a/modules/ui/workspaces/autoload/workspaces.el +++ b/modules/ui/workspaces/autoload/workspaces.el @@ -580,6 +580,14 @@ This be hooked to `projectile-after-switch-project-hook'." 'tab-bar-tabs (tab-bar-tabs)) (set-persp-parameter 'tab-bar-closed-tabs tab-bar-closed-tabs))) +;;;###autoload +(defun +workspaces-save-tab-bar-data-to-file-h (&rest _) + "Save the current workspace's tab bar data to file." + (when (get-current-persp) + ;; HACK: Remove fields (for window-configuration) that cannot be serialized. + (set-persp-parameter 'tab-bar-tabs + (frameset-filter-tabs (tab-bar-tabs) nil nil t)))) + ;;;###autoload (defun +workspaces-load-tab-bar-data-h (_) "Restores the tab bar data of the workspace we have just switched to." @@ -587,6 +595,12 @@ This be hooked to `projectile-after-switch-project-hook'." (setq tab-bar-closed-tabs (persp-parameter 'tab-bar-closed-tabs)) (tab-bar--update-tab-bar-lines t)) +;;;###autoload +(defun +workspaces-load-tab-bar-data-from-file-h (&rest _) + "Restores the tab bar data from file." + (tab-bar-tabs-set (persp-parameter 'tab-bar-tabs)) + (tab-bar--update-tab-bar-lines t)) + ;; ;;; Advice diff --git a/modules/ui/workspaces/config.el b/modules/ui/workspaces/config.el index 8a2393878..0fb223bf2 100644 --- a/modules/ui/workspaces/config.el +++ b/modules/ui/workspaces/config.el @@ -282,4 +282,7 @@ stored in `persp-save-dir'.") (add-hook! 'tab-bar-mode-hook (defun +workspaces-set-up-tab-bar-integration-h () (add-hook 'persp-before-deactivate-functions #'+workspaces-save-tab-bar-data-h) - (add-hook 'persp-activated-functions #'+workspaces-load-tab-bar-data-h)))) + (add-hook 'persp-activated-functions #'+workspaces-load-tab-bar-data-h) + ;; Load and save configurations for tab-bar. + (add-hook 'persp-before-save-state-to-file-functions #'+workspaces-save-tab-bar-data-to-file-h) + (+workspaces-load-tab-bar-data-from-file-h))))