about summary refs log tree commit diff
path: root/exwm.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2015-08-11T03·54+0800
committerChris Feng <chris.w.feng@gmail.com>2015-08-11T03·54+0800
commit801185c7cc2c257ac2e8ed9a3aa8e8119c56ad1f (patch)
tree88b701c22920f07029c1b4a057ef48ef32ac5046 /exwm.el
parentb755296f547938d0f97d6aa49b8cb0d726de9eb9 (diff)
Fix buffer switch problems
* Prevent switching to floating windows or windows on other workspaces
* Provide a workaround for `ido-mode` (can be enabled with
  `(exwm-enable-ido-workaround)`)
Diffstat (limited to 'exwm.el')
-rw-r--r--exwm.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/exwm.el b/exwm.el
index 95b674243cee..7e909cdef681 100644
--- a/exwm.el
+++ b/exwm.el
@@ -707,6 +707,30 @@
     (add-hook 'window-setup-hook 'exwm-init t)            ;for Emacs
     (add-hook 'after-make-frame-functions 'exwm-init t))) ;for Emacs Client
 
+(defun exwm--ido-buffer-window-other-frame (orig-fun buffer)
+  "Wrapper for `ido-buffer-window-other-frame' to exclude invisible windows."
+  (let* ((window (funcall orig-fun buffer))
+         (frame (window-frame window)))
+    ;; Exclude windows on other workspaces
+    (unless (and (memq frame exwm-workspace--list)
+                 (not (eq frame exwm-workspace--current)))
+      window)))
+
+(defun exwm--fix-ido-buffer-window-other-frame ()
+  "Fix `ido-buffer-window-other-frame'."
+  (advice-add 'ido-buffer-window-other-frame :around
+              'exwm--ido-buffer-window-other-frame))
+
+(defun exwm-enable-ido-workaround ()
+  "Enable workarounds for `ido-mode'."
+  (add-hook 'exwm-init-hook 'exwm--fix-ido-buffer-window-other-frame))
+
+(defun exwm-disable-ido-workaround ()
+  "Disable workarounds for `ido-mode'."
+  (remove-hook 'exwm-init-hook 'exwm--fix-ido-buffer-window-other-frame)
+  (advice-remove 'ido-buffer-window-other-frame
+                 'exwm--ido-buffer-window-other-frame))
+
 
 
 (provide 'exwm)