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:
parent
38c0a85155
commit
22f4404210
2 changed files with 30 additions and 22 deletions
|
@ -468,8 +468,10 @@ created."
|
||||||
"Create a blank, new perspective and associate it with FRAME."
|
"Create a blank, new perspective and associate it with FRAME."
|
||||||
(when persp-mode
|
(when persp-mode
|
||||||
(with-selected-frame frame
|
(with-selected-frame frame
|
||||||
|
(if (not (persp-frame-list-without-daemon))
|
||||||
|
(+workspace-switch +workspaces-main t)
|
||||||
(+workspace/new)
|
(+workspace/new)
|
||||||
(set-frame-parameter frame 'workspace (+workspace-current-name))
|
(set-frame-parameter frame 'workspace (+workspace-current-name)))
|
||||||
(+workspace/display))))
|
(+workspace/display))))
|
||||||
|
|
||||||
(defvar +workspaces--project-dir nil)
|
(defvar +workspaces--project-dir nil)
|
||||||
|
|
|
@ -24,12 +24,16 @@ renamed.")
|
||||||
(def-package! persp-mode
|
(def-package! persp-mode
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
(defun +workspaces|init (&optional frame)
|
(defun +workspaces|init ()
|
||||||
(require 'persp-mode)
|
(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
|
(unless noninteractive
|
||||||
(let (persp-before-switch-functions persp-activated-functions)
|
(let (persp-before-switch-functions persp-activated-functions)
|
||||||
|
(with-selected-frame frame
|
||||||
;; The default perspective persp-mode makes (defined by
|
;; The default perspective persp-mode makes (defined by
|
||||||
;; `persp-nil-name') is special and doesn't actually represent a real
|
;; `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
|
;; 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)
|
(unless (persp-get-by-name +workspaces-main)
|
||||||
(persp-add-new +workspaces-main))
|
(persp-add-new +workspaces-main))
|
||||||
;; Switch to it if we aren't auto-loading the last session
|
;; 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-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
|
;; The warnings buffer gets swallowed by creating `+workspaces-main', so
|
||||||
;; we display it manually, if it exists (fix #319).
|
;; we display it manually, if it exists (fix #319).
|
||||||
(when-let* ((warnings (get-buffer "*Warnings*")))
|
(when-let* ((warnings (get-buffer "*Warnings*")))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(display-buffer-in-side-window
|
(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 'doom-init-hook #'+workspaces|init)
|
||||||
(add-hook 'after-make-frame-functions #'+workspaces|init)
|
|
||||||
:config
|
:config
|
||||||
(setq persp-autokill-buffer-on-remove 'kill-weak
|
(setq persp-autokill-buffer-on-remove 'kill-weak
|
||||||
persp-nil-hidden t
|
persp-nil-hidden t
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue