Add +workspace/swap-{left,right} commands
For changing the order of workspaces. Relevant to #2488, #2487
This commit is contained in:
parent
5eeb362610
commit
3ab70d78eb
1 changed files with 25 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue