all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `kill-buffer-and-window' is too noisy (patch)
@ 2003-08-30 17:22 Paul Pogonyshev
  0 siblings, 0 replies; only message in thread
From: Paul Pogonyshev @ 2003-08-30 17:22 UTC (permalink / raw)


`kill-buffer-and-window' currently has a strange behaviour.  It asks user
whether to kill the buffer even if it is not modified, while `kill-buffer'
does not.

When the buffer is modified, the situation is even worse. First,
`kill-buffer-and-window' asks if to kill the buffer.  Then it deletes the
selected window thus hiding the buffer and then another question pops up:
`kill-buffer' has discovered the buffer is modified and asks if to kill it
again (and the buffer itself is hidden by now)!

The patch below must fix both problems.  I kept the order of killing
(first window, then buffer) using a hook.

Even if the window cannot be deleted, the buffer will be killed.  It seems
to be more logical, since otherwise `kill-buffer' queries may be ignored.



2003-08-30  Paul Pogonyshev  <pogonyshev@gmx.net>

	* window.el (kill-buffer-and-window): Remove `yes-or-no-p' so that
	the function is less noisy.  Now only `kill-buffer' can ask
	questions.



--- window.el.~1.89.~	2003-02-04 12:15:11.000000000 +0000
+++ window.el	2003-08-30 17:13:01.000000000 +0000
@@ -532,11 +532,18 @@ Return non-nil if the window was shrunk.
 (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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-08-30 17:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-30 17:22 `kill-buffer-and-window' is too noisy (patch) Paul Pogonyshev

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.