]> git.eshelyaron.com Git - emacs.git/commitdiff
(kill-buffer-and-window): Fix a bug where an aborted
authorDavid Kastrup <dak@gnu.org>
Fri, 20 Oct 2006 15:12:31 +0000 (15:12 +0000)
committerDavid Kastrup <dak@gnu.org>
Fri, 20 Oct 2006 15:12:31 +0000 (15:12 +0000)
operation would still cause some window to collapse later.

lisp/ChangeLog
lisp/window.el

index 44439658b5638bf87a510cb6208b9c2233c7eb1d..e40671e1d9924c4c7fc806e4bdfaf7a24f5a8fe6 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-20  David Kastrup  <dak@gnu.org>
+
+       * window.el (kill-buffer-and-window): Fix a bug where an aborted
+       operation would still cause some window to collapse later.
+
 2006-10-20  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * vc.el (vc-switch-backend): Try to be more careful with unwanted
 
        * autoinsert.el (auto-insert-alist): Doc fix.
 
-2006-10-07  Johan Bockg\e,be\e(Brd  <bojohan@dd.chalmers.se>
+2006-10-07  Johan Bockg\e,Ae\e(Brd  <bojohan@dd.chalmers.se>
 
        * mouse-sel.el (mouse-insert-selection-internal):
        Use insert-for-yank, so that yank handlers are run.
index 0c50bc63a08c931790e714104759bd2a3c7b54a3..ac4fc0b7c96d8fd9a4a942f0f12e7db02d18b733 100644 (file)
@@ -719,17 +719,25 @@ or if the window is the only window of its frame."
   "Kill the current buffer and delete the selected window."
   (interactive)
   (let ((window-to-delete (selected-window))
+       (buffer-to-kill (current-buffer))
        (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))))
+    (unwind-protect
+       (progn
+         (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 echo area.
+             (when (eq (selected-window) window-to-delete)
+               (delete-window))))
+      ;; If the buffer is not dead for some reason (probably because
+      ;; of a `quit' signal), remove the hook again.
+      (condition-case nil
+         (with-current-buffer buffer-to-kill
+           (remove-hook 'kill-buffer-hook delete-window-hook t))
+       (error nil)))))
 
 (defun quit-window (&optional kill window)
   "Quit the current buffer.  Bury it, and maybe delete the selected frame.