[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11665: kill-buffer gives an error on killing dead buffers
From: |
martin rudalics |
Subject: |
bug#11665: kill-buffer gives an error on killing dead buffers |
Date: |
Sun, 10 Jun 2012 19:49:29 +0200 |
There seem more occasions where this problem could strike. Also, we
should return t when we find out that the buffer name has been reset to
nil under our feet. Patch attached, comments welcome.
martin
*** src/buffer.c 2012-05-29 16:13:38 +0000
--- src/buffer.c 2012-06-10 17:33:15 +0000
***************
*** 1493,1498 ****
--- 1493,1502 ----
unbind_to (count, Qnil);
}
+ /* If the hooks have killed the buffer, exit now. */
+ if (NILP (BVAR (b, name)))
+ return Qt;
+
/* We have no more questions to ask. Verify that it is valid
to kill the buffer. This must be done after the questions
since anything can happen within do_yes_or_no_p. */
***************
*** 1501,1509 ****
if (EQ (buffer, XWINDOW (minibuf_window)->buffer))
return Qnil;
- if (NILP (BVAR (b, name)))
- return Qnil;
-
/* When we kill a base buffer, kill all its indirect buffers.
We do it at this stage so nothing terrible happens if they
ask questions or their hooks get errors. */
--- 1505,1510 ----
***************
*** 1526,1540 ****
UNGCPRO;
}
/* Run replace_buffer_in_windows before making another buffer current
since set-window-buffer-start-and-point will refuse to make another
buffer current if the selected window does not show the current
buffer. (Bug#10114) */
replace_buffer_in_windows (buffer);
! /* Make this buffer not be current.
! In the process, notice if this is the sole visible buffer
! and give up if so. */
if (b == current_buffer)
{
tem = Fother_buffer (buffer, Qnil, Qnil);
--- 1527,1549 ----
UNGCPRO;
}
+ /* If killing the indirect buffers has killed our buffer, return. */
+ if (NILP (BVAR (b, name)))
+ return Qt;
+
/* Run replace_buffer_in_windows before making another buffer current
since set-window-buffer-start-and-point will refuse to make another
buffer current if the selected window does not show the current
buffer. (Bug#10114) */
replace_buffer_in_windows (buffer);
! /* If replacing the buffer in windows has killed our buffer,
! return. */
! if (NILP (BVAR (b, name)))
! return Qt;
!
! /* Make this buffer not be current. In the process, notice if this is
! the sole visible buffer and give up if so. */
if (b == current_buffer)
{
tem = Fother_buffer (buffer, Qnil, Qnil);
***************
*** 1564,1574 ****
kill_buffer_processes (buffer);
UNGCPRO;
! /* Killing buffer processes may run sentinels which may
! have called kill-buffer. */
!
if (NILP (BVAR (b, name)))
! return Qnil;
/* These may run Lisp code and into infinite loops (if someone
insisted on circular lists) so allow quitting here. */
--- 1573,1582 ----
kill_buffer_processes (buffer);
UNGCPRO;
! /* Killing buffer processes may run sentinels which may have called
! kill-buffer. */
if (NILP (BVAR (b, name)))
! return Qt;
/* These may run Lisp code and into infinite loops (if someone
insisted on circular lists) so allow quitting here. */
***************
*** 1599,1604 ****
--- 1607,1616 ----
internal_delete_file (BVAR (b, auto_save_file_name));
}
+ /* Deleting a file could have killed our buffer. */
+ if (NILP (BVAR (b, name)))
+ return Qt;
+
if (b->base_buffer)
{
/* Unchain all markers that belong to this indirect buffer.