Add +workspace/swap-{left,right} commands

For changing the order of workspaces.

Relevant to #2488, #2487
This commit is contained in:
Henrik Lissner 2020-02-06 15:17:29 -05:00
parent 5eeb362610
commit 3ab70d78eb
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -404,6 +404,31 @@ the next."
((+workspace-error "Can't delete last workspace" t)))))))
;;;###autoload
(defun +workspace/swap-left (&optional count)
"Swap the current workspace with the COUNTth workspace on its left."
(interactive "p")
(let* ((current-name (+workspace-current-name))
(count (or count 1))
(index (- (cl-position current-name persp-names-cache :test #'equal)
count))
(names (remove current-name persp-names-cache)))
(unless names
(user-error "Only one workspace"))
(let ((index (min (max 0 index) (length names))))
(setq persp-names-cache
(append (cl-subseq names 0 index)
(list current-name)
(cl-subseq names index))))
(when (called-interactively-p 'any)
(+workspace/display))))
;;;###autoload
(defun +workspace/swap-right (&optional count)
"Swap the current workspace with the COUNTth workspace on its right."
(interactive "p")
(funcall-interactively #'+workspace/swap-left (- count)))
;;
;;; Tabs display in minibuffer