From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: bury-buffer Date: Thu, 11 Jul 2002 19:52:07 -0500 (CDT) Sender: emacs-devel-admin@gnu.org Message-ID: <200207120052.TAA00448@eel.dms.auburn.edu> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1026435129 14979 127.0.0.1 (12 Jul 2002 00:52:09 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 12 Jul 2002 00:52:09 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17SofI-0003tU-00 for ; Fri, 12 Jul 2002 02:52:08 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17Soow-00016x-00 for ; Fri, 12 Jul 2002 03:02:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17SofO-0001z1-00; Thu, 11 Jul 2002 20:52:14 -0400 Original-Received: from manatee.dms.auburn.edu ([131.204.53.104]) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17SoeP-0001wy-00 for ; Thu, 11 Jul 2002 20:51:13 -0400 Original-Received: from eel.dms.auburn.edu (eel.dms.auburn.edu [131.204.53.108]) by manatee.dms.auburn.edu (8.9.1a/8.9.1) with ESMTP id TAA04691 for ; Thu, 11 Jul 2002 19:51:11 -0500 (CDT) Original-Received: (from teirllm@localhost) by eel.dms.auburn.edu (8.9.3+Sun/8.9.3) id TAA00448; Thu, 11 Jul 2002 19:52:07 -0500 (CDT) X-Authentication-Warning: eel.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:5678 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:5678 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.