Add +workspace/other #1480

- Rename +workspace/switch-to-last to +workspace/switch-to-final, to
  avoid ambiguity.
- Add +workspace/switch-to-N commands
This commit is contained in:
Henrik Lissner 2019-06-11 16:09:29 +02:00
parent 6b6ea699f4
commit bc6c4b3e37
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 36 additions and 24 deletions

View file

@ -164,22 +164,22 @@
:desc "Save workspace" "S" #'+workspace/save
:desc "Load session" "l" #'doom/load-session
:desc "Load last autosaved session" "L" #'doom/quickload-session
:desc "Kill other buffers" "o" #'doom/kill-other-buffers
:desc "Switch to other workspace" "o" #'+workspace/other
:desc "Undo window config" "u" #'winner-undo
:desc "Redo window config" "U" #'winner-redo
:desc "Switch to left workspace" "p" #'+workspace/switch-left
:desc "Switch to right workspace" "n" #'+workspace/switch-right
:desc "Switch to" "w" #'+workspace/switch-to
:desc "Switch to workspace 1" "1" (λ! (+workspace/switch-to 0))
:desc "Switch to workspace 2" "2" (λ! (+workspace/switch-to 1))
:desc "Switch to workspace 3" "3" (λ! (+workspace/switch-to 2))
:desc "Switch to workspace 4" "4" (λ! (+workspace/switch-to 3))
:desc "Switch to workspace 5" "5" (λ! (+workspace/switch-to 4))
:desc "Switch to workspace 6" "6" (λ! (+workspace/switch-to 5))
:desc "Switch to workspace 7" "7" (λ! (+workspace/switch-to 6))
:desc "Switch to workspace 8" "8" (λ! (+workspace/switch-to 7))
:desc "Switch to workspace 9" "9" (λ! (+workspace/switch-to 8))
:desc "Switch to last workspace" "0" #'+workspace/switch-to-last)
:desc "Switch to workspace 1" "1" #'+workspace/switch-to-0
:desc "Switch to workspace 2" "2" #'+workspace/switch-to-1
:desc "Switch to workspace 3" "3" #'+workspace/switch-to-2
:desc "Switch to workspace 4" "4" #'+workspace/switch-to-3
:desc "Switch to workspace 5" "5" #'+workspace/switch-to-4
:desc "Switch to workspace 6" "6" #'+workspace/switch-to-5
:desc "Switch to workspace 7" "7" #'+workspace/switch-to-6
:desc "Switch to workspace 8" "8" #'+workspace/switch-to-7
:desc "Switch to workspace 9" "9" #'+workspace/switch-to-8
:desc "Switch to last workspace" "0" #'+workspace/switch-to-final)
;;; <leader> m --- multiple cursors
(:when (featurep! :editor multiple-cursors)

View file

@ -321,7 +321,7 @@
:g "M-7" (λ! (+workspace/switch-to 6))
:g "M-8" (λ! (+workspace/switch-to 7))
:g "M-9" (λ! (+workspace/switch-to 8))
:g "M-0" #'+workspace/switch-to-last
:g "M-0" #'+workspace/switch-to-final
:g "M-t" #'+workspace/new
:g "M-T" #'+workspace/display))
@ -530,6 +530,7 @@
(:prefix-map ("TAB" . "workspace")
:desc "Display tab bar" "TAB" #'+workspace/display
:desc "Switch workspace" "." #'+workspace/switch-to
:desc "Switch to last workspace" "`" #'+workspace/other
:desc "New workspace" "n" #'+workspace/new
:desc "Load workspace from file" "l" #'+workspace/load
:desc "Save workspace to file" "s" #'+workspace/save
@ -539,16 +540,16 @@
:desc "Restore last session" "R" #'+workspace/restore-last-session
:desc "Next workspace" "]" #'+workspace/switch-right
:desc "Previous workspace" "[" #'+workspace/switch-left
:desc "Switch to 1st workspace" "1" (λ! (+workspace/switch-to 0))
:desc "Switch to 2nd workspace" "2" (λ! (+workspace/switch-to 1))
:desc "Switch to 3rd workspace" "3" (λ! (+workspace/switch-to 2))
:desc "Switch to 4th workspace" "4" (λ! (+workspace/switch-to 3))
:desc "Switch to 5th workspace" "5" (λ! (+workspace/switch-to 4))
:desc "Switch to 6th workspace" "6" (λ! (+workspace/switch-to 5))
:desc "Switch to 7th workspace" "7" (λ! (+workspace/switch-to 6))
:desc "Switch to 8th workspace" "8" (λ! (+workspace/switch-to 7))
:desc "Switch to 9th workspace" "9" (λ! (+workspace/switch-to 8))
:desc "Switch to last workspace" "0" #'+workspace/switch-to-last))
:desc "Switch to 1st workspace" "1" #'+workspace/switch-to-0
:desc "Switch to 2nd workspace" "2" #'+workspace/switch-to-1
:desc "Switch to 3rd workspace" "3" #'+workspace/switch-to-2
:desc "Switch to 4th workspace" "4" #'+workspace/switch-to-3
:desc "Switch to 5th workspace" "5" #'+workspace/switch-to-4
:desc "Switch to 6th workspace" "6" #'+workspace/switch-to-5
:desc "Switch to 7th workspace" "7" #'+workspace/switch-to-6
:desc "Switch to 8th workspace" "8" #'+workspace/switch-to-7
:desc "Switch to 9th workspace" "9" #'+workspace/switch-to-8
:desc "Switch to final workspace" "0" #'+workspace/switch-to-final))
;;; <leader> b --- buffer
(:prefix-map ("b" . "buffer")

View file

@ -327,11 +327,22 @@ end of the workspace list."
('error (+workspace-error (cadr ex) t))))
;;;###autoload
(defun +workspace/switch-to-last ()
"Switch to the last workspace."
(dotimes (i 9)
(fset (intern (format "+workspace/switch-to-%d" i))
(lambda () (interactive) (+workspace/switch-to i))))
;;;###autoload
(defun +workspace/switch-to-final ()
"Switch to the final workspace in open workspaces."
(interactive)
(+workspace/switch-to (car (last (+workspace-list-names)))))
;;;###autoload
(defun +workspace/other ()
"Switch to the last activated workspace."
(interactive)
(+workspace/switch-to +workspace--last))
;;;###autoload
(defun +workspace/cycle (n)
"Cycle n workspaces to the right (default) or left."