about summary refs log tree commit diff
path: root/exwm-manage.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-07-30T02·12+0800
committerChris Feng <chris.w.feng@gmail.com>2016-07-30T02·12+0800
commitaa7de9dc6f13b0d937fe265b64368b7be6e8798e (patch)
tree0e10e504beeedd2717fb03f4316d515e69c76da1 /exwm-manage.el
parentba0f41db1b377196af8aa6607ef215e48a3daa26 (diff)
Exit the active minibuffer on unmanaging X windows
* exwm-manage.el (exwm-manage--unmanage-window): Exit the minibuffer as
a precaution to prevent the "selecting deleted buffer" error.
Diffstat (limited to 'exwm-manage.el')
-rw-r--r--exwm-manage.el28
1 files changed, 20 insertions, 8 deletions
diff --git a/exwm-manage.el b/exwm-manage.el
index c083229c2dbe..16abe9845bc3 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -352,14 +352,26 @@ manager is shutting down."
         ;; Destroy the X window container (and the frame container if any).
         (xcb:+request exwm--connection
             (make-instance 'xcb:DestroyWindow :window exwm--container))
-        (let ((kill-buffer-query-functions nil)
-              (floating exwm--floating-frame))
-          (kill-buffer)
-          (when floating
-            (select-window
-             (frame-selected-window exwm-workspace--current)))))
-      (exwm-manage--set-client-list)
-      (xcb:flush exwm--connection))))
+        (exwm-manage--set-client-list)
+        (xcb:flush exwm--connection))
+      (let ((kill-buffer-func
+             (lambda (buffer)
+               (with-current-buffer buffer
+                 (let ((kill-buffer-query-functions nil)
+                       (floating exwm--floating-frame))
+                   (kill-buffer)
+                   (when floating
+                     (select-window
+                      (frame-selected-window exwm-workspace--current))))))))
+        (if (not (active-minibuffer-window))
+            ;; Kill the buffer as usual.
+            (funcall kill-buffer-func buffer)
+          ;; This can happen when this buffer was requested to be killed
+          ;; from the minibuffer (e.g. with `ido-kill-buffer-at-head').
+          ;; We have to exit the minibuffer first or there'll be a
+          ;; "selecting deleted buffer" error.
+          (run-with-idle-timer 0 nil kill-buffer-func buffer)
+          (exit-minibuffer))))))
 
 (defun exwm-manage--scan ()
   "Search for existing windows and try to manage them."