feature/workspaces: clear last workspace instead of erroring out

This commit is contained in:
Henrik Lissner 2018-04-02 05:50:39 -04:00
parent 7282553d2d
commit aad653d913
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -259,25 +259,21 @@ workspace to delete."
nil nil current-name) nil nil current-name)
current-name)))) current-name))))
(condition-case-unless-debug ex (condition-case-unless-debug ex
(+workspace-message (let ((workspaces (length (+workspace-list-names))))
(let ((workspaces (length (+workspace-list-names)))) (cond ((> workspaces 1)
(cond ((> workspaces 1) (+workspace-delete name)
(+workspace-delete name) (+workspace-switch
(+workspace-switch (if (+workspace-exists-p +workspace--last)
(if (+workspace-exists-p +workspace--last) +workspace--last
+workspace--last (car (+workspace-list-names))))
(car (+workspace-list-names)))) (unless (doom-buffer-frame-predicate (current-buffer))
(unless (doom-buffer-frame-predicate (current-buffer)) (switch-to-buffer (doom-fallback-buffer))))
(switch-to-buffer (doom-fallback-buffer))) (t
(format "Deleted '%s' workspace" name)) (+workspace-switch +workspaces-main t)
((= workspaces 1) (unless (string= (car workspaces) +workspaces-main)
(format "Can't delete the last workspace!")) (+workspace-delete name))
(t (doom/kill-all-buffers)))
(+workspace-delete name) (+workspace-message (format "Deleted '%s' workspace" name) 'success))
(+workspace-switch +workspaces-main t)
(switch-to-buffer (doom-fallback-buffer))
(format "No workspaces detected! Auto-creating '%s' workspace" +workspaces-main))))
'success)
('error (+workspace-error ex t)))) ('error (+workspace-error ex t))))
;;;###autoload ;;;###autoload