From 7a4bce3f9abc7a130610a0d7919b734f8e812617 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 21 Jun 2019 14:50:59 +0200 Subject: [PATCH] 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. --- modules/ui/workspaces/config.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/ui/workspaces/config.el b/modules/ui/workspaces/config.el index b45c7a662..75cb4fa4a 100644 --- a/modules/ui/workspaces/config.el +++ b/modules/ui/workspaces/config.el @@ -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