ui/workspaces: associate buffers on buffer switch

We stop relying on the built-in mechanism for auto-registering a buffer
to the current workspace, because it misses many buffers (e.g. when we
switch buffers with SPC b b). Instead, we add buffers when they are
interactively switched to.
This commit is contained in:
Henrik Lissner 2019-06-21 14:50:59 +02:00
parent 0290b687a5
commit 7a4bce3f9a
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -91,12 +91,16 @@ Uses `+workspaces-main' to determine the name of the main workspace."
(advice-add #'persp-asave-on-exit :around #'+workspaces*autosave-real-buffers)
;; Ensure buffers we've opened/switched to are auto-added to the current
;; perspective
(setq persp-add-buffer-on-find-file t
persp-add-buffer-on-after-change-major-mode t)
;; Don't rely on the built-in mechanism for auto-registering a buffer to the
;; current workspace. Instead, we add buffers when they are switched to.
(setq persp-add-buffer-on-find-file nil
persp-add-buffer-on-after-change-major-mode nil)
(add-hook 'persp-add-buffer-on-after-change-major-mode-filter-functions #'doom-unreal-buffer-p)
(defun +workspaces|add-current-buffer ()
(persp-add-buffer (current-buffer) (get-current-persp)))
(add-hook 'doom-switch-buffer-hook #'+workspaces|add-current-buffer)
(defun +workspaces|init-persp-mode ()
(cond (persp-mode
;; `persp-kill-buffer-query-function' must be last