Fix evil-alternate-buffer + persp-mode

Fixes an issue where evil-switch-to-windows-last-buffer would switch to
buffers outside the current workspace.
This commit is contained in:
Henrik Lissner 2019-05-18 21:27:23 -04:00
parent 892f0164af
commit dce3d0ddc6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -115,6 +115,16 @@ Uses `+workspaces-main' to determine the name of the main workspace."
'auto-create))) 'auto-create)))
(add-hook 'persp-after-load-state-functions #'+workspaces|leave-nil-perspective) (add-hook 'persp-after-load-state-functions #'+workspaces|leave-nil-perspective)
(defun +workspaces*evil-alternate-buffer (&optional window)
"Make `evil-alternate-buffer' ignore buffers outside the current workspace."
(let* ((prev-buffers (cl-remove-if-not #'persp-contain-buffer-p (window-prev-buffers)
:key #'car))
(head (car prev-buffers)))
(if (eq (car head) (window-buffer window))
(cadr prev-buffers)
head)))
(advice-add #'evil-alternate-buffer :override #'+workspaces*evil-alternate-buffer)
;; Delete the current workspace if closing the last open window ;; Delete the current workspace if closing the last open window
(define-key! persp-mode-map (define-key! persp-mode-map
[remap delete-window] #'+workspace/close-window-or-workspace [remap delete-window] #'+workspace/close-window-or-workspace