feature/workspaces: remove +workspace-change-hook

persp-mode provides the following hooks already (among many others):

+ persp-{before,after}-switch-functions
+ persp-renamed-functions
+ persp-created-functions
+ persp-before-kill-functions

This makes +workspace-change-hook redundant.
This commit is contained in:
Henrik Lissner 2018-01-14 16:21:18 -05:00
parent ea97600507
commit 10167b85b5
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -3,9 +3,6 @@
(defvar +workspace-data-file "_workspaces" (defvar +workspace-data-file "_workspaces"
"The file basename in which to store single workspace perspectives.") "The file basename in which to store single workspace perspectives.")
(defvar +workspace-change-hook ()
"Hooks run when workspaces are added, removed, renamed or switched to.")
(defvar +workspace--last nil) (defvar +workspace--last nil)
(defvar +workspace--index 0) (defvar +workspace--index 0)
@ -155,9 +152,7 @@ Otherwise return t on success, nil otherwise."
(error "Can't create a new '%s' workspace" name)) (error "Can't create a new '%s' workspace" name))
(when (+workspace-exists-p name) (when (+workspace-exists-p name)
(error "A workspace named '%s' already exists" name)) (error "A workspace named '%s' already exists" name))
(when (persp-add-new name) (persp-add-new name))
(run-hooks '+workspace-change-hook)
t))
;;;###autoload ;;;###autoload
(defun +workspace-rename (name new-name) (defun +workspace-rename (name new-name)
@ -165,9 +160,7 @@ Otherwise return t on success, nil otherwise."
success, nil otherwise." success, nil otherwise."
(when (+workspace--protected-p name) (when (+workspace--protected-p name)
(error "Can't rename '%s' workspace" name)) (error "Can't rename '%s' workspace" name))
(when (persp-rename new-name (+workspace-get name)) (persp-rename new-name (+workspace-get name)))
(run-hooks '+workspace-change-hook)
name))
;;;###autoload ;;;###autoload
(defun +workspace-delete (name &optional inhibit-kill-p) (defun +workspace-delete (name &optional inhibit-kill-p)
@ -178,9 +171,7 @@ buffers."
(error "Can't delete '%s' workspace" name)) (error "Can't delete '%s' workspace" name))
(+workspace-get name) ; error checking (+workspace-get name) ; error checking
(persp-kill name inhibit-kill-p) (persp-kill name inhibit-kill-p)
(unless (+workspace-exists-p name) (not (+workspace-exists-p name)))
(run-hooks '+workspace-change-hook)
t))
;;;###autoload ;;;###autoload
(defun +workspace-switch (name &optional auto-create-p) (defun +workspace-switch (name &optional auto-create-p)
@ -193,11 +184,9 @@ buffers."
(setq +workspace--last (setq +workspace--last
(or (and (not (string= old-name persp-nil-name)) (or (and (not (string= old-name persp-nil-name))
old-name) old-name)
+workspaces-main))) +workspaces-main))
(persp-frame-switch name) (persp-frame-switch name)
(when (equal (+workspace-current-name) name) (equal (+workspace-current-name) name)))
(run-hooks '+workspace-change-hook)
t))
;;;###autoload ;;;###autoload
(defun +workspace-on-new-frame (frame &optional _new-frame-p) (defun +workspace-on-new-frame (frame &optional _new-frame-p)