From 46b7967e4d98570501f5e75ba7460fa4c79e4617 Mon Sep 17 00:00:00 2001
From: Troels Nielsen <bn.troels@gmail.com>
Date: Tue, 29 May 2012 20:22:49 +0800
Subject: [PATCH] Fix active minibuffer case for window-deletable-p.

* window.el (window-deletable-p): Avoid deleting the root window
of a frame with an active minibuffer.
---
 lisp/ChangeLog | 5 +++++
 lisp/window.el | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a98bdda3526..fbb398335d8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-29  Troels Nielsen  <bn.troels@gmail.com>
+
+	* window.el (window-deletable-p): Avoid deleting the root window
+	of a frame with an active minibuffer.
+
 2012-05-29  Martin Rudalics  <rudalics@gmx.at>
 
 	* simple.el (choose-completion): Use quit-window (Bug#11567).
diff --git a/lisp/window.el b/lisp/window.el
index a650c5602ba..52b0a31e241 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2370,8 +2370,11 @@ frame."
     (cond
      ((frame-root-window-p window)
       ;; WINDOW's frame can be deleted only if there are other frames
-      ;; on the same terminal.
-      (unless (eq frame (next-frame frame 0))
+      ;; on the same terminal, and it does not contain the active
+      ;; minibuffer.
+      (unless (or (eq frame (next-frame frame 0))
+		  (let ((minibuf (active-minibuffer-window)))
+		    (and minibuf (eq frame (window-frame minibuf)))))
 	'frame))
      ((or ignore-window-parameters
 	  (not (eq (window-parameter window 'window-side) 'none))
-- 
2.39.5