bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6454: 24.0.50; kill-buffer switches current-buffer


From: martin rudalics
Subject: bug#6454: 24.0.50; kill-buffer switches current-buffer
Date: Fri, 18 Jun 2010 21:12:05 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

>>> I know that kill-buffer should not change current-buffer.
>> What about C-x k  ;-)
>
> C-x k is no exception: the kill-buffer function there should not (and
> usually will not) change current-buffer (other than in the obvious case
> where we kill the current-buffer, obviously).

I obviously meant the obvious case ;-)

>> So we would have to check whether we want to kill the current buffer and
>> not change it if we don't.
>
> That's right.
>
>> Unfortunately, there's no proof that the buffer current when calling
>> `kill-buffer' is the buffer considered current by the outermost
>> calling application.  It might be just current because some
>> intermittent part (the actual caller of `kill-buffer') wanted to have
>> a look at the buffer's local variables.  So `kill-buffer' can't be
>> sure about the "real identity of the current buffer" either.
>
> I don't see a problem here.  Can you give a more detailed scenario?

When `kill-buffer' kills the current buffer it has to find a new current
buffer.  It does so as follows:

  if (b == current_buffer)
    {
      tem = Fother_buffer (buffer, Qnil, Qnil);
      Fset_buffer (tem);
      if (b == current_buffer)
        return Qnil;
    }

I had code in mind that does something not entirely unreasonable like

(dolist (buffer buffer-list)
  (with-current-buffer buffer
      (when this-is-a-buffer-that-should-be-killed
        (kill-buffer))))

where this-is-a-buffer-that-should-be-killed is a buffer-local variable.
In this case `kill-buffer' will rotate through all possible candidates
in order to make another buffer current.

martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]