+workspace/delete: error if workspace doesn't exist

This commit is contained in:
Henrik Lissner 2018-08-26 14:14:53 +02:00
parent e40a58c423
commit 1ed8894826
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -301,22 +301,24 @@ workspace to delete."
current-name)))) current-name))))
(condition-case-unless-debug ex (condition-case-unless-debug ex
(let ((workspaces (+workspace-list-names))) (let ((workspaces (+workspace-list-names)))
(cond ((delq (selected-frame) (persp-frames-with-persp (get-frame-persp))) (if (not (member name workspaces))
(user-error "Can't close workspace, it's visible in another frame")) (+workspace-message (format "'%s' workspace doesn't exist" name) 'warn)
((> (length workspaces) 1) (cond ((delq (selected-frame) (persp-frames-with-persp (get-frame-persp)))
(+workspace-delete name) (user-error "Can't close workspace, it's visible in another frame"))
(+workspace-switch ((> (length workspaces) 1)
(if (+workspace-exists-p +workspace--last) (+workspace-delete name)
+workspace--last (+workspace-switch
(car (+workspace-list-names)))) (if (+workspace-exists-p +workspace--last)
(unless (doom-buffer-frame-predicate (current-buffer)) +workspace--last
(switch-to-buffer (doom-fallback-buffer)))) (car (+workspace-list-names))))
(t (unless (doom-buffer-frame-predicate (current-buffer))
(+workspace-switch +workspaces-main t) (switch-to-buffer (doom-fallback-buffer))))
(unless (string= (car workspaces) +workspaces-main) (t
(+workspace-delete name)) (+workspace-switch +workspaces-main t)
(doom/kill-all-buffers))) (unless (string= (car workspaces) +workspaces-main)
(+workspace-message (format "Deleted '%s' workspace" name) 'success)) (+workspace-delete name))
(doom/kill-all-buffers)))
(+workspace-message (format "Deleted '%s' workspace" name) 'success)))
('error (+workspace-error ex t)))) ('error (+workspace-error ex t))))
;;;###autoload ;;;###autoload