From: martin rudalics <rudalics@gmx.at>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: 11665@debbugs.gnu.org
Subject: bug#11665: kill-buffer gives an error on killing dead buffers
Date: Sun, 10 Jun 2012 14:55:34 +0200 [thread overview]
Message-ID: <4FD49946.2040402@gmx.at> (raw)
In-Reply-To: <87r4tn4eoi.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]
> Create a buffer "test.tmp" and create an indirect buffer:
>
> (with-current-buffer (make-indirect-buffer "test.tmp" "test1")
> (add-hook 'kill-buffer-hook
> '(lambda ()
> (setq kill-buffer-hook nil)
> (kill-buffer (buffer-base-buffer)))
> t t))
>
> (The above triggers the killing of the base buffer when an indirect
> buffer is killed)
>
> Now, kill the base buffer "test.tmp", which raises:
>
> signal(error ("Buffer #<killed buffer> is not a live buffer"))
> error("Buffer %s is not a live buffer" #<killed buffer>)
> window-normalize-buffer(#<killed buffer>)
> replace-buffer-in-windows(#<killed buffer>)
> kill-buffer(#<killed buffer>)
> (if (and (boundp (quote sub-kill-buffer-and-its-windows)) sub-kill-buffer-and-its-windows (fboundp (quote kill-buffer-and-its-windows))) (kill-buffer-and-its-windows (current-buffer)) (kill-buffer (current-buffer)))
>
>
> This doesn't occur when killing an indirect buffer.
I don't have `sub-kill-buffer-and-its-windows' so I can't repeat this
easily. Anyway, here's what I suppose to happen:
Killing "test.tmp" implicitly calls `kill-buffer' on "test1" because
killing a base buffer kills all its indirect buffers.
Killing "test1" calls `kill-buffer' on "test.tmp" because that's on
the hook.
Killing "test.tmp" calls `kill-buffer' on "test1" again.
Killing "test1" now succeeds and returns.
Killing "test.tmp" now succeeds.
Killing "test1" now tries to continue with `replace-buffer-in-windows'
but this fails because the buffer is no more live.
I also suppose that the
> kill-buffer(#<killed buffer>)
is a red herring in the sense that `kill-buffer' was actually invoked
with a live buffer but when the trace was printed the buffer was already
dead while `replace-buffer-in-windows' was really called with a dead
buffer as argument.
Basically, I could exit `replace-buffer-in-windows' when the argument
buffer is not live but that's not nice. So maybe the attached patch is
better. Can you try it?
martin
[-- Attachment #2: buffer.c.diff --]
[-- Type: text/plain, Size: 514 bytes --]
*** src/buffer.c 2012-05-29 16:13:38 +0000
--- src/buffer.c 2012-06-10 12:52:57 +0000
***************
*** 1526,1531 ****
--- 1526,1535 ----
UNGCPRO;
}
+ /* If killing the indirect buffers has killed our buffer, return. */
+ if (NILP (BVAR (b, name)))
+ return Qnil;
+
/* Run replace_buffer_in_windows before making another buffer current
since set-window-buffer-start-and-point will refuse to make another
buffer current if the selected window does not show the current
next prev parent reply other threads:[~2012-06-10 12:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-10 10:57 bug#11665: kill-buffer gives an error on killing dead buffers Vitalie Spinu
2012-06-10 12:55 ` martin rudalics [this message]
2012-06-10 17:49 ` martin rudalics
2012-06-18 7:24 ` martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FD49946.2040402@gmx.at \
--to=rudalics@gmx.at \
--cc=11665@debbugs.gnu.org \
--cc=spinuvit@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.