about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2016-07-17T12·00+0000
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2016-07-17T12·00+0000
commitf4b8cc47c7a00456566a8a794cd9ee0bf06efaaa (patch)
tree1d412bd2c36f293e64e73d6055a87147e7315d73
parente4911181d317942e9946da4cbceeeb4c6ca98884 (diff)
Support moving workspaces
	* exwm-workspace.el (exwm-workspace-move-workspace): New function
	to move a workspace to a certain position.
-rw-r--r--exwm-workspace.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 8627432e562d..9bbbf2a51b99 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -396,7 +396,7 @@ The optional FORCE option is for internal use only."
 
 ;;;###autoload
 (defun exwm-workspace-swap-workspaces (workspace1 workspace2)
-  "Swap position of WORKSPACE1 with that of WORKSPACE2."
+  "Interchange position of WORKSPACE1 with that of WORKSPACE2."
   (interactive
    (unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
      (list
@@ -415,6 +415,20 @@ The optional FORCE option is for internal use only."
             (setq exwm-workspace-current-index pos1))))
       (user-error "[EXWM] Frames are not workspaces"))))
 
+;;;###autoload
+(defun exwm-workspace-move-workspace (workspace nth)
+  "Move WORKSPACE to the NTH position.
+When called interactively, prompt for a workspace and move current one just
+before it."
+  (interactive
+   (unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
+     (list exwm-workspace--current
+           (exwm-workspace--position (exwm-workspace--prompt-for-workspace)))))
+  (let ((pos (exwm-workspace--position workspace)))
+    (if (= nth pos)
+        (user-error "[EXWM] Cannot move to same position")
+      (pop (nthcdr pos exwm-workspace--list))
+      (push workspace (nthcdr nth exwm-workspace--list)))))
 
 (defun exwm-workspace--on-focus-in ()
   "Handle unexpected frame switch."