mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
fix(workspaces): avoid duplicate workspace creation when no frame exists
When Emacs is started as a daemon and no frames exist, `emacsclient -c` should simply switch to the main workspace. However, before `+workspaces-associate-frame-fn` is called, the new frame is already added to the frame list, which causes `persp-frame-list-without-daemon` to always return a non-empty list. A new workspace will be created instead of switching to the main one.
This commit is contained in:
@ -532,16 +532,16 @@ created."
|
|||||||
(defun +workspaces-associate-frame-fn (frame &optional _new-frame-p)
|
(defun +workspaces-associate-frame-fn (frame &optional _new-frame-p)
|
||||||
"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
|
||||||
(if (not (persp-frame-list-without-daemon))
|
(with-selected-frame frame
|
||||||
(+workspace-switch +workspaces-main t)
|
(if (not (cdr-safe (persp-frame-list-without-daemon)))
|
||||||
(with-selected-frame frame
|
(+workspace-switch +workspaces-main t)
|
||||||
(+workspace-switch (format "#%s" (+workspace--generate-id)) t)
|
(+workspace-switch (format "#%s" (+workspace--generate-id)) t))
|
||||||
(unless (doom-real-buffer-p (current-buffer))
|
(unless (doom-real-buffer-p (current-buffer))
|
||||||
(switch-to-buffer (doom-fallback-buffer)))
|
(switch-to-buffer (doom-fallback-buffer)))
|
||||||
(set-frame-parameter frame 'workspace (+workspace-current-name))
|
(set-frame-parameter frame 'workspace (+workspace-current-name))
|
||||||
;; ensure every buffer has a buffer-predicate
|
;; ensure every buffer has a buffer-predicate
|
||||||
(persp-set-frame-buffer-predicate frame))
|
(persp-set-frame-buffer-predicate frame))
|
||||||
(run-at-time 0.1 nil #'+workspace/display))))
|
(run-at-time 0.1 nil #'+workspace/display)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +workspaces-switch-to-project-h (&optional dir)
|
(defun +workspaces-switch-to-project-h (&optional dir)
|
||||||
|
Reference in New Issue
Block a user