fix(workspaces): save current tab-bar tabs to file
This commit is contained in:
parent
f6616e8a06
commit
d12b0ebc80
2 changed files with 18 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue