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

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

[elpa] externals/exwm 734b401 1/2: Fix the advice function for ido-buffe


From: Chris Feng
Subject: [elpa] externals/exwm 734b401 1/2: Fix the advice function for ido-buffer-window-other-frame
Date: Sun, 21 Feb 2016 08:45:33 +0000

branch: externals/exwm
commit 734b4013063d1bf3c6e34e0aa66e39a92ba49ace
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Fix the advice function for ido-buffer-window-other-frame
    
    * exwm-config.el (exwm-config--ido-buffer-window-other-frame)
    (exwm-config--fix/ido-buffer-window-other-frame): Do not use advice.
    Fix issues when switching form/to floating frames.
---
 exwm-config.el |   43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/exwm-config.el b/exwm-config.el
index db8c68f..d6e10f2 100644
--- a/exwm-config.el
+++ b/exwm-config.el
@@ -26,6 +26,7 @@
 ;;; Code:
 
 (require 'exwm)
+(require 'ido)
 
 (defun exwm-config-default ()
   "Default configuration of EXWM."
@@ -65,21 +66,37 @@
   ;; Other configurations
   (exwm-config-misc))
 
-(defun exwm-config--ido-buffer-window-other-frame (orig-fun buffer)
-  "Wrapper for `ido-buffer-window-other-frame' to exclude invisible windows."
-  (with-current-buffer buffer
-    (if (and (eq major-mode 'exwm-mode)
-             (or exwm--floating-frame
-                 (not exwm-layout-show-all-buffers)))
-        ;; `ido-mode' works well with `exwm-mode' buffers
-        (funcall orig-fun buffer)
-      ;; Other buffers should be selected within the same workspace
-      (get-buffer-window buffer exwm-workspace--current))))
-
 (defun exwm-config--fix/ido-buffer-window-other-frame ()
   "Fix `ido-buffer-window-other-frame'."
-  (advice-add 'ido-buffer-window-other-frame :around
-              #'exwm-config--ido-buffer-window-other-frame))
+  (defalias 'exwm-config-ido-buffer-window-other-frame
+    (symbol-function #'ido-buffer-window-other-frame))
+  (defun ido-buffer-window-other-frame (buffer)
+    "This is a version redefined by EXWM.
+
+You can find the original one at `exwm-config-ido-buffer-window-other-frame'."
+    (with-current-buffer (window-buffer (selected-window))
+      (if (and (eq major-mode 'exwm-mode)
+               exwm--floating-frame)
+          ;; Switch from a floating frame.
+          (with-current-buffer buffer
+            (if (and (eq major-mode 'exwm-mode)
+                     exwm--floating-frame
+                     (eq exwm--frame exwm-workspace--current))
+                ;; Switch to another floating frame.
+                (frame-root-window exwm--floating-frame)
+              ;; Do not switch if the buffer is not on the current workspace.
+              (or (get-buffer-window buffer exwm-workspace--current)
+                  (selected-window))))
+        (with-current-buffer buffer
+          (when (eq major-mode 'exwm-mode)
+            (if (eq exwm--frame exwm-workspace--current)
+                (when exwm--floating-frame
+                  ;; Switch to a floating frame on the current workspace.
+                  (frame-selected-window exwm--floating-frame))
+              ;; Do not switch to exwm-mode buffers on other workspace (which
+              ;; won't work unless `exwm-layout-show-all-buffers' is set)
+              (unless exwm-layout-show-all-buffers
+                (selected-window)))))))))
 
 (defun exwm-config-ido ()
   "Configure Ido to work with EXWM."



reply via email to

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