feature/workspace: improve daemon/frame compatibility

This update fixes issues with frame-local perspectives, and ensures that
a workspace is always selected in a daemon session's frames.
This commit is contained in:
Henrik Lissner 2018-01-28 20:32:08 -05:00
parent 38c0a85155
commit 22f4404210
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 30 additions and 22 deletions

View file

@ -468,8 +468,10 @@ created."
"Create a blank, new perspective and associate it with FRAME."
(when persp-mode
(with-selected-frame frame
(if (not (persp-frame-list-without-daemon))
(+workspace-switch +workspaces-main t)
(+workspace/new)
(set-frame-parameter frame 'workspace (+workspace-current-name))
(set-frame-parameter frame 'workspace (+workspace-current-name)))
(+workspace/display))))
(defvar +workspaces--project-dir nil)

View file

@ -24,12 +24,16 @@ renamed.")
(def-package! persp-mode
:defer t
:init
(defun +workspaces|init (&optional frame)
(defun +workspaces|init ()
(require 'persp-mode)
(unless persp-mode
(persp-mode +1))
(persp-mode +1)
(+workspaces|init-frame (selected-frame))
(add-hook 'after-make-frame-functions #'+workspaces|init-frame))
(defun +workspaces|init-frame (frame)
(unless noninteractive
(let (persp-before-switch-functions persp-activated-functions)
(with-selected-frame frame
;; The default perspective persp-mode makes (defined by
;; `persp-nil-name') is special and doesn't actually represent a real
;; persp object, so buffers can't really be assigned to it, among other
@ -37,18 +41,20 @@ renamed.")
(unless (persp-get-by-name +workspaces-main)
(persp-add-new +workspaces-main))
;; Switch to it if we aren't auto-loading the last session
(when (and (equal (safe-persp-name (get-current-persp)) persp-nil-name)
(when (and (string= (safe-persp-name (get-current-persp)) persp-nil-name)
(= persp-auto-resume-time -1))
(persp-frame-switch +workspaces-main)))
(persp-frame-switch +workspaces-main frame))
;; We want to know where we are in every new daemon frame
(when (daemonp)
(run-at-time 0.2 nil #'+workspace/display))
;; The warnings buffer gets swallowed by creating `+workspaces-main', so
;; we display it manually, if it exists (fix #319).
(when-let* ((warnings (get-buffer "*Warnings*")))
(save-excursion
(display-buffer-in-side-window
warnings '((window-height . shrink-window-if-larger-than-buffer)))))))
warnings '((window-height . shrink-window-if-larger-than-buffer)))))))))
(add-hook 'doom-init-hook #'+workspaces|init)
(add-hook 'after-make-frame-functions #'+workspaces|init)
:config
(setq persp-autokill-buffer-on-remove 'kill-weak
persp-nil-hidden t