Add workspace action messages and open home buffer (#14709)
### Added workspace action messages `SPC l w` followed by a number key `0-9` or `SPC l w s` single window workspace >Workspace 2 created `SPC l w 1` from another workspace >Workspace switched to 1 `SPC l w 1` from the same workspace >Already on Workspace 1 `SPC l w c` clones the current workspace to the next free slot >Workspace 1 cloned to 3 `SPC l w d` close the current workspace Workspace 3 closed ### And Open the Spacemacs home buffer when creating a new workspace with the number keys. Previously it opened the scratch buffer.
This commit is contained in:
parent
4e5a7233b0
commit
29fa26af98
|
@ -701,25 +701,99 @@ STATE is a window-state object as returned by `window-state-get'."
|
|||
|
||||
;; Eyebrowse transient state
|
||||
|
||||
(defun spacemacs//workspace-get-used-slots ()
|
||||
(mapcar 'car (eyebrowse--get 'window-configs)))
|
||||
|
||||
(defun spacemacs//workspace-next-free-slot ()
|
||||
"Get the next free workspace slot."
|
||||
(eyebrowse-free-slot (spacemacs//workspace-get-used-slots)))
|
||||
|
||||
(defun spacemacs/clone-workspace ()
|
||||
"Clone the current workspace.
|
||||
And show a minibuffer message, ex:
|
||||
Workspace: 1, cloned to Workspace: 2"
|
||||
"Clone the current workspace."
|
||||
(interactive)
|
||||
(let* ((eyebrowse-new-workspace nil) ; nil = clone current workspace
|
||||
(current-workspace-nr (eyebrowse--get 'current-slot))
|
||||
(window-configs (eyebrowse--get 'window-configs))
|
||||
(slots (mapcar 'car window-configs))
|
||||
(next-free-workspace-nr (eyebrowse-free-slot slots)))
|
||||
(eyebrowse-switch-to-window-config next-free-workspace-nr)
|
||||
(message "Workspace: %s, cloned to Workspace: %s"
|
||||
current-workspace-nr next-free-workspace-nr)))
|
||||
(let ((eyebrowse-new-workspace nil) ; nil = clone current workspace
|
||||
(current-slot (eyebrowse--get 'current-slot))
|
||||
(next-free-slot (spacemacs//workspace-next-free-slot)))
|
||||
(eyebrowse-switch-to-window-config next-free-slot)
|
||||
(message "Workspace %s cloned to %s" current-slot next-free-slot)))
|
||||
|
||||
(defun spacemacs/new-workspace (&optional slot)
|
||||
"Create a new workspace, showing the Spacemacs home buffer.
|
||||
If a optional SLOT (number) was provided,
|
||||
then create the new workspace at that slot.
|
||||
Otherwise create it at the next free slot."
|
||||
(let ((eyebrowse-new-workspace 'spacemacs/home)
|
||||
(slot (or slot (spacemacs//workspace-next-free-slot))))
|
||||
(eyebrowse-switch-to-window-config slot)
|
||||
(message "Workspace %s created" slot)))
|
||||
|
||||
(defun spacemacs/single-win-workspace ()
|
||||
"Create a new single window workspace, and show the Spacemacs home buffer."
|
||||
"Create a new single window workspace,
|
||||
showing the Spacemacs home buffer."
|
||||
(interactive)
|
||||
(let ((eyebrowse-new-workspace 'spacemacs/home))
|
||||
(eyebrowse-create-window-config)))
|
||||
(spacemacs/new-workspace))
|
||||
|
||||
(defun spacemacs/workspace-switch-or-create (slot)
|
||||
"Given a workspace SLOT number.
|
||||
If SLOT is current, show a message.
|
||||
If SLOT exists, switch to it.
|
||||
Otherwise create a new workspace at the next free slot."
|
||||
(let* ((slot-current-p (= slot (eyebrowse--get 'current-slot)))
|
||||
(slot-exists-p (and (not slot-current-p)
|
||||
(memq slot (spacemacs//workspace-get-used-slots)))))
|
||||
(cond (slot-current-p (message "Already on Workspace: %s" slot))
|
||||
(slot-exists-p (eyebrowse-switch-to-window-config slot)
|
||||
(message "Workspace switched to: %s" slot))
|
||||
(t (spacemacs/new-workspace slot)))))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-0 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 0))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-1 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 1))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-2 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 2))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-3 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 3))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-4 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 4))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-5 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 5))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-6 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 6))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-7 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 7))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-8 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 8))
|
||||
|
||||
(defun spacemacs/eyebrowse-switch-to-window-config-9 ()
|
||||
(interactive)
|
||||
(spacemacs/workspace-switch-or-create 9))
|
||||
|
||||
(defun spacemacs/eyebrowse-close-window-config ()
|
||||
(interactive)
|
||||
(let ((current-workspace (eyebrowse--get 'current-slot))
|
||||
(last-workspace-p (= (length (eyebrowse--get 'window-configs)) 1)))
|
||||
(if last-workspace-p
|
||||
(message "The last workspace can not be closed")
|
||||
(eyebrowse-close-window-config)
|
||||
(message "Workspace %s closed" current-workspace))))
|
||||
|
||||
(defun spacemacs//workspaces-ts-toggle-hint ()
|
||||
"Toggle the full hint docstring for the workspaces transient-state."
|
||||
|
|
|
@ -57,26 +57,26 @@
|
|||
:dynamic-hint (spacemacs//workspaces-ts-hint)
|
||||
:bindings
|
||||
("?" spacemacs//workspaces-ts-toggle-hint)
|
||||
("0" eyebrowse-switch-to-window-config-0 :exit t)
|
||||
("1" eyebrowse-switch-to-window-config-1 :exit t)
|
||||
("2" eyebrowse-switch-to-window-config-2 :exit t)
|
||||
("3" eyebrowse-switch-to-window-config-3 :exit t)
|
||||
("4" eyebrowse-switch-to-window-config-4 :exit t)
|
||||
("5" eyebrowse-switch-to-window-config-5 :exit t)
|
||||
("6" eyebrowse-switch-to-window-config-6 :exit t)
|
||||
("7" eyebrowse-switch-to-window-config-7 :exit t)
|
||||
("8" eyebrowse-switch-to-window-config-8 :exit t)
|
||||
("9" eyebrowse-switch-to-window-config-9 :exit t)
|
||||
("C-0" eyebrowse-switch-to-window-config-0)
|
||||
("C-1" eyebrowse-switch-to-window-config-1)
|
||||
("C-2" eyebrowse-switch-to-window-config-2)
|
||||
("C-3" eyebrowse-switch-to-window-config-3)
|
||||
("C-4" eyebrowse-switch-to-window-config-4)
|
||||
("C-5" eyebrowse-switch-to-window-config-5)
|
||||
("C-6" eyebrowse-switch-to-window-config-6)
|
||||
("C-7" eyebrowse-switch-to-window-config-7)
|
||||
("C-8" eyebrowse-switch-to-window-config-8)
|
||||
("C-9" eyebrowse-switch-to-window-config-9)
|
||||
("0" spacemacs/eyebrowse-switch-to-window-config-0 :exit t)
|
||||
("1" spacemacs/eyebrowse-switch-to-window-config-1 :exit t)
|
||||
("2" spacemacs/eyebrowse-switch-to-window-config-2 :exit t)
|
||||
("3" spacemacs/eyebrowse-switch-to-window-config-3 :exit t)
|
||||
("4" spacemacs/eyebrowse-switch-to-window-config-4 :exit t)
|
||||
("5" spacemacs/eyebrowse-switch-to-window-config-5 :exit t)
|
||||
("6" spacemacs/eyebrowse-switch-to-window-config-6 :exit t)
|
||||
("7" spacemacs/eyebrowse-switch-to-window-config-7 :exit t)
|
||||
("8" spacemacs/eyebrowse-switch-to-window-config-8 :exit t)
|
||||
("9" spacemacs/eyebrowse-switch-to-window-config-9 :exit t)
|
||||
("C-0" spacemacs/eyebrowse-switch-to-window-config-0)
|
||||
("C-1" spacemacs/eyebrowse-switch-to-window-config-1)
|
||||
("C-2" spacemacs/eyebrowse-switch-to-window-config-2)
|
||||
("C-3" spacemacs/eyebrowse-switch-to-window-config-3)
|
||||
("C-4" spacemacs/eyebrowse-switch-to-window-config-4)
|
||||
("C-5" spacemacs/eyebrowse-switch-to-window-config-5)
|
||||
("C-6" spacemacs/eyebrowse-switch-to-window-config-6)
|
||||
("C-7" spacemacs/eyebrowse-switch-to-window-config-7)
|
||||
("C-8" spacemacs/eyebrowse-switch-to-window-config-8)
|
||||
("C-9" spacemacs/eyebrowse-switch-to-window-config-9)
|
||||
("<tab>" eyebrowse-last-window-config)
|
||||
("<return>" nil :exit t)
|
||||
("TAB" eyebrowse-last-window-config)
|
||||
|
@ -85,7 +85,7 @@
|
|||
("C" spacemacs/clone-workspace)
|
||||
("C-h" eyebrowse-prev-window-config)
|
||||
("C-l" eyebrowse-next-window-config)
|
||||
("d" eyebrowse-close-window-config)
|
||||
("d" spacemacs/eyebrowse-close-window-config)
|
||||
("l" spacemacs/layouts-transient-state/body :exit t)
|
||||
("n" eyebrowse-next-window-config)
|
||||
("N" eyebrowse-prev-window-config)
|
||||
|
|
Loading…
Reference in New Issue