fix: stabilize copying and moving perspectives

This commit is contained in:
Pavel Korytov 2021-12-24 22:56:07 +03:00
parent 6d3caf4cd0
commit 5b13dc7ecf

View file

@ -211,24 +211,22 @@ If MOVE is t, move the perspective instead."
(when (and move (= 1 (hash-table-count (perspectives-hash)))) (when (and move (= 1 (hash-table-count (perspectives-hash))))
(error "Can't move the only workspace")) (error "Can't move the only workspace"))
(let* ((target-workspace (exwm-workspace--prompt-for-workspace)) (let* ((target-workspace (exwm-workspace--prompt-for-workspace))
(persp (persp-curr))
(persp-name (persp-current-name)) (persp-name (persp-current-name))
(url (burly-windows-url))) (url (burly-windows-url))
(buffers (persp-current-buffers)))
(unless (= (cl-position target-workspace exwm-workspace--list) (unless (= (cl-position target-workspace exwm-workspace--list)
exwm-workspace-current-index) exwm-workspace-current-index)
(when (gethash persp-name (perspectives-hash target-workspace))
(error "Perspective with name \"%s\" already exists on the target workspace" persp-name))
(with-selected-frame target-workspace (with-selected-frame target-workspace
(when (gethash persp-name (perspectives-hash))
(error "Perspective with name \"%s\" already exists on the target workspace" persp-name))
(puthash persp-name (copy-tree (copy-perspective persp)) (perspectives-hash))
(with-perspective persp-name (with-perspective persp-name
;; (run-hooks 'persp-created-hook) (mapcar #'persp-add-buffer buffers)
(persp-update-modestring))) (burly-open-url url))
(persp-switch persp-name)
(persp-update-modestring))
(when move (when move
(persp-kill persp-name)) (persp-kill persp-name))
(exwm-workspace-switch target-workspace) (exwm-workspace-switch target-workspace))))
(persp-switch persp-name)
(burly-open-url url)
(persp-update-modestring))))
;;;###autoload ;;;###autoload
(defun perspective-exwm-move-to-workspace () (defun perspective-exwm-move-to-workspace ()