Xref: utzoo gnu.emacs.help:807 comp.emacs:9879 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!UUNET.UU.NET!kyle From: kyle@UUNET.UU.NET (Kyle Jones) Newsgroups: gnu.emacs.help,comp.emacs Subject: bug in Freplace_buffer_in_windows (really window_loop) Message-ID: <9101171848.AA13535@wendy-fate.UU.NET> Date: 17 Jan 91 18:48:22 GMT Sender: daemon@tut.cis.ohio-state.edu Followup-To: gnu.emacs.help Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu Lines: 34 GNU Emacs version 18.55: In src/window.c, inside the definition of window_loop, at the part of the main switch statement that Freplace_buffer_in_windows uses, we see case 6: if (EQ (p->buffer, obj)) { tem = Fother_buffer (obj); if (NULL (tem)) tem = Fget_buffer_create (build_string ("*scratch*")); Fset_window_buffer (w, tem); Fset_buffer (p->buffer); } break; I think the call to Fset_buffer is a bug. Why does the current buffer need to be changed here? To illustrate the buggy behavior, consider this code: (delete-other-windows) (switch-to-buffer "aaa") (split-window) (switch-to-buffer "bbb") (kill-buffer "aaa") (message "%s" (current-buffer)) At this point the current buffer should still be "bbb", but it is not. If you put this code into a file and run "emacs -q -l ", you'll see # in the echo area. The bug nails Fkill_buffer because it calls Freplace_buffer_in_windows which in turn calls window_loop.