=== modified file 'src/buffer.c' --- src/buffer.c 2010-06-05 00:41:32 +0000 +++ src/buffer.c 2010-06-20 17:24:02 +0000 @@ -1413,6 +1413,9 @@ register struct Lisp_Marker *m; struct gcpro gcpro1; + int count = SPECPDL_INDEX (); + record_unwind_protect (save_excursion_restore, save_excursion_save ()); + if (NILP (buffer_or_name)) buffer = Fcurrent_buffer (); else @@ -1424,7 +1427,7 @@ /* Avoid trouble for buffer already dead. */ if (NILP (b->name)) - return Qnil; + return unbind_to (count, Qnil); /* Query if the buffer is still modified. */ if (INTERACTIVE && !NILP (b->filename) @@ -1435,15 +1438,13 @@ b->name, make_number (0))); UNGCPRO; if (NILP (tem)) - return Qnil; + return unbind_to (count, Qnil); } /* Run hooks with the buffer to be killed the current buffer. */ { - int count = SPECPDL_INDEX (); Lisp_Object arglist[1]; - record_unwind_protect (save_excursion_restore, save_excursion_save ()); set_buffer_internal (b); /* First run the query functions; if any query is answered no, @@ -1455,7 +1456,6 @@ /* Then run the hooks. */ Frun_hooks (1, &Qkill_buffer_hook); - unbind_to (count, Qnil); } /* We have no more questions to ask. Verify that it is valid @@ -1464,10 +1464,10 @@ /* Don't kill the minibuffer now current. */ if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) - return Qnil; + return unbind_to (count, Qnil); if (NILP (b->name)) - return Qnil; + return unbind_to (count, Qnil); /* When we kill a base buffer, kill all its indirect buffers. We do it at this stage so nothing terrible happens if they @@ -1499,7 +1499,7 @@ tem = Fother_buffer (buffer, Qnil, Qnil); Fset_buffer (tem); if (b == current_buffer) - return Qnil; + return unbind_to (count, Qnil); } /* Notice if the buffer to kill is the sole visible buffer @@ -1509,7 +1509,7 @@ { tem = Fother_buffer (buffer, Qnil, Qnil); if (EQ (buffer, tem)) - return Qnil; + return unbind_to (count, Qnil); } /* Now there is no question: we can kill the buffer. */ @@ -1527,7 +1527,7 @@ have called kill-buffer. */ if (NILP (b->name)) - return Qnil; + return unbind_to (count, Qnil); clear_charpos_cache (b); @@ -1609,7 +1609,7 @@ UNBLOCK_INPUT; b->undo_list = Qnil; - return Qt; + return unbind_to (count, Qt); } /* Move the assoc for buffer BUF to the front of buffer-alist. Since