changeset 52481:f1cce2846e29

(kill-buffer-and-window): Remove `yes-or-no-p' so that the function is less noisy. Now only `kill-buffer' can ask questions.
author Richard M. Stallman <rms@gnu.org>
date Fri, 12 Sep 2003 00:52:08 +0000
parents dc467d89341e
children 702be51912a8
files lisp/window.el
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/window.el	Fri Sep 12 00:51:13 2003 +0000
+++ b/lisp/window.el	Fri Sep 12 00:52:08 2003 +0000
@@ -532,11 +532,18 @@
 (defun kill-buffer-and-window ()
   "Kill the current buffer and delete the selected window."
   (interactive)
-  (if (yes-or-no-p (format "Kill buffer `%s'? " (buffer-name)))
-      (let ((buffer (current-buffer)))
-	(delete-window (selected-window))
-	(kill-buffer buffer))
-    (error "Aborted")))
+  (let ((window-to-delete (selected-window))
+	(delete-window-hook (lambda ()
+			      (condition-case nil
+				  (delete-window)
+				(error nil)))))
+    (add-hook 'kill-buffer-hook delete-window-hook t t)
+    (if (kill-buffer (current-buffer))
+	;; If `delete-window' failed before, we rerun it to regenerate
+	;; the error so it can be seen in the minibuffer.
+	(when (eq (selected-window) window-to-delete)
+	  (delete-window))
+      (remove-hook 'kill-buffer-hook delete-window-hook t))))
 
 (defun quit-window (&optional kill window)
   "Quit the current buffer.  Bury it, and maybe delete the selected frame.