unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* bury-buffer
@ 2002-07-12  0:52 Luc Teirlinck
  2002-07-14 15:22 ` bury-buffer Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Luc Teirlinck @ 2002-07-12  0:52 UTC (permalink / raw)


There is a problem with bury-buffer.  Its documentation string says
that, with no argument or an argument of nil, it is going to remove
the current buffer from the selected window "if it is displayed
there".  The problem is that it removes any buffer displayed in the
selected window whether current or not.

Just do:

M-: (with-temp-buffer (bury-buffer))

This should not have any effect whatsoever.  It creates a temporary
buffer, makes it current, buries it and kills it, supposedly then
restoring the original current buffer.  This is not what happens. The
original current buffer disappears from the screen.  It did not really
get buried, it is still second in the buffer list after the newly
selected buffer.  All very confusing.

Clearly, (with-temp-buffer (bury-buffer)) is a pretty useless piece of
code.

But the behavior of bury-buffer does cause actual problems, for
instance in ielm.  One often plays around in ielm with a "working
buffer" which is the current buffer during evaluation of forms.
Testing pieces of code involving burying buffers makes the ielm buffer
disappear from the screen, although it is not current when the
(bury-buffer) gets executed.

I tracked the problem down to the C code.  I can program C, but I am
not very familiar with the Emacs C code.

From the emacs21.2.90 code of buffer.c:   


DEFUN ("bury-buffer", Fbury_buffer, Sbury_buffer, 0, 1, "",
  "Put BUFFER at the end of the list of all buffers.\n\
There it is the least likely candidate for `other-buffer' to
  return;\n\
thus, the least likely buffer for \\[switch-to-buffer] to select by
  default.\n\
If BUFFER is nil or omitted, bury the current buffer.\n\
Also, if BUFFER is nil or omitted, remove the current buffer from
  the\n\
selected window if it is displayed there.")
  (buffer)
     register Lisp_Object buffer;
{
  /* Figure out what buffer we're going to bury.  */
  if (NILP (buffer))
    {
      XSETBUFFER (buffer, current_buffer);

      /* If we're burying the current buffer, unshow it.  */
      Fswitch_to_buffer (Fother_buffer (buffer, Qnil, Qnil), Qnil);
    }
  else

Remarks:

/* If we're burying the current buffer, unshow it.  */

Immediately following that comment, we need an extra if-statement:

      if (...)
         Fswitch_to_buffer (Fother_buffer (buffer, Qnil, Qnil), Qnil);

where (...) should check whether the current buffer is, in fact,
displayed in the selected window.  Since I am not terribly familiar
with the Emacs C code, I do not know the exact semantics, but this
probably is relatively easy for somebody used to play around with the
Emacs C sources.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: bury-buffer
  2002-07-12  0:52 bury-buffer Luc Teirlinck
@ 2002-07-14 15:22 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2002-07-14 15:22 UTC (permalink / raw)
  Cc: emacs-devel

It looks like this has been fixed in the development version:

2001-10-11  Stefan Monnier  <monnier@cs.yale.edu>

	* buffer.c (Fbury_buffer): Don't try to remove the buffer from the
	selected window if it's not displayed there.  Handle the case
	when the window is dedicated.

Eli, could you put that change into RC?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-14 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-12  0:52 bury-buffer Luc Teirlinck
2002-07-14 15:22 ` bury-buffer Richard Stallman

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).