about summary refs log tree commit diff
path: root/emacs/.emacs.d/wpc/window-manager.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/.emacs.d/wpc/window-manager.el')
-rw-r--r--emacs/.emacs.d/wpc/window-manager.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/emacs/.emacs.d/wpc/window-manager.el b/emacs/.emacs.d/wpc/window-manager.el
index cda66a296492..5a2ae0e186ed 100644
--- a/emacs/.emacs.d/wpc/window-manager.el
+++ b/emacs/.emacs.d/wpc/window-manager.el
@@ -375,6 +375,22 @@ predicate."
        cycle-current
        window-manager--named-workspace-label))
 
+(defun window-manager-swap-workspaces ()
+  "Prompt the user to switch the current workspace with another."
+  (interactive)
+  (let* ((selection (->> window-manager--named-workspaces
+                         (-map #'window-manager--named-workspace-label)
+                         (-reject
+                          (lambda (x)
+                            (s-equals? x (window-manager-current-workspace))))
+                         (completing-read
+                          (format "Swap current workspace (i.e. \"%s\") with: "
+                                  (window-manager-current-workspace)))))
+         (i (-find-index (lambda (x)
+                           (s-equals? selection (window-manager--named-workspace-label x)))
+                                 window-manager--named-workspaces)))
+    (exwm-workspace-swap exwm-workspace--current (elt exwm-workspace--list i))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Startup Applications in `window-manager--named-workspaces'
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;