emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/exwm e491118 10/19: Support swapping workspaces


From: Chris Feng
Subject: [elpa] externals/exwm e491118 10/19: Support swapping workspaces
Date: Tue, 19 Jul 2016 03:07:08 +0000 (UTC)

branch: externals/exwm
commit e4911181d317942e9946da4cbceeeb4c6ca98884
Author: Adrián Medraño Calvo <address@hidden>
Commit: Adrián Medraño Calvo <address@hidden>

    Support swapping workspaces
    
        * exwm-workspace.el (exwm-workspace-swap-workspaces): New
        function to interchange the position of two workspaces.
---
 exwm-workspace.el |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/exwm-workspace.el b/exwm-workspace.el
index 21a415e..8627432 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -394,6 +394,28 @@ The optional FORCE option is for internal use only."
       (xcb:flush exwm--connection))
      (run-hooks 'exwm-workspace-switch-hook)))
 
+;;;###autoload
+(defun exwm-workspace-swap-workspaces (workspace1 workspace2)
+  "Swap position of WORKSPACE1 with that of WORKSPACE2."
+  (interactive
+   (unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
+     (list
+      (exwm-workspace--prompt-for-workspace)
+      (exwm-workspace--prompt-for-workspace))))
+  (let ((pos1 (exwm-workspace--position workspace1))
+        (pos2 (exwm-workspace--position workspace2)))
+    (if (and pos1 pos2)
+        (progn
+          (setf (elt exwm-workspace--list pos1) workspace2)
+          (setf (elt exwm-workspace--list pos2) workspace1)
+          (cond
+           ((eq exwm-workspace--current workspace1)
+            (setq exwm-workspace-current-index pos2))
+           ((eq exwm-workspace--current workspace2)
+            (setq exwm-workspace-current-index pos1))))
+      (user-error "[EXWM] Frames are not workspaces"))))
+
+
 (defun exwm-workspace--on-focus-in ()
   "Handle unexpected frame switch."
   ;; `focus-in-hook' is run by `handle-switch-frame'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]